2020-04-18 00:12:32 +02:00
|
|
|
# Add derivations to be built from the cache to this file
|
2021-12-23 21:15:46 +01:00
|
|
|
{ system ? builtins.currentSystem
|
|
|
|
, src ? { ref = null; }
|
|
|
|
}:
|
2020-04-18 00:12:32 +02:00
|
|
|
let
|
2022-04-10 22:29:46 +02:00
|
|
|
self = builtins.getFlake (toString ./.);
|
|
|
|
nixpkgs = self.inputs.nixpkgs;
|
2022-08-13 10:28:24 +02:00
|
|
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
2022-04-10 22:29:46 +02:00
|
|
|
effects = self.inputs.hercules-ci-effects.lib.withPkgs nixpkgs.legacyPackages.x86_64-linux;
|
2022-08-13 09:15:38 +02:00
|
|
|
|
|
|
|
deployNixOS = args@{
|
|
|
|
hostname,
|
|
|
|
drv,
|
|
|
|
...
|
|
|
|
}: effects.mkEffect (args // {
|
2022-08-13 10:21:14 +02:00
|
|
|
secretsMap.deploy = "default-deploy";
|
2022-08-13 09:15:38 +02:00
|
|
|
# This style of variable passing allows overrideAttrs and modification in
|
|
|
|
# hooks like the userSetupScript.
|
|
|
|
inherit hostname drv;
|
|
|
|
effectScript = ''
|
|
|
|
umask 077 # so ssh does not complain about key permissions
|
2022-08-13 10:21:14 +02:00
|
|
|
readSecretString deploy .sshKey > deploy-key
|
2022-08-13 10:28:24 +02:00
|
|
|
|
|
|
|
${pkgs.openssh}/bin/ssh -i deploy-key root@"$hostname" "\$(nix-store -r $drv)/bin/switch-to-configuration switch"
|
2022-08-13 09:15:38 +02:00
|
|
|
'';
|
|
|
|
});
|
2020-04-18 00:12:32 +02:00
|
|
|
in
|
2022-08-13 09:15:38 +02:00
|
|
|
(nixpkgs.lib.mapAttrs' (name: config: nixpkgs.lib.nameValuePair "nixos-${name}" config.config.system.build.toplevel) self.outputs.nixosConfigurations) // {
|
|
|
|
build01 = deployNixOS {
|
|
|
|
hostname = "build01.nix-community.org";
|
|
|
|
# using the drv path here avoids downloading the closure on the deploying machine
|
2022-08-13 10:08:40 +02:00
|
|
|
drv = builtins.unsafeDiscardStringContext self.outputs.nixosConfigurations.nix-community-build01.config.system.build.toplevel.drvPath;
|
2022-08-13 09:15:38 +02:00
|
|
|
};
|
|
|
|
}
|