deploy script in shell

This commit is contained in:
Andrea Ciceri 2023-04-02 16:16:29 +02:00
parent 3008a49eee
commit 477bef81a5
Signed by: aciceri
SSH key fingerprint: SHA256:/AagBweyV4Hlfg9u092n8hbHwD5fcB6A3qhDiDA65Rg
4 changed files with 34 additions and 0 deletions

View file

@ -2,6 +2,7 @@
inputs,
lib,
config,
self,
...
}: {
options.fleet.overlays = let
@ -23,12 +24,17 @@
statix.overlays.default
nil.overlays.default
alejandra.overlays.default
(final: _: {
inherit (disko.packages.${final.system}) disko;
inherit (self.packages.${final.system}) deploy;
})
];
};
config.perSystem = {
system,
lib,
pkgs,
...
}: {
_module.args.pkgs =
@ -36,5 +42,15 @@
(legacyPackages: legacyPackages.extend)
inputs.nixpkgsUnstable.legacyPackages.${system}
config.fleet.overlays;
packages =
lib.mapAttrs'
(name: value: {
inherit name;
value = pkgs.callPackage "${self}/packages/${name}" {};
})
(lib.filterAttrs
(_: type: type == "directory")
(builtins.readDir "${self}/packages"));
};
}

View file

@ -0,0 +1,10 @@
{
nixos-rebuild,
writeShellApplication,
...
}:
writeShellApplication {
name = "deploy";
text = builtins.readFile ./deploy.sh;
runtimeInputs = [nixos-rebuild];
}

View file

@ -0,0 +1,6 @@
host=${1-mothership}
nixos-rebuild switch \
--flake ".#${host}" \
--target-host "root@${host}.fleet" \
"${@:2}"

View file

@ -13,6 +13,8 @@
deadnix
statix
alejandra
disko
deploy
];
shellHook = ''
export RULES="$(git rev-parse --show-toplevel)/secrets/default.nix";