|
18 | 18 | };
|
19 | 19 | };
|
20 | 20 |
|
| 21 | + outputs = { |
| 22 | + self, |
| 23 | + nixpkgs, |
| 24 | + utils, |
| 25 | + naersk, |
| 26 | + rust-overlay, |
| 27 | + ... |
| 28 | + }: |
21 | 29 | utils.lib.eachDefaultSystem (system:
|
22 | 30 | let
|
23 |
| - pkgs = import nixpkgs { inherit system; }; |
| 31 | + overlays = [ (import rust-overlay) ]; |
| 32 | + |
| 33 | + pkgs = (import nixpkgs) { |
| 34 | + inherit system overlays; |
| 35 | + }; |
| 36 | + |
| 37 | + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; |
| 38 | + |
| 39 | + naersk' = pkgs.callPackage naersk { |
| 40 | + cargo = toolchain; |
| 41 | + rustc = toolchain; |
| 42 | + clippy = toolchain; |
| 43 | + }; |
24 | 44 |
|
25 | 45 | nativeBuildInputs = with pkgs; [
|
26 | 46 | pkg-config
|
27 | 47 | ];
|
28 | 48 |
|
| 49 | + darwinBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ |
| 50 | + pkgs.darwin.apple_sdk.frameworks.Security |
| 51 | + pkgs.darwin.apple_sdk.frameworks.SystemConfiguration |
| 52 | + ]; |
| 53 | + |
29 | 54 | buildInputs = with pkgs; [
|
30 | 55 | openssl
|
31 | 56 | dbus
|
32 | 57 | sqlite
|
33 |
| - ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration ]); |
34 |
| - |
| 58 | + ] ++ darwinBuildInputs; |
35 | 59 |
|
36 |
| - package = with pkgs; rustPlatform.buildRustPackage rec { |
| 60 | + package = naersk'.buildPackage rec { |
37 | 61 | pname = "leetcode-cli";
|
38 | 62 | version = "git";
|
| 63 | + |
39 | 64 | src = ./.;
|
| 65 | + doCheck = true; # run `cargo test` on build |
40 | 66 |
|
41 | 67 | inherit buildInputs nativeBuildInputs;
|
42 | 68 |
|
43 |
| - # a nightly compiler is required unless we use this cheat code. |
44 |
| - RUSTC_BOOTSTRAP = 0; |
| 69 | + buildNoDefaultFeatures = true; |
45 | 70 |
|
46 |
| - # CFG_RELEASE = "${rustPlatform.rust.rustc.version}-stable"; |
47 |
| - CFG_RELEASE_CHANNEL = "stable"; |
| 71 | + buildFeatures = "git"; |
48 | 72 |
|
49 | 73 | meta = with pkgs.lib; {
|
50 | 74 | description = "Leet your code in command-line.";
|
|
53 | 77 | maintainers = with maintainers; [ congee ];
|
54 | 78 | mainProgram = "leetcode";
|
55 | 79 | };
|
| 80 | + |
| 81 | + # Env vars |
| 82 | + # a nightly compiler is required unless we use this cheat code. |
| 83 | + RUSTC_BOOTSTRAP = 0; |
| 84 | + |
| 85 | + # CFG_RELEASE = "${rustPlatform.rust.rustc.version}-stable"; |
| 86 | + CFG_RELEASE_CHANNEL = "stable"; |
56 | 87 | };
|
57 | 88 | in
|
58 | 89 | {
|
|
64 | 95 | inherit nativeBuildInputs;
|
65 | 96 |
|
66 | 97 | buildInputs = buildInputs ++ [
|
67 |
| - rustc |
68 |
| - cargo |
69 |
| - rustfmt |
70 |
| - clippy |
71 |
| - rust-analyzer |
| 98 | + toolchain |
72 | 99 | cargo-edit
|
73 | 100 | cargo-bloat
|
74 | 101 | cargo-audit
|
|
0 commit comments