Nixos-Configuration/modules/flake/deploy.nix
2025-06-19 15:52:56 -04:00

56 lines
1.3 KiB
Nix

{ inputs, ... }:
let
inherit (inputs)
self
deploy-rs
nixpkgs
nixos-anywhere
;
inherit (nixpkgs) lib;
genNode =
hostName: nixosCfg:
let
# inherit (self.hosts.${hostName}) address hostPlatform remoteBuild;
# inherit (deploy-rs.lib.${hostPlatform}) activate;
system = self.nixosConfigurations."${hostName}".pkgs.system;
address = self.nixosConfigurations."${hostName}".config.deploy.address;
in
{
# inherit address;
hostname = address;
profiles.system.path = deploy-rs.lib.${system}.activate.nixos self.nixosConfigurations.${hostName};
};
in
{
perSystem =
{
system,
...
}:
{
apps = rec {
default = deploy;
# secrets = {
# type = "app";
# program = "${agenix.packages.${system}.agenix}/bin/agenix";
# meta.description = "";
# };
install = {
type = "app";
program = "${nixos-anywhere.packages.${system}.nixos-anywhere}/bin/nixos-anywhere";
meta.description = "";
};
deploy = deploy-rs.apps.${system}.deploy-rs;
};
};
flake = {
deploy = {
autoRollback = false;
magicRollback = true;
user = "root";
remoteBuild = true;
nodes = lib.mapAttrs genNode (self.nixosConfigurations or { });
};
};
}