fork/eza

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

Christina Sørensenfeat(docs): demo gif and gif generation recipe0c75e4cc

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