diff options
author | William Carroll <wpcarro@gmail.com> | 2021-12-17T00·49-0500 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2021-12-26T14·55+0000 |
commit | 80ef71e9958d0effe0ea1e1fb39b7200e02eff70 (patch) | |
tree | 8b47e0210cb8fcaf255aafb27ffe6faac0dd2f5e /ops/nixos.nix | |
parent | 1d10adb67ccf87cc7461be71905b1ee2378b7c73 (diff) |
feat(ops/auto-deploy): Support auto-deploy r/3414
Automatically rebuild the current system's NixOS config from the latest checkout of depot. Change-Id: I23aa7af50e16e985ac34df214e0905e770316e5e Reviewed-on: https://cl.tvl.fyi/c/depot/+/4390 Reviewed-by: wpcarro <wpcarro@gmail.com> Reviewed-by: zseri <zseri.devel@ytrizja.de> Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI
Diffstat (limited to 'ops/nixos.nix')
-rw-r--r-- | ops/nixos.nix | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ops/nixos.nix b/ops/nixos.nix index 19ba0168c07e..66ca188c5bca 100644 --- a/ops/nixos.nix +++ b/ops/nixos.nix @@ -32,7 +32,9 @@ in rec { (throw "${hostname} is not a known NixOS host") (map nixosFor depot.ops.machines.all-systems)); - rebuild-system = pkgs.writeShellScriptBin "rebuild-system" '' + rebuild-system = rebuildSystemWith depot.path; + + rebuildSystemWith = depotPath: pkgs.writeShellScriptBin "rebuild-system" '' set -ue if [[ $EUID -ne 0 ]]; then echo "Oh no! Only root is allowed to rebuild the system!" >&2 @@ -40,9 +42,9 @@ in rec { fi echo "Rebuilding NixOS for $HOSTNAME" - system=$(nix-build -E "((import ${toString depot.path} {}).ops.nixos.findSystem \"$HOSTNAME\").system" --no-out-link --show-trace) + system=$(${pkgs.nix}/bin/nix-build -E "((import ${depotPath} {}).ops.nixos.findSystem \"$HOSTNAME\").system" --no-out-link --show-trace) - nix-env -p /nix/var/nix/profiles/system --set $system + ${pkgs.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set $system $system/bin/switch-to-configuration switch ''; |