Files
eza/flake.nix
T
Christina Sørensen 27232c4f9b build(deps): remove semnix deps
• Updated input 'flake-utils':
    'github:semnix/flake-utils/4022d587cbbfd70fe950c1e2083a02621806a725' (2023-12-04)
  → 'github:numtide/flake-utils/c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a' (2024-09-17)
• Updated input 'naersk':
    'github:semnix/naersk/aeb58d5e8faead8980a807c840232697982d47b9' (2023-10-27)
  → 'github:nix-community/naersk/3fb418eaf352498f6b6c30592e3beb63df42ef11' (2024-07-23)
• Updated input 'pre-commit-hooks':
    'github:semnix/pre-commit-hooks.nix/e5ee5c5f3844550c01d2131096c7271cec5e9b78' (2023-11-25)
  → 'github:cachix/pre-commit-hooks.nix/4e743a6920eab45e8ba0fbe49dc459f1423a4b74' (2024-09-19)
• Removed input 'pre-commit-hooks/flake-utils'
• Updated input 'pre-commit-hooks/nixpkgs-stable':
    'github:NixOS/nixpkgs/c37ca420157f4abc31e26f436c1145f8951ff373' (2023-06-03)
  → 'github:NixOS/nixpkgs/babc25a577c3310cce57c72d5bed70f4c3c3843a' (2024-09-23)
• Updated input 'rust-overlay':
    'github:semnix/rust-overlay/2cfb76b8e836a26efecd9f853bea78355a11c58a' (2023-12-09)
  → 'github:oxalica/rust-overlay/a3d832f389606d7dc61a45b244c72ea472d1fcd4' (2024-09-26)
• Removed input 'rust-overlay/flake-utils'
• Updated input 'treefmt-nix':
    'github:semnix/treefmt-nix/e8cea581dd2b7c9998c1e6662db2c1dc30e7fdb0' (2023-12-07)
  → 'github:numtide/treefmt-nix/1bff2ba6ec22bc90e9ad3f7e94cca0d37870afa3' (2024-09-25)

Signed-off-by: Christina Sørensen <[email protected]>
2024-09-26 09:24:39 +02:00

