|
22 | 22 | inherit (pkgs) lib;
|
23 | 23 |
|
24 | 24 | craneLib = crane.mkLib pkgs;
|
25 |
| - src = craneLib.cleanCargoSource ./.; |
| 25 | + src = ./.; |
26 | 26 |
|
27 | 27 | # Common arguments can be set here to avoid repeating them later
|
28 | 28 | commonArgs = {
|
29 | 29 | inherit src;
|
30 | 30 | strictDeps = true;
|
31 | 31 |
|
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 ]; |
38 | 44 |
|
39 | 45 | # Additional environment variables can be set directly
|
40 | 46 | # MY_CUSTOM_VAR = "some value";
|
|
46 | 52 |
|
47 | 53 | # Build the actual crate itself, reusing the dependency
|
48 | 54 | # 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 { |
54 | 58 | checks = {
|
55 | 59 | # Build the crate as part of `nix flake check` for convenience
|
56 |
| - inherit my-crate; |
| 60 | + inherit onefetch; |
57 | 61 |
|
58 | 62 | # Run clippy (and deny all warnings) on the crate source,
|
59 | 63 | # again, reusing the dependency artifacts from above.
|
60 | 64 | #
|
61 | 65 | # Note that this is done as a separate derivation so that
|
62 | 66 | # we can block the CI if there are issues here, but not
|
63 | 67 | # prevent downstream consumers from building our crate by itself.
|
64 |
| - my-crate-clippy = craneLib.cargoClippy (commonArgs // { |
| 68 | + onefetch-clippy = craneLib.cargoClippy (commonArgs // { |
65 | 69 | inherit cargoArtifacts;
|
66 | 70 | cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
67 | 71 | });
|
68 | 72 |
|
69 |
| - my-crate-doc = craneLib.cargoDoc (commonArgs // { |
70 |
| - inherit cargoArtifacts; |
71 |
| - }); |
| 73 | + onefetch-doc = |
| 74 | + craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; }); |
72 | 75 |
|
73 | 76 | # Check formatting
|
74 |
| - my-crate-fmt = craneLib.cargoFmt { |
75 |
| - inherit src; |
76 |
| - }; |
| 77 | + onefetch-fmt = craneLib.cargoFmt { inherit src; }; |
77 | 78 |
|
78 |
| - my-crate-toml-fmt = craneLib.taploFmt { |
| 79 | + onefetch-toml-fmt = craneLib.taploFmt { |
79 | 80 | src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ];
|
80 | 81 | # taplo arguments can be further customized below as needed
|
81 | 82 | # taploExtraArgs = "--config ./taplo.toml";
|
82 | 83 | };
|
83 | 84 |
|
84 | 85 | # Audit dependencies
|
85 |
| - my-crate-audit = craneLib.cargoAudit { |
86 |
| - inherit src advisory-db; |
87 |
| - }; |
| 86 | + onefetch-audit = craneLib.cargoAudit { inherit src advisory-db; }; |
88 | 87 |
|
89 | 88 | # Audit licenses
|
90 |
| - my-crate-deny = craneLib.cargoDeny { |
91 |
| - inherit src; |
92 |
| - }; |
| 89 | + onefetch-deny = craneLib.cargoDeny { inherit src; }; |
93 | 90 |
|
94 | 91 | # Run tests with cargo-nextest
|
95 | 92 | # Consider setting `doCheck = false` on `my-crate` if you do not want
|
96 | 93 | # the tests to run twice
|
97 |
| - my-crate-nextest = craneLib.cargoNextest (commonArgs // { |
| 94 | + onefetch-nextest = craneLib.cargoNextest (commonArgs // { |
98 | 95 | inherit cargoArtifacts;
|
99 | 96 | partitions = 1;
|
100 | 97 | partitionType = "count";
|
101 | 98 | cargoNextestPartitionsExtraArgs = "--no-tests=pass";
|
102 | 99 | });
|
103 | 100 | };
|
104 | 101 |
|
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; |
107 | 111 | };
|
108 | 112 |
|
109 |
| - apps.default = flake-utils.lib.mkApp { |
110 |
| - drv = my-crate; |
111 |
| - }; |
| 113 | + apps.default = flake-utils.lib.mkApp { drv = onefetch; }; |
112 | 114 |
|
113 | 115 | devShells.default = craneLib.devShell {
|
114 | 116 | # Inherit inputs from checks.
|
|
118 | 120 | # MY_CUSTOM_DEVELOPMENT_VAR = "something else";
|
119 | 121 |
|
120 | 122 | # Extra inputs can be added here; cargo and rustc are provided by default.
|
121 |
| - packages = [ |
| 123 | + packages = with pkgs; [ |
122 | 124 | # pkgs.ripgrep
|
| 125 | + nixd |
| 126 | + nixfmt |
123 | 127 | ];
|
124 | 128 | };
|
125 | 129 | });
|
|
0 commit comments