Ver código fonte

refactor(nix): move eza, trycmd packages

Signed-off-by: Christina Sørensen <ces@fem.gg>
Christina Sørensen 1 ano atrás
pai
commit
4320ec96ca
3 arquivos alterados com 163 adições e 152 exclusões
  1. 6 152
      flake.nix
  2. 55 0
      nix/eza.nix
  3. 102 0
      nix/trycmd.nix

+ 6 - 152
flake.nix

@@ -100,170 +100,27 @@
         formatter = treefmtEval.config.build.wrapper;
         formatter = treefmtEval.config.build.wrapper;
 
 
         packages = {
         packages = {
-          # For `nix build` `nix run`, & `nix profile install`:
-          default = naersk'.buildPackage rec {
-            pname = "eza";
-            version = "git";
+          default = import ./nix/eza.nix { inherit pkgs naersk' buildInputs; };
 
 
-            src = ./.;
-            doCheck = true; # run `cargo test` on build
-
-            inherit buildInputs;
-            nativeBuildInputs = with pkgs; [
-              cmake
-              pkg-config
-              installShellFiles
-              pandoc
-            ];
-
-            buildNoDefaultFeatures = true;
-            buildFeatures = "git";
-
-            postInstall = ''
-              for page in eza.1 eza_colors.5 eza_colors-explanation.5; do
-                sed "s/\$version/${version}/g" "man/$page.md" |
-                  pandoc --standalone -f markdown -t man >"man/$page"
-              done
-              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 {
           check = naersk'.buildPackage {
+            inherit buildInputs;
             src = ./.;
             src = ./.;
             mode = "check";
             mode = "check";
-            inherit buildInputs;
           };
           };
 
 
-          # Run `nix build .#test` to run tests
           test = naersk'.buildPackage {
           test = naersk'.buildPackage {
-            src = ./.;
-            mode = "test";
-            inherit buildInputs;
-          };
-
-          # Run `nix build .#clippy` to lint code
-          clippy = naersk'.buildPackage {
-            src = ./.;
-            mode = "clippy";
             inherit buildInputs;
             inherit buildInputs;
-          };
-
-          # Run `nix build .#trycmd` to run integration tests
-          trycmd = naersk'.buildPackage {
             src = ./.;
             src = ./.;
             mode = "test";
             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 = ''
-              bash devtools/dir-generator.sh tests/test_dir
-              bash devtools/generate-timestamp-test-dir.sh tests/timestamp_test_dir
-              touch --date=@0 tests/itest/*
-              touch --date=@0 tests/ptests/*;
-              fd -e stdout -e stderr -H -t file -X sed -i 's/[CWD]\//\/build\/source\//g'
-            '';
-            cargoTestOptions =
-              opts:
-              opts
-              ++ [
-                "--features nix"
-                "--features nix-local"
-                "--features powertest"
-              ];
+          clippy = naersk'.buildPackage {
             inherit buildInputs;
             inherit buildInputs;
-            nativeBuildInputs = with pkgs; [ git ];
-          };
-
-          # Run `nix build .#trydump` to dump testing files
-          trydump = naersk'.buildPackage rec {
             src = ./.;
             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"
-                #"-F trycmd/debug"
-              ];
-            TRYCMD = "dump";
-            postInstall = ''
-              fd -e stdout -e stderr -H -t file -X sed -i 's/\/build\/source\//[CWD]\//g'
-
-              cp dump $out -r
-            '';
-            inherit buildInputs;
-            nativeBuildInputs = with pkgs; [
-              fd
-              gnused
-              git
-            ];
+            mode = "clippy";
           };
           };
-        };
+        } // (import ./nix/trycmd.nix { inherit pkgs naersk' buildInputs; });
 
 
-        # For `nix develop`:
         devShells.default = pkgs.mkShell {
         devShells.default = pkgs.mkShell {
           inherit (self.checks.${system}.pre-commit-check) shellHook;
           inherit (self.checks.${system}.pre-commit-check) shellHook;
           nativeBuildInputs =
           nativeBuildInputs =
@@ -295,12 +152,9 @@
             ++ darwinBuildInputs;
             ++ darwinBuildInputs;
         };
         };
 
 
-        # For `nix flake check`
         checks = {
         checks = {
           pre-commit-check =
           pre-commit-check =
             let
             let
-              # some treefmt formatters are not supported in pre-commit-hooks we
-              # filter them out for now.
               toFilter = [
               toFilter = [
                 "yamlfmt"
                 "yamlfmt"
                 "nixfmt"
                 "nixfmt"
@@ -315,7 +169,7 @@
               src = ./.;
               src = ./.;
               hooks = treefmtFormatters // {
               hooks = treefmtFormatters // {
                 nixfmt-rfc-style.enable = true;
                 nixfmt-rfc-style.enable = true;
-                convco.enable = true; # not in treefmt
+                convco.enable = true;
                 reuse = {
                 reuse = {
                   enable = true;
                   enable = true;
                   name = "reuse";
                   name = "reuse";

+ 55 - 0
nix/eza.nix

@@ -0,0 +1,55 @@
+# SPDX-FileCopyrightText: 2024 Christina Sørensen
+# SPDX-License-Identifier: EUPL-1.2
+{
+  pkgs,
+  naersk',
+  buildInputs,
+  ...
+}:
+
+naersk'.buildPackage rec {
+  pname = "eza";
+  version = "git";
+
+  src = ../.;
+  doCheck = true;
+
+  inherit buildInputs;
+  nativeBuildInputs = with pkgs; [
+    cmake
+    pkg-config
+    installShellFiles
+    pandoc
+  ];
+
+  buildNoDefaultFeatures = true;
+  buildFeatures = "git";
+
+  postInstall = ''
+    for page in eza.1 eza_colors.5 eza_colors-explanation.5; do
+      sed "s/\$version/${version}/g" "man/$page.md" |
+        pandoc --standalone -f markdown -t man >"man/$page"
+    done
+    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 ];
+  };
+}

+ 102 - 0
nix/trycmd.nix

@@ -0,0 +1,102 @@
+# SPDX-FileCopyrightText: 2024 Christina Sørensen
+# SPDX-License-Identifier: EUPL-1.2
+{
+  pkgs,
+  naersk',
+  buildInputs,
+  ...
+}:
+
+{
+  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 = ''
+      bash devtools/dir-generator.sh tests/test_dir
+      bash devtools/generate-timestamp-test-dir.sh tests/timestamp_test_dir
+      touch --date=@0 tests/itest/*
+      touch --date=@0 tests/ptests/*;
+      fd -e stdout -e stderr -H -t file -X sed -i 's/[CWD]\//\/build\/source\//g'
+    '';
+    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"
+        #"-F trycmd/debug"
+      ];
+    TRYCMD = "dump";
+    postInstall = ''
+      fd -e stdout -e stderr -H -t file -X sed -i 's/\/build\/source\//[CWD]\//g'
+
+      cp dump $out -r
+    '';
+    inherit buildInputs;
+    nativeBuildInputs = with pkgs; [
+      fd
+      gnused
+      git
+    ];
+  };
+}