Skip to content

Commit 77afd70

Browse files
committed
flake: fixes
> add nix tools to devShell (rust-required stuff provided by default) > add build dependencies > add build profiles
1 parent 0211e90 commit 77afd70

File tree

2 files changed

+132
-34
lines changed

2 files changed

+132
-34
lines changed

flake.lock

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

flake.nix

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,25 @@
2222
inherit (pkgs) lib;
2323

2424
craneLib = crane.mkLib pkgs;
25-
src = craneLib.cleanCargoSource ./.;
25+
src = ./.;
2626

2727
# Common arguments can be set here to avoid repeating them later
2828
commonArgs = {
2929
inherit src;
3030
strictDeps = true;
3131

32-
buildInputs = [
33-
# Add additional build inputs here
34-
] ++ lib.optionals pkgs.stdenv.isDarwin [
35-
# Additional darwin specific inputs can be set here
36-
pkgs.libiconv
37-
];
32+
buildInputs = with pkgs;
33+
[
34+
# package dependencies
35+
zstd
36+
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
37+
# additional dependencies on Darwin systems
38+
CoreFoundation
39+
libresolv
40+
Security
41+
]);
42+
nativeBuildInputs = with pkgs; [ cmake pkg-config ];
43+
nativeCheckInputs = with pkgs; [ git ];
3844

3945
# Additional environment variables can be set directly
4046
# MY_CUSTOM_VAR = "some value";
@@ -46,69 +52,65 @@
4652

4753
# Build the actual crate itself, reusing the dependency
4854
# artifacts from above.
49-
my-crate = craneLib.buildPackage (commonArgs // {
50-
inherit cargoArtifacts;
51-
});
52-
in
53-
{
55+
onefetch =
56+
craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
57+
in {
5458
checks = {
5559
# Build the crate as part of `nix flake check` for convenience
56-
inherit my-crate;
60+
inherit onefetch;
5761

5862
# Run clippy (and deny all warnings) on the crate source,
5963
# again, reusing the dependency artifacts from above.
6064
#
6165
# Note that this is done as a separate derivation so that
6266
# we can block the CI if there are issues here, but not
6367
# prevent downstream consumers from building our crate by itself.
64-
my-crate-clippy = craneLib.cargoClippy (commonArgs // {
68+
onefetch-clippy = craneLib.cargoClippy (commonArgs // {
6569
inherit cargoArtifacts;
6670
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
6771
});
6872

69-
my-crate-doc = craneLib.cargoDoc (commonArgs // {
70-
inherit cargoArtifacts;
71-
});
73+
onefetch-doc =
74+
craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; });
7275

7376
# Check formatting
74-
my-crate-fmt = craneLib.cargoFmt {
75-
inherit src;
76-
};
77+
onefetch-fmt = craneLib.cargoFmt { inherit src; };
7778

78-
my-crate-toml-fmt = craneLib.taploFmt {
79+
onefetch-toml-fmt = craneLib.taploFmt {
7980
src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ];
8081
# taplo arguments can be further customized below as needed
8182
# taploExtraArgs = "--config ./taplo.toml";
8283
};
8384

8485
# Audit dependencies
85-
my-crate-audit = craneLib.cargoAudit {
86-
inherit src advisory-db;
87-
};
86+
onefetch-audit = craneLib.cargoAudit { inherit src advisory-db; };
8887

8988
# Audit licenses
90-
my-crate-deny = craneLib.cargoDeny {
91-
inherit src;
92-
};
89+
onefetch-deny = craneLib.cargoDeny { inherit src; };
9390

9491
# Run tests with cargo-nextest
9592
# Consider setting `doCheck = false` on `my-crate` if you do not want
9693
# the tests to run twice
97-
my-crate-nextest = craneLib.cargoNextest (commonArgs // {
94+
onefetch-nextest = craneLib.cargoNextest (commonArgs // {
9895
inherit cargoArtifacts;
9996
partitions = 1;
10097
partitionType = "count";
10198
cargoNextestPartitionsExtraArgs = "--no-tests=pass";
10299
});
103100
};
104101

105-
packages = {
106-
default = my-crate;
102+
packages = rec {
103+
onefetch-debug = onefetch // {
104+
cargoExtraArgs = lib.concatStringsSep " " [
105+
# Just to get more human-readable look
106+
"--profile dev"
107+
];
108+
};
109+
inherit onefetch;
110+
default = onefetch-debug;
107111
};
108112

109-
apps.default = flake-utils.lib.mkApp {
110-
drv = my-crate;
111-
};
113+
apps.default = flake-utils.lib.mkApp { drv = onefetch; };
112114

113115
devShells.default = craneLib.devShell {
114116
# Inherit inputs from checks.
@@ -118,8 +120,10 @@
118120
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
119121

120122
# Extra inputs can be added here; cargo and rustc are provided by default.
121-
packages = [
123+
packages = with pkgs; [
122124
# pkgs.ripgrep
125+
nixd
126+
nixfmt
123127
];
124128
};
125129
});

0 commit comments

Comments
 (0)