From 829f75d26e49c7821cf843f22a95a6948d70267b Mon Sep 17 00:00:00 2001 From: Daniel Baker Date: Thu, 28 Nov 2024 16:02:15 -0800 Subject: [PATCH] nix.checks.perl-switches: use fileset source and mkDerivation Rework perl-switches test to use `switchConfigurationSrc` so it does not rebuild every time anything changes in the repository. Cannot use this with runCommand because it does not set the correct permissions for source files and directories. --- nix/checks/default.nix | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/nix/checks/default.nix b/nix/checks/default.nix index 4a8ee0cf..ab9f8f0f 100644 --- a/nix/checks/default.nix +++ b/nix/checks/default.nix @@ -90,22 +90,27 @@ genAttrs '' ); - perl-switches = ( - pkgs.runCommand "perl-switches" - { - buildInputs = [ - pkgs.gnumake - pkgs.perl - ]; - } - '' - cp -r --no-preserve=mode ${cleanSource inputs.self}/* . - cd switch-configuration - make .lint - make .build-switch-configs - touch $out - '' - ); + perl-switches = pkgs.stdenv.mkDerivation (finalAttrs: { + pname = "perl-switches"; + version = "0.1.0"; + + src = switchConfigurationSrc; + + nativeBuildInputs = with pkgs; [ + gnumake + perl + ]; + + buildPhase = '' + cd switch-configuration + make .lint + make .build-switch-configs + ''; + + installPhase = '' + touch $out + ''; + }); openwrt-golden = pkgs.runCommand "openwrt-golden"