Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 17 additions & 73 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
crane.url = "github:ipetkov/crane";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -12,10 +11,9 @@

outputs =
{
self,
nixpkgs,
crane,
fenix,
...
}:
let
systems = [
Expand All @@ -25,89 +23,35 @@
"x86_64-linux"
];
eachSystem = nixpkgs.lib.genAttrs systems;
in
{

mkComrak =
packages = eachSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs;
src = craneLib.cleanCargoSource (craneLib.path ./.);

commonArgs = {
inherit src;

buildInputs = nixpkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
};
cargoToml = pkgs.lib.importTOML ./Cargo.toml;

cargoArtifacts = craneLib.buildDepsOnly commonArgs;
mkComrak =
pkgs:
pkgs.rustPlatform.buildRustPackage {
pname = "comrak";
inherit (cargoToml.package) version;

comrak = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;

doCheck = false;
}
);
in
{
inherit
craneLib
src
commonArgs
cargoArtifacts
comrak
;
};

in
{

checks = eachSystem (
system:
let
inherit (mkComrak system)
craneLib
src
commonArgs
cargoArtifacts
comrak
;
};
in
{
inherit comrak;
rec {
default = comrak;

comrak-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
# cargoClippyExtraArgs = "--lib --bins --examples --tests -- --deny warnings";
# XXX Not sure if we can fix all these and retain our current MSRV.
cargoClippyExtraArgs = "--lib --bins --examples --tests";
}
);

comrak-doc = craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; });

comrak-fmt = craneLib.cargoFmt { inherit src; };

comrak-nextest = craneLib.cargoNextest (
commonArgs
// {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
}
);
comrak = mkComrak pkgs;
comrak-musl = mkComrak pkgs.pkgsStatic;
}
);

packages = eachSystem (system: rec {
default = comrak;

inherit (mkComrak system) comrak;
});

formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);

devShells = eachSystem (
Expand Down
20 changes: 15 additions & 5 deletions script/build-releases
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,24 @@ function build {
local rust_ver="$1"
local flake_ref="$2"

echo "--- building $flake_ref"
nix build ".#$flake_ref" &&
cp result/bin/comrak "comrak-$version-$rust_ver"
local target="comrak-$version-$rust_ver"
local nix="nix"
if command -v nom &>/dev/null; then
nix="nom"
fi

if ! test -f "$target"; then
echo "--- building $flake_ref"
"$nix" build ".#$flake_ref" &&
cp result/bin/comrak "$target"
else
echo "--- skipping $flake_ref, $target already exists"
fi
}

build aarch64-apple-darwin packages.aarch64-darwin.default
build x86_64-apple-darwin packages.x86_64-darwin.default
build aarch64-unknown-linux-gnu packages.aarch64-linux.default
build x86_64-unknown-linux-gnu packages.x86_64-linux.default
build aarch64-unknown-linux-musl packages.aarch64-linux.comrak-musl
build x86_64-unknown-linux-musl packages.x86_64-linux.comrak-musl

file "comrak-$version-"*