Skip to content

Commit 9a25834

Browse files
authored
Merge pull request #671 from kivikakk/push-xztplxsxllsp
flake.nix: simplify, build for linux with musl.
2 parents ffcd85f + 4f4eb36 commit 9a25834

File tree

3 files changed

+32
-94
lines changed

3 files changed

+32
-94
lines changed

flake.lock

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 17 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
6-
crane.url = "github:ipetkov/crane";
76
fenix = {
87
url = "github:nix-community/fenix";
98
inputs.nixpkgs.follows = "nixpkgs";
@@ -12,10 +11,9 @@
1211

1312
outputs =
1413
{
15-
self,
1614
nixpkgs,
17-
crane,
1815
fenix,
16+
...
1917
}:
2018
let
2119
systems = [
@@ -25,89 +23,35 @@
2523
"x86_64-linux"
2624
];
2725
eachSystem = nixpkgs.lib.genAttrs systems;
26+
in
27+
{
2828

29-
mkComrak =
29+
packages = eachSystem (
3030
system:
3131
let
3232
pkgs = nixpkgs.legacyPackages.${system};
33-
craneLib = crane.mkLib pkgs;
34-
src = craneLib.cleanCargoSource (craneLib.path ./.);
35-
36-
commonArgs = {
37-
inherit src;
38-
39-
buildInputs = nixpkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
40-
};
33+
cargoToml = pkgs.lib.importTOML ./Cargo.toml;
4134

42-
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
35+
mkComrak =
36+
pkgs:
37+
pkgs.rustPlatform.buildRustPackage {
38+
pname = "comrak";
39+
inherit (cargoToml.package) version;
4340

44-
comrak = craneLib.buildPackage (
45-
commonArgs
46-
// {
47-
inherit cargoArtifacts;
41+
src = ./.;
42+
cargoLock.lockFile = ./Cargo.lock;
4843

4944
doCheck = false;
50-
}
51-
);
52-
in
53-
{
54-
inherit
55-
craneLib
56-
src
57-
commonArgs
58-
cargoArtifacts
59-
comrak
60-
;
61-
};
62-
63-
in
64-
{
65-
66-
checks = eachSystem (
67-
system:
68-
let
69-
inherit (mkComrak system)
70-
craneLib
71-
src
72-
commonArgs
73-
cargoArtifacts
74-
comrak
75-
;
45+
};
7646
in
77-
{
78-
inherit comrak;
47+
rec {
48+
default = comrak;
7949

80-
comrak-clippy = craneLib.cargoClippy (
81-
commonArgs
82-
// {
83-
inherit cargoArtifacts;
84-
# cargoClippyExtraArgs = "--lib --bins --examples --tests -- --deny warnings";
85-
# XXX Not sure if we can fix all these and retain our current MSRV.
86-
cargoClippyExtraArgs = "--lib --bins --examples --tests";
87-
}
88-
);
89-
90-
comrak-doc = craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; });
91-
92-
comrak-fmt = craneLib.cargoFmt { inherit src; };
93-
94-
comrak-nextest = craneLib.cargoNextest (
95-
commonArgs
96-
// {
97-
inherit cargoArtifacts;
98-
partitions = 1;
99-
partitionType = "count";
100-
}
101-
);
50+
comrak = mkComrak pkgs;
51+
comrak-musl = mkComrak pkgs.pkgsStatic;
10252
}
10353
);
10454

105-
packages = eachSystem (system: rec {
106-
default = comrak;
107-
108-
inherit (mkComrak system) comrak;
109-
});
110-
11155
formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
11256

11357
devShells = eachSystem (

script/build-releases

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@ function build {
1010
local rust_ver="$1"
1111
local flake_ref="$2"
1212

13-
echo "--- building $flake_ref"
14-
nix build ".#$flake_ref" &&
15-
cp result/bin/comrak "comrak-$version-$rust_ver"
13+
local target="comrak-$version-$rust_ver"
14+
local nix="nix"
15+
if command -v nom &>/dev/null; then
16+
nix="nom"
17+
fi
18+
19+
if ! test -f "$target"; then
20+
echo "--- building $flake_ref"
21+
"$nix" build ".#$flake_ref" &&
22+
cp result/bin/comrak "$target"
23+
else
24+
echo "--- skipping $flake_ref, $target already exists"
25+
fi
1626
}
1727

1828
build aarch64-apple-darwin packages.aarch64-darwin.default
1929
build x86_64-apple-darwin packages.x86_64-darwin.default
20-
build aarch64-unknown-linux-gnu packages.aarch64-linux.default
21-
build x86_64-unknown-linux-gnu packages.x86_64-linux.default
30+
build aarch64-unknown-linux-musl packages.aarch64-linux.comrak-musl
31+
build x86_64-unknown-linux-musl packages.x86_64-linux.comrak-musl
2232

2333
file "comrak-$version-"*

0 commit comments

Comments
 (0)