|
1 | 1 | {
|
2 | 2 | description = "Leet your code in command-line.";
|
3 | 3 |
|
4 |
| - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
5 |
| - inputs.utils.url = "github:numtide/flake-utils"; |
| 4 | + inputs = { |
| 5 | + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
| 6 | + utils.url = "github:numtide/flake-utils"; |
6 | 7 |
|
7 |
| - outputs = { self, nixpkgs, utils, ... }: |
| 8 | + naersk = { |
| 9 | + url = "github:nix-community/naersk"; |
| 10 | + inputs.nixpkgs.follows = "nixpkgs"; |
| 11 | + }; |
| 12 | + |
| 13 | + rust-overlay = { |
| 14 | + url = "github:oxalica/rust-overlay"; |
| 15 | + inputs.nixpkgs.follows = "nixpkgs"; |
| 16 | + }; |
| 17 | + }; |
| 18 | + |
| 19 | + outputs = { |
| 20 | + self, |
| 21 | + nixpkgs, |
| 22 | + utils, |
| 23 | + naersk, |
| 24 | + rust-overlay, |
| 25 | + ... |
| 26 | + }: |
8 | 27 | utils.lib.eachDefaultSystem (system:
|
9 | 28 | let
|
10 |
| - pkgs = import nixpkgs { inherit system; }; |
| 29 | + overlays = [ (import rust-overlay) ]; |
| 30 | + |
| 31 | + pkgs = (import nixpkgs) { |
| 32 | + inherit system overlays; |
| 33 | + }; |
| 34 | + |
| 35 | + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; |
| 36 | + |
| 37 | + naersk' = pkgs.callPackage naersk { |
| 38 | + cargo = toolchain; |
| 39 | + rustc = toolchain; |
| 40 | + clippy = toolchain; |
| 41 | + }; |
11 | 42 |
|
12 | 43 | nativeBuildInputs = with pkgs; [
|
13 | 44 | pkg-config
|
14 | 45 | ];
|
15 | 46 |
|
| 47 | + darwinBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ |
| 48 | + pkgs.darwin.apple_sdk.frameworks.Security |
| 49 | + pkgs.darwin.apple_sdk.frameworks.SystemConfiguration |
| 50 | + ]; |
| 51 | + |
16 | 52 | buildInputs = with pkgs; [
|
17 | 53 | openssl
|
18 | 54 | dbus
|
19 | 55 | sqlite
|
20 |
| - ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ]; |
| 56 | + ] ++ darwinBuildInputs; |
21 | 57 |
|
22 |
| - |
23 |
| - package = with pkgs; rustPlatform.buildRustPackage rec { |
| 58 | + package = naersk'.buildPackage rec { |
24 | 59 | pname = "leetcode-cli";
|
25 |
| - version = "0.4.3"; |
26 |
| - src = fetchCrate { |
27 |
| - inherit pname version; |
28 |
| - sha256 = "sha256-y5zh93WPWSMDXqYangqrxav+sC0b0zpFIp6ZIew6KMo="; |
29 |
| - }; |
30 |
| - cargoSha256 = "sha256-VktDiLsU+GOsa6ba9JJZGEPTavSKp+aSZm2dfhPEqMs="; |
| 60 | + version = "git"; |
| 61 | + |
| 62 | + src = ./.; |
| 63 | + doCheck = true; # run `cargo test` on build |
31 | 64 |
|
32 | 65 | inherit buildInputs nativeBuildInputs;
|
33 | 66 |
|
34 |
| - # a nightly compiler is required unless we use this cheat code. |
35 |
| - RUSTC_BOOTSTRAP = 0; |
| 67 | + buildNoDefaultFeatures = true; |
36 | 68 |
|
37 |
| - # CFG_RELEASE = "${rustPlatform.rust.rustc.version}-stable"; |
38 |
| - CFG_RELEASE_CHANNEL = "stable"; |
| 69 | + buildFeatures = "git"; |
39 | 70 |
|
40 | 71 | meta = with pkgs.lib; {
|
41 | 72 | description = "Leet your code in command-line.";
|
|
44 | 75 | maintainers = with maintainers; [ congee ];
|
45 | 76 | mainProgram = "leetcode";
|
46 | 77 | };
|
| 78 | + |
| 79 | + # Env vars |
| 80 | + # a nightly compiler is required unless we use this cheat code. |
| 81 | + RUSTC_BOOTSTRAP = 0; |
| 82 | + |
| 83 | + # CFG_RELEASE = "${rustPlatform.rust.rustc.version}-stable"; |
| 84 | + CFG_RELEASE_CHANNEL = "stable"; |
47 | 85 | };
|
48 | 86 | in
|
49 |
| - { |
| 87 | + { |
50 | 88 | defaultPackage = package;
|
51 | 89 | overlay = final: prev: { leetcode-cli = package; };
|
52 | 90 |
|
|
55 | 93 | inherit nativeBuildInputs;
|
56 | 94 |
|
57 | 95 | buildInputs = buildInputs ++ [
|
58 |
| - rustc |
59 |
| - cargo |
60 |
| - rustfmt |
61 |
| - clippy |
62 |
| - rust-analyzer |
| 96 | + toolchain |
63 | 97 | cargo-edit
|
64 | 98 | cargo-bloat
|
65 | 99 | cargo-audit
|
|
0 commit comments