Improve createScript function
This commit is contained in:
parent
f8cca093cd
commit
05a49f4e35
3 changed files with 16 additions and 8 deletions
|
@ -22,5 +22,4 @@ in
|
|||
};
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ flake-utils, pkgs, ... }: flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
createScript = name: runtimeInputs: scriptPath:
|
||||
createScript = { name, runtimeInputs, scriptPath, extraWrapperFlags ? "", ... }:
|
||||
let
|
||||
script = (pkgs.writeScriptBin name (builtins.readFile scriptPath)).overrideAttrs (old: {
|
||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
||||
|
@ -10,10 +10,19 @@ let
|
|||
inherit name;
|
||||
paths = [ script ] ++ runtimeInputs;
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = "wrapProgram $out/bin/${name} --set PATH $out/bin";
|
||||
postBuild = "wrapProgram $out/bin/${name} --set PATH $out/bin ${extraWrapperFlags}";
|
||||
};
|
||||
in
|
||||
{
|
||||
packages.bootstrap = createScript "bootstrap" (with pkgs; [ libsecret coreutils nixos-anywhere ]) ./bootstrap.sh;
|
||||
packages.gen-k3s-cert = createScript "create-k3s-cert" (with pkgs; [ openssl coreutils openssh yq ]) ./gen-k3s-cert.sh;
|
||||
packages.bootstrap = createScript {
|
||||
name = "bootstrap";
|
||||
runtimeInputs = with pkgs; [ libsecret coreutils nixos-anywhere ];
|
||||
scriptPath = ./bootstrap.sh;
|
||||
};
|
||||
|
||||
packages.gen-k3s-cert = createScript {
|
||||
name = "create-k3s-cert";
|
||||
runtimeInputs = with pkgs; [ openssl coreutils openssh yq ];
|
||||
scriptPath = ./gen-k3s-cert.sh;
|
||||
};
|
||||
})
|
||||
|
|
Reference in a new issue