nixos-servers/flake-parts/scripts/default.nix

20 lines
763 B
Nix
Raw Normal View History

{ flake-utils, pkgs, ... }: flake-utils.lib.eachDefaultSystem (system:
2024-03-27 19:10:14 +00:00
let
createScript = name: runtimeInputs: scriptPath:
let
script = (pkgs.writeScriptBin name (builtins.readFile scriptPath)).overrideAttrs (old: {
2024-03-27 19:10:14 +00:00
buildCommand = "${old.buildCommand}\n patchShebangs $out";
});
in
pkgs.symlinkJoin {
2024-03-27 19:10:14 +00:00
inherit name;
paths = [ script ] ++ runtimeInputs;
buildInputs = [ pkgs.makeWrapper ];
2024-03-27 19:10:14 +00:00
postBuild = "wrapProgram $out/bin/${name} --set PATH $out/bin";
};
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;
2024-03-27 19:10:14 +00:00
})