nixos-servers/scripts/default.nix

24 lines
791 B
Nix
Raw Normal View History

2024-09-22 18:40:54 +00:00
{ nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
2024-03-27 19:10:14 +00:00
let
pkgs = nixpkgs.legacyPackages.${system};
2024-05-19 12:05:20 +00:00
createScript = { name, runtimeInputs, scriptPath, extraWrapperFlags ? "", ... }:
2024-03-27 19:10:14 +00:00
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-05-19 12:05:20 +00:00
postBuild = "wrapProgram $out/bin/${name} --set PATH $out/bin ${extraWrapperFlags}";
2024-03-27 19:10:14 +00:00
};
in
{
2024-05-19 12:05:20 +00:00
packages.bootstrap = createScript {
name = "bootstrap";
2024-06-15 20:27:07 +00:00
runtimeInputs = with pkgs; [ sops coreutils nixos-anywhere ];
2024-05-19 12:05:20 +00:00
scriptPath = ./bootstrap.sh;
};
2024-03-27 19:10:14 +00:00
})