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