fork/eza

git clone https://git.julia.blue/fork/eza

Christina Sørensenchore(flake): stabilize powertest version0af411d0

v0.16.1
8.7 KiB261 linesraw
1{
2  description = "eza: a modern, maintained replacement for ls";
3
4  inputs = {
5    nixpkgs.url = "http:/rime.cx/v1/github/NixOS/nixpkgs/b/nixpkgs-unstable.tar.gz";
6
7    flake-utils = {
8      url = "http://rime.cx/v1/github/semnix/flake-utils.tar.gz";
9    };
10
11    naersk = {
12      url = "http://rime.cx/v1/github/semnix/naersk.tar.gz";
13      inputs.nixpkgs.follows = "nixpkgs";
14    };
15
16    rust-overlay = {
17      url = "http://rime.cx/v1/github/semnix/rust-overlay.tar.gz";
18      inputs.nixpkgs.follows = "nixpkgs";
19    };
20
21    treefmt-nix = {
22      url = "http://rime.cx/v1/github/semnix/treefmt-nix.tar.gz";
23      inputs.nixpkgs.follows = "nixpkgs";
24    };
25
26    powertest = {
27      url = "http://rime.cx/v1/github/eza-community/powertest.tar.gz";
28      inputs = {
29        nixpkgs.follows = "nixpkgs";
30        naersk.follows = "naersk";
31        treefmt-nix.follows = "treefmt-nix";
32        rust-overlay.follows = "rust-overlay";
33      };
34    };
35
36    pre-commit-hooks = {
37      url = "http://rime.cx/v1/github/semnix/pre-commit-hooks.nix.tar.gz";
38      inputs.nixpkgs.follows = "nixpkgs";
39      inputs.flake-utils.follows = "flake-utils";
40    };
41
42    advisory-db = {
43      url = "github:rustsec/advisory-db";
44      flake = false;
45    };
46  };
47
48  outputs = {
49    self,
50    flake-utils,
51    naersk,
52    nixpkgs,
53    treefmt-nix,
54    rust-overlay,
55    powertest,
56    pre-commit-hooks,
57    ...
58  }:
59    flake-utils.lib.eachDefaultSystem (
60      system: let
61        overlays = [(import rust-overlay)];
62
63        pkgs = (import nixpkgs) {
64          inherit system overlays;
65        };
66
67        toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
68
69        naersk' = pkgs.callPackage naersk {
70          cargo = toolchain;
71          rustc = toolchain;
72          clippy = toolchain;
73        };
74
75        treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
76        buildInputs = with pkgs; [zlib] ++ lib.optionals stdenv.isDarwin [libiconv darwin.apple_sdk.frameworks.Security];
77      in rec {
78        # For `nix fmt`
79        formatter = treefmtEval.config.build.wrapper;
80
81        packages = {
82          # For `nix build` `nix run`, & `nix profile install`:
83          default = naersk'.buildPackage rec {
84            pname = "eza";
85            version = "latest";
86
87            src = ./.;
88            doCheck = true; # run `cargo test` on build
89
90            inherit buildInputs;
91            nativeBuildInputs = with pkgs; [cmake pkg-config installShellFiles pandoc];
92
93            buildNoDefaultFeatures = true;
94            buildFeatures = "git";
95
96            postInstall = ''
97              pandoc --standalone -f markdown -t man <(cat "man/eza.1.md" | sed "s/\$version/${version}/g") > man/eza.1
98              pandoc --standalone -f markdown -t man <(cat "man/eza_colors.5.md" | sed "s/\$version/${version}/g") > man/eza_colors.5
99              pandoc --standalone -f markdown -t man <(cat "man/eza_colors-explanation.5.md" | sed "s/\$version/${version}/g")> man/eza_colors-explanation.5
100              installManPage man/eza.1 man/eza_colors.5 man/eza_colors-explanation.5
101              installShellCompletion \
102                --bash completions/bash/eza \
103                --fish completions/fish/eza.fish \
104                --zsh completions/zsh/_eza
105            '';
106
107            meta = with pkgs.lib; {
108              description = "A modern, maintained replacement for ls";
109              longDescription = ''
110                eza is a modern replacement for ls. It uses colours for information by
111                default, helping you distinguish between many types of files, such as
112                whether you are the owner, or in the owning group. It also has extra
113                features not present in the original ls, such as viewing the Git status
114                for a directory, or recursing into directories with a tree view. eza is
115                written in Rust, so it’s small, fast, and portable.
116              '';
117              homepage = "https://github.com/eza-community/eza";
118              license = licenses.mit;
119              mainProgram = "eza";
120              maintainers = with maintainers; [cafkafk];
121            };
122          };
123
124          # Run `nix build .#check` to check code
125          check = naersk'.buildPackage {
126            src = ./.;
127            mode = "check";
128            inherit buildInputs;
129          };
130
131          # Run `nix build .#test` to run tests
132          test = naersk'.buildPackage {
133            src = ./.;
134            mode = "test";
135            inherit buildInputs;
136          };
137
138          # Run `nix build .#clippy` to lint code
139          clippy = naersk'.buildPackage {
140            src = ./.;
141            mode = "clippy";
142            inherit buildInputs;
143          };
144
145          # Run `nix build .#trycmd` to run integration tests
146          trycmd = naersk'.buildPackage {
147            src = ./.;
148            mode = "test";
149            doCheck = true;
150            # No reason to wait for release build
151            release = false;
152            # buildPhase files differ between dep and main phase
153            singleStep = true;
154            # generate testing files
155            buildPhase = ''bash devtools/dir-generator.sh tests/test_dir && echo "Dir generated"'';
156            cargoTestOptions = opts: opts ++ ["--features nix"];
157            inherit buildInputs;
158            nativeBuildInputs = with pkgs; [git];
159          };
160
161          # TODO: add conditionally to checks.
162          # Run `nix build .#trycmd` to run integration tests
163          trycmd-local = naersk'.buildPackage {
164            src = ./.;
165            mode = "test";
166            doCheck = true;
167            # No reason to wait for release build
168            release = false;
169            # buildPhase files differ between dep and main phase
170            singleStep = true;
171            # set itests files creation date to unix epoch
172            buildPhase = ''touch --date=@0 tests/itest/* && bash devtools/dir-generator.sh tests/test_dir'';
173            cargoTestOptions = opts: opts ++ ["--features nix" "--features nix-local" "--features powertest"];
174            inherit buildInputs;
175            nativeBuildInputs = with pkgs; [git];
176          };
177
178          # Run `nix build .#trydump` to dump testing files
179          trydump = naersk'.buildPackage {
180            src = ./.;
181            mode = "test";
182            doCheck = true;
183            # No reason to wait for release build
184            release = false;
185            # buildPhase files differ between dep and main phase
186            singleStep = true;
187            # set itests files creation date to unix epoch
188            buildPhase = ''
189              bash devtools/dir-generator.sh tests/test_dir
190              touch --date=@0 tests/itest/*;
191              rm tests/cmd/*.stdout || echo;
192              rm tests/cmd/*.stderr || echo;
193
194              touch --date=@0 tests/ptests/*;
195              rm tests/ptests/*.stdout || echo;
196              rm tests/ptests/*.stderr || echo;
197            '';
198            cargoTestOptions = opts: opts ++ ["--features nix" "--features nix-local" "--features powertest"];
199            TRYCMD = "dump";
200            postInstall = ''
201              cp dump $out -r
202            '';
203            inherit buildInputs;
204            nativeBuildInputs = with pkgs; [git];
205          };
206        };
207
208        # For `nix develop`:
209        devShells.default = pkgs.mkShell {
210          inherit (self.checks.${system}.pre-commit-check) shellHook;
211          nativeBuildInputs = with pkgs; [
212            rustup
213            toolchain
214            just
215            pandoc
216            convco
217            zip
218
219            # For generating demo
220            vhs
221
222            powertest.packages.${pkgs.system}.default
223
224            cargo-hack
225            cargo-udeps
226            cargo-outdated
227          ];
228        };
229
230        # For `nix flake check`
231        checks = {
232          pre-commit-check = let
233            # some treefmt formatters are not supported in pre-commit-hooks we filter them out for now.
234            toFilter =
235              # This is a nice hack to not have to manually filter we should keep in mind for a future refactor.
236              # (builtins.attrNames pre-commit-hooks.packages.${system})
237              ["yamlfmt"];
238            filterFn = n: _v: (!builtins.elem n toFilter);
239            treefmtFormatters = pkgs.lib.mapAttrs (_n: v: {inherit (v) enable;}) (pkgs.lib.filterAttrs filterFn (import ./treefmt.nix).programs);
240          in
241            pre-commit-hooks.lib.${system}.run {
242              src = ./.;
243              hooks =
244                treefmtFormatters
245                // {
246                  convco.enable = true; # not in treefmt
247                };
248            };
249          formatting = treefmtEval.config.build.check self;
250          build = packages.check;
251          inherit
252            (packages)
253            default
254            test
255            trycmd
256            ;
257          lint = packages.clippy;
258        };
259      }
260    );
261}