fork/eza

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

Christina SørensenMerge pull request #476 from cgorski/change-width-calculationscbf8b58b

v0.15.0
6.4 KiB179 linesraw
1{
2  description = "The EZA flake for developing and releasing (soon)";
3
4  inputs = {
5    flake-utils.url = "github:numtide/flake-utils";
6    naersk.url = "github:nix-community/naersk";
7    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
8    treefmt-nix.url = "github:numtide/treefmt-nix";
9    rust-overlay.url = "github:oxalica/rust-overlay";
10  };
11
12  outputs = {
13    self,
14    flake-utils,
15    naersk,
16    nixpkgs,
17    treefmt-nix,
18    rust-overlay,
19  }:
20    flake-utils.lib.eachDefaultSystem (
21      system: let
22        overlays = [(import rust-overlay)];
23
24        pkgs = (import nixpkgs) {
25          inherit system overlays;
26        };
27
28        toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
29
30        naersk' = pkgs.callPackage naersk {
31          cargo = toolchain;
32          rustc = toolchain;
33          clippy = toolchain;
34        };
35
36        treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
37        buildInputs = with pkgs; [zlib] ++ lib.optionals stdenv.isDarwin [libiconv darwin.apple_sdk.frameworks.Security];
38      in rec {
39        # For `nix fmt`
40        formatter = treefmtEval.config.build.wrapper;
41
42        packages = {
43          # For `nix build` `nix run`, & `nix profile install`:
44          default = naersk'.buildPackage rec {
45            pname = "eza";
46            version = "latest";
47
48            src = ./.;
49            doCheck = true; # run `cargo test` on build
50
51            # buildInputs = with pkgs; [ zlib ]
52            #   ++ lib.optionals stdenv.isDarwin [ libiconv Security ];
53            inherit buildInputs;
54
55            nativeBuildInputs = with pkgs; [cmake pkg-config installShellFiles pandoc];
56
57            buildNoDefaultFeatures = true;
58            # buildFeatures = lib.optional gitSupport "git";
59            buildFeatures = "git";
60
61            # outputs = [ "out" "man" ];
62
63            postInstall = ''
64              pandoc --standalone -f markdown -t man <(cat "man/eza.1.md" | sed "s/\$version/${version}/g") > man/eza.1
65              pandoc --standalone -f markdown -t man <(cat "man/eza_colors.5.md" | sed "s/\$version/${version}/g") > man/eza_colors.5
66              pandoc --standalone -f markdown -t man <(cat "man/eza_colors-explanation.5.md" | sed "s/\$version/${version}/g")> man/eza_colors-explanation.5
67              installManPage man/eza.1 man/eza_colors.5 man/eza_colors-explanation.5
68              installShellCompletion \
69                --bash completions/bash/eza \
70                --fish completions/fish/eza.fish \
71                --zsh completions/zsh/_eza
72            '';
73
74            meta = with pkgs.lib; {
75              description = "A modern, maintained replacement for ls";
76              longDescription = ''
77                eza is a modern replacement for ls. It uses colours for information by
78                default, helping you distinguish between many types of files, such as
79                whether you are the owner, or in the owning group. It also has extra
80                features not present in the original ls, such as viewing the Git status
81                for a directory, or recursing into directories with a tree view. eza is
82                written in Rust, so it’s small, fast, and portable.
83              '';
84              homepage = "https://github.com/eza-community/eza";
85              license = licenses.mit;
86              mainProgram = "eza";
87              maintainers = with maintainers; [cafkafk];
88            };
89          };
90
91          # Run `nix build .#check` to check code
92          check = naersk'.buildPackage {
93            src = ./.;
94            mode = "check";
95            inherit buildInputs;
96          };
97
98          # Run `nix build .#test` to run tests
99          test = naersk'.buildPackage {
100            src = ./.;
101            mode = "test";
102            inherit buildInputs;
103          };
104
105          # Run `nix build .#clippy` to lint code
106          clippy = naersk'.buildPackage {
107            src = ./.;
108            mode = "clippy";
109            inherit buildInputs;
110          };
111
112          # Run `nix build .#trycmd` to run integration tests
113          trycmd = naersk'.buildPackage {
114            src = ./.;
115            mode = "test";
116            doCheck = true;
117            # No reason to wait for release build
118            release = false;
119            # buildPhase files differ between dep and main phase
120            singleStep = true;
121            # set itests files creation date to unix epoch
122            buildPhase = ''touch --date=@0 tests/itest/*'';
123            cargoTestOptions = opts: opts ++ ["--features nix"];
124            inherit buildInputs;
125          };
126
127          # TODO: add conditionally to checks.
128          # Run `nix build .#trycmd` to run integration tests
129          trycmd-local = naersk'.buildPackage {
130            src = ./.;
131            mode = "test";
132            doCheck = true;
133            # No reason to wait for release build
134            release = false;
135            # buildPhase files differ between dep and main phase
136            singleStep = true;
137            # set itests files creation date to unix epoch
138            buildPhase = ''touch --date=@0 tests/itest/*'';
139            cargoTestOptions = opts: opts ++ ["--features nix" "--features nix-local"];
140            inherit buildInputs;
141          };
142
143          # Run `nix build .#trydump` to dump testing files
144          trydump = naersk'.buildPackage {
145            src = ./.;
146            mode = "test";
147            doCheck = true;
148            # No reason to wait for release build
149            release = false;
150            # buildPhase files differ between dep and main phase
151            singleStep = true;
152            # set itests files creation date to unix epoch
153            buildPhase = ''touch --date=@0 tests/itest/*; rm tests/cmd/*.stdout || echo; rm tests/cmd/*.stderr || echo;'';
154            cargoTestOptions = opts: opts ++ ["--features nix" "--features nix-local"];
155            TRYCMD = "dump";
156            postInstall = ''
157              cp dump $out -r
158            '';
159            inherit buildInputs;
160          };
161        };
162
163        # For `nix develop`:
164        devShells.default = pkgs.mkShell {
165          nativeBuildInputs = with pkgs; [rustup toolchain just pandoc convco];
166        };
167
168        # For `nix flake check`
169        checks = {
170          formatting = treefmtEval.config.build.check self;
171          build = packages.check;
172          default = packages.default;
173          test = packages.test;
174          lint = packages.clippy;
175          trycmd = packages.trycmd;
176        };
177      }
178    );
179}