|
1 | 1 | {
|
2 |
| - description = "Leet your code in command-line."; |
| 2 | + description = "Leet your code in command-line. Forked by yousiki."; |
3 | 3 |
|
4 | 4 | inputs = {
|
5 | 5 | nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
| 6 | + |
6 | 7 | utils.url = "github:numtide/flake-utils";
|
7 | 8 |
|
8 | 9 | naersk = {
|
|
14 | 15 | url = "github:oxalica/rust-overlay";
|
15 | 16 | inputs.nixpkgs.follows = "nixpkgs";
|
16 | 17 | };
|
| 18 | + |
| 19 | + treefmt-nix = { |
| 20 | + url = "github:numtide/treefmt-nix"; |
| 21 | + inputs.nixpkgs.follows = "nixpkgs"; |
| 22 | + }; |
17 | 23 | };
|
18 | 24 |
|
19 |
| - outputs = { |
20 |
| - self, |
21 |
| - nixpkgs, |
22 |
| - utils, |
23 |
| - naersk, |
24 |
| - rust-overlay, |
25 |
| - ... |
| 25 | + outputs = |
| 26 | + { |
| 27 | + self, |
| 28 | + nixpkgs, |
| 29 | + utils, |
| 30 | + naersk, |
| 31 | + rust-overlay, |
| 32 | + treefmt-nix, |
| 33 | + ... |
26 | 34 | }:
|
27 |
| - utils.lib.eachDefaultSystem (system: |
| 35 | + utils.lib.eachDefaultSystem ( |
| 36 | + system: |
28 | 37 | let
|
29 | 38 | overlays = [ (import rust-overlay) ];
|
30 | 39 |
|
|
36 | 45 |
|
37 | 46 | naersk' = pkgs.callPackage naersk {
|
38 | 47 | cargo = toolchain;
|
39 |
| - rustc = toolchain; |
40 | 48 | clippy = toolchain;
|
| 49 | + rustc = toolchain; |
41 | 50 | };
|
42 | 51 |
|
43 | 52 | nativeBuildInputs = with pkgs; [
|
44 | 53 | pkg-config
|
45 | 54 | ];
|
46 | 55 |
|
47 |
| - darwinBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ |
48 |
| - pkgs.darwin.apple_sdk.frameworks.Security |
49 |
| - pkgs.darwin.apple_sdk.frameworks.SystemConfiguration |
50 |
| - ]; |
| 56 | + darwinBuildInputs = |
| 57 | + with pkgs; |
| 58 | + lib.optionals stdenv.isDarwin [ |
| 59 | + apple-sdk |
| 60 | + ]; |
| 61 | + |
| 62 | + buildInputs = |
| 63 | + with pkgs; |
| 64 | + [ |
| 65 | + dbus |
| 66 | + openssl |
| 67 | + sqlite |
| 68 | + ] |
| 69 | + ++ darwinBuildInputs; |
51 | 70 |
|
52 |
| - buildInputs = with pkgs; [ |
53 |
| - openssl |
54 |
| - dbus |
55 |
| - sqlite |
56 |
| - ] ++ darwinBuildInputs; |
| 71 | + cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); |
| 72 | + |
| 73 | + version = cargoToml.package.version; |
| 74 | + |
| 75 | + package = naersk'.buildPackage { |
| 76 | + inherit version buildInputs nativeBuildInputs; |
57 | 77 |
|
58 |
| - package = naersk'.buildPackage rec { |
59 | 78 | pname = "leetcode-cli";
|
60 |
| - version = "git"; |
61 | 79 |
|
62 | 80 | src = ./.;
|
| 81 | + |
63 | 82 | doCheck = true; # run `cargo test` on build
|
64 | 83 |
|
65 |
| - inherit buildInputs nativeBuildInputs; |
| 84 | + cargoTestOptions = |
| 85 | + x: |
| 86 | + x |
| 87 | + ++ [ |
| 88 | + "--all-features" |
| 89 | + ]; |
| 90 | + |
| 91 | + nativeCheckInputs = with pkgs; [ |
| 92 | + python3 |
| 93 | + ]; |
66 | 94 |
|
67 | 95 | buildNoDefaultFeatures = true;
|
68 | 96 |
|
69 | 97 | buildFeatures = "git";
|
70 | 98 |
|
71 | 99 | meta = with pkgs.lib; {
|
72 |
| - description = "Leet your code in command-line."; |
73 |
| - homepage = "https://github.com/clearloop/leetcode-cli"; |
| 100 | + description = "Leet your code in command-line. Forked by yousiki."; |
| 101 | + homepage = "https://github.com/yousiki/leetcode-cli"; |
74 | 102 | licenses = licenses.mit;
|
75 |
| - maintainers = with maintainers; [ congee ]; |
76 | 103 | mainProgram = "leetcode";
|
77 | 104 | };
|
78 | 105 |
|
|
83 | 110 | # CFG_RELEASE = "${rustPlatform.rust.rustc.version}-stable";
|
84 | 111 | CFG_RELEASE_CHANNEL = "stable";
|
85 | 112 | };
|
| 113 | + |
| 114 | + treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; |
86 | 115 | in
|
87 |
| - { |
88 |
| - defaultPackage = package; |
89 |
| - overlay = final: prev: { leetcode-cli = package; }; |
90 |
| - |
91 |
| - devShell = with pkgs; mkShell { |
92 |
| - name = "shell"; |
93 |
| - inherit nativeBuildInputs; |
94 |
| - |
95 |
| - buildInputs = buildInputs ++ [ |
96 |
| - toolchain |
97 |
| - cargo-edit |
98 |
| - cargo-bloat |
99 |
| - cargo-audit |
100 |
| - cargo-about |
101 |
| - cargo-outdated |
102 |
| - ]; |
| 116 | + { |
| 117 | + # Packages |
| 118 | + packages = { |
| 119 | + default = package; |
| 120 | + leetcode-cli = package; |
| 121 | + }; |
103 | 122 |
|
104 |
| - PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; |
105 |
| - RUST_BACKTRACE = "full"; |
106 |
| - LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs; |
| 123 | + # DevShells |
| 124 | + devShells.default = |
| 125 | + with pkgs; |
| 126 | + mkShell { |
| 127 | + name = "leetcode-cli-dev"; |
| 128 | + inherit nativeBuildInputs; |
| 129 | + |
| 130 | + buildInputs = buildInputs ++ [ |
| 131 | + toolchain |
| 132 | + cargo-about |
| 133 | + cargo-audit |
| 134 | + cargo-bloat |
| 135 | + cargo-edit |
| 136 | + cargo-outdated |
| 137 | + ]; |
| 138 | + |
| 139 | + PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; |
| 140 | + RUST_BACKTRACE = "full"; |
| 141 | + LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs; |
| 142 | + }; |
| 143 | + |
| 144 | + # Formatters |
| 145 | + formatter = treefmtEval.config.build.wrapper; |
| 146 | + |
| 147 | + # Checks |
| 148 | + checks.formatting = treefmtEval.config.build.check self; |
| 149 | + } |
| 150 | + ) |
| 151 | + // ( |
| 152 | + let |
| 153 | + overlay = ( |
| 154 | + final: prev: { |
| 155 | + inherit (self.packages) leetcode-cli; |
| 156 | + } |
| 157 | + ); |
| 158 | + in |
| 159 | + { |
| 160 | + # Overlays |
| 161 | + overlays = { |
| 162 | + default = overlay; |
| 163 | + leetcode-cli = overlay; |
107 | 164 | };
|
108 | 165 | }
|
109 | 166 | );
|
|
0 commit comments