Skip to content

Commit 1ee6e10

Browse files
committed
nix: fixed usage of derivations' attrs and artifacts
1 parent 703b4c9 commit 1ee6e10

File tree

4 files changed

+43
-33
lines changed

4 files changed

+43
-33
lines changed

nix/common/artifacts.nix

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,32 @@
33
inherit (config) craneLib commonArgs commonArgsNative;
44
in {
55
options = {
6+
# Production artifacts - minimal dependencies
67
cargoArtifacts = lib.mkOption {
78
type = lib.types.package;
89
default = craneLib.buildDepsOnly (commonArgs
910
// {
1011
pname = "odido-aap";
11-
# Include dev dependencies for clippy offline mode
12-
cargoCheckExtraArgs = "--all-targets --all-features";
1312
});
1413
};
14+
1515
cargoArtifactsNative = lib.mkOption {
1616
type = lib.types.package;
1717
default = craneLib.buildDepsOnly (commonArgsNative
1818
// {
1919
pname = "odido-aap-native";
2020
});
2121
};
22+
23+
# Development artifacts - includes test/bench deps for clippy offline mode
24+
cargoArtifactsDev = lib.mkOption {
25+
type = lib.types.package;
26+
default = craneLib.buildDepsOnly (commonArgs
27+
// {
28+
pname = "odido-aap-dev";
29+
cargoCheckExtraArgs = "--all-targets";
30+
});
31+
};
2232
};
2333
};
2434
}

nix/common/default.nix

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{lib, ...}: {
22
imports = [
33
./rust-toolchain.nix
44
./crane-lib.nix
@@ -8,16 +8,23 @@
88

99
perSystem = {config, ...}: let
1010
inherit (config) craneLib commonArgs commonArgsNative cargoArtifacts cargoArtifactsNative;
11+
12+
meta = {
13+
description = "Odido AAP CLI tool";
14+
license = lib.licenses.mit;
15+
mainProgram = "odido";
16+
};
1117
in {
1218
packages = {
1319
odido-aap = craneLib.buildPackage (commonArgs
1420
// {
15-
inherit cargoArtifacts;
21+
inherit cargoArtifacts meta;
1622
});
1723

1824
odido-aap-native = craneLib.buildPackage (commonArgsNative
1925
// {
20-
inherit cargoArtifactsNative;
26+
cargoArtifacts = cargoArtifactsNative;
27+
inherit meta;
2128
});
2229
};
2330
};

nix/common/rust-toolchain.nix

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
{lib, ...}: {
2-
perSystem = {inputs', ...}: {
2+
perSystem = {inputs', ...}: let
3+
fenix = inputs'.fenix.packages;
4+
in {
35
options.rust-toolchain = lib.mkOption {
4-
type = lib.types.attrs;
5-
6-
default = with inputs'.fenix.packages;
7-
with default;
8-
combine [
9-
cargo
10-
clippy
11-
rust-std
12-
rustc
13-
rustc-unwrapped
14-
rustfmt
15-
];
6+
type = lib.types.package;
7+
default = fenix.combine [
8+
fenix.default.cargo
9+
fenix.default.clippy
10+
fenix.default.rust-std
11+
fenix.default.rustc
12+
fenix.default.rustc-unwrapped
13+
fenix.default.rustfmt
14+
];
1615
};
1716
};
1817
}

nix/dev/checks.nix

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
11
{
22
perSystem = {config, ...}: let
3-
inherit (config) craneLib src commonArgs cargoArtifacts;
3+
inherit (config) craneLib src commonArgs cargoArtifacts cargoArtifactsDev;
44
in {
55
checks = {
66
inherit (config.packages) odido-aap;
77

8-
odido-aap-clippy = craneLib.cargoClippy (
9-
commonArgs
8+
odido-aap-clippy = craneLib.cargoClippy (commonArgs
109
// {
11-
inherit cargoArtifacts;
10+
cargoArtifacts = cargoArtifactsDev;
1211
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
13-
}
14-
);
12+
});
1513

16-
odido-aap-doc = craneLib.cargoDoc (
17-
commonArgs
14+
odido-aap-doc = craneLib.cargoDoc (commonArgs
1815
// {
1916
inherit cargoArtifacts;
20-
}
21-
);
17+
});
2218

2319
odido-aap-fmt = craneLib.cargoFmt {
2420
inherit src;
2521
};
2622

27-
odido-aap-nextest = craneLib.cargoNextest (
28-
commonArgs
23+
odido-aap-nextest = craneLib.cargoNextest (commonArgs
2924
// {
30-
inherit cargoArtifacts;
25+
cargoArtifacts = cargoArtifactsDev;
3126
partitions = 1;
3227
partitionType = "count";
33-
}
34-
);
28+
});
3529
};
3630
};
3731
}

0 commit comments

Comments
 (0)