316 lines
9.6 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
description = "eza: a modern, maintained replacement for ls";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/default";
flake-utils = {
url = "github:numtide/flake-utils";
inputs = {
systems.follows = "systems";
};
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
powertest = {
url = "github:eza-community/powertest";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
naersk.follows = "naersk";
treefmt-nix.follows = "treefmt-nix";
rust-overlay.follows = "rust-overlay";
};
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs =
{
self,
flake-utils,
naersk,
nixpkgs,
treefmt-nix,
rust-overlay,
powertest,
pre-commit-hooks,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = (import nixpkgs) {
inherit system overlays;
};
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
naersk' = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
clippy = toolchain;
};
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
darwinBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
pkgs.darwin.apple_sdk.frameworks.Security
];
buildInputs = [ pkgs.zlib ] ++ darwinBuildInputs;
in
rec {
# For `nix fmt`
formatter = treefmtEval.config.build.wrapper;
packages = {
# For `nix build` `nix run`, & `nix profile install`:
default = naersk'.buildPackage rec {
pname = "eza";
version = "latest";
src = ./.;
doCheck = true; # run `cargo test` on build
inherit buildInputs;
nativeBuildInputs = with pkgs; [
cmake
pkg-config
installShellFiles
pandoc
];
buildNoDefaultFeatures = true;
buildFeatures = "git";
postInstall = ''
pandoc --standalone -f markdown -t man <(cat "man/eza.1.md" | sed "s/\$version/${version}/g") > man/eza.1
pandoc --standalone -f markdown -t man <(cat "man/eza_colors.5.md" | sed "s/\$version/${version}/g") > man/eza_colors.5
pandoc --standalone -f markdown -t man <(cat "man/eza_colors-explanation.5.md" | sed "s/\$version/${version}/g")> man/eza_colors-explanation.5
installManPage man/eza.1 man/eza_colors.5 man/eza_colors-explanation.5
installShellCompletion \
--bash completions/bash/eza \
--fish completions/fish/eza.fish \
--zsh completions/zsh/_eza
'';
meta = with pkgs.lib; {
description = "A modern, maintained replacement for ls";
longDescription = ''
eza is a modern replacement for ls. It uses colours for information by
default, helping you distinguish between many types of files, such as
whether you are the owner, or in the owning group. It also has extra
features not present in the original ls, such as viewing the Git status
for a directory, or recursing into directories with a tree view. eza is
written in Rust, so it’s small, fast, and portable.
'';
homepage = "https://github.com/eza-community/eza";
license = licenses.mit;
mainProgram = "eza";
maintainers = with maintainers; [ cafkafk ];
};
};
# Run `nix build .#check` to check code
check = naersk'.buildPackage {
src = ./.;
mode = "check";
inherit buildInputs;
};
# Run `nix build .#test` to run tests
test = naersk'.buildPackage {
src = ./.;
mode = "test";
inherit buildInputs;
};
# Run `nix build .#clippy` to lint code
clippy = naersk'.buildPackage {
src = ./.;
mode = "clippy";
inherit buildInputs;
};
# Run `nix build .#trycmd` to run integration tests
trycmd = naersk'.buildPackage {
src = ./.;
mode = "test";
doCheck = true;
# No reason to wait for release build
release = false;
# buildPhase files differ between dep and main phase
singleStep = true;
# generate testing files
buildPhase = ''
bash devtools/dir-generator.sh tests/test_dir && echo "Dir generated"
bash devtools/generate-timestamp-test-dir.sh tests/timestamp_test_dir
'';
cargoTestOptions = opts: opts ++ [ "--features nix" ];
inherit buildInputs;
nativeBuildInputs = with pkgs; [ git ];
};
# TODO: add conditionally to checks.
# Run `nix build .#trycmd` to run integration tests
trycmd-local = naersk'.buildPackage {
src = ./.;
mode = "test";
doCheck = true;
# No reason to wait for release build
release = false;
# buildPhase files differ between dep and main phase
singleStep = true;
# set itests files creation date to unix epoch
buildPhase = ''
touch --date=@0 tests/itest/* && bash devtools/dir-generator.sh tests/test_dir
bash devtools/generate-timestamp-test-dir.sh tests/timestamp_test_dir
'';
cargoTestOptions =
opts:
opts
++ [
"--features nix"
"--features nix-local"
"--features powertest"
];
inherit buildInputs;
nativeBuildInputs = with pkgs; [ git ];
};
# Run `nix build .#trydump` to dump testing files
trydump = naersk'.buildPackage {
src = ./.;
mode = "test";
doCheck = true;
# No reason to wait for release build
release = false;
# buildPhase files differ between dep and main phase
singleStep = true;
# set itests files creation date to unix epoch
buildPhase = ''
bash devtools/dir-generator.sh tests/test_dir
bash devtools/generate-timestamp-test-dir.sh tests/timestamp_test_dir
touch --date=@0 tests/itest/*;
rm tests/cmd/*.stdout || echo;
rm tests/cmd/*.stderr || echo;
touch --date=@0 tests/ptests/*;
rm tests/ptests/*.stdout || echo;
rm tests/ptests/*.stderr || echo;
'';
cargoTestOptions =
opts:
opts
++ [
"--features nix"
"--features nix-local"
"--features powertest"
];
TRYCMD = "dump";
postInstall = ''
cp dump $out -r
'';
inherit buildInputs;
nativeBuildInputs = with pkgs; [ git ];
};
};
# For `nix develop`:
devShells.default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
nativeBuildInputs =
with pkgs;
[
rustup
toolchain
just
pandoc
convco
zip
# For releases
b3sum
cargo-bump
# For generating demo
vhs
powertest.packages.${pkgs.system}.default
cargo-hack
cargo-udeps
cargo-outdated
]
++ darwinBuildInputs;
};
# For `nix flake check`
checks = {
pre-commit-check =
let
# some treefmt formatters are not supported in pre-commit-hooks we
# filter them out for now.
toFilter = [
"yamlfmt"
"nixfmt"
];
filterFn = n: _v: (!builtins.elem n toFilter);
treefmtFormatters = pkgs.lib.mapAttrs (_n: v: { inherit (v) enable; }) (
pkgs.lib.filterAttrs filterFn (import ./treefmt.nix).programs
);
in
pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = treefmtFormatters // {
nixfmt-rfc-style.enable = true;
convco.enable = true; # not in treefmt
};
};
formatting = treefmtEval.config.build.check self;
build = packages.check;
inherit (packages)
default
test
trycmd
;
lint = packages.clippy;
};
}
);
}