Improve nix run .#HOSTNAME-nixos-rebuild
This commit is contained in:
parent
e110b04549
commit
8ff2ad30f5
14
packages.nix
14
packages.nix
|
@ -98,6 +98,7 @@ lib.attrsets.mapAttrs
|
|||
hostConfig = self.nixosConfigurations."${name}".config;
|
||||
hostPkgs = self.nixosConfigurations."${name}".pkgs;
|
||||
declaredRunnerDrvPath = discardStringCtx hostConfig.microvm.declaredRunner.drvPath;
|
||||
toplevelDrvPath = discardStringCtx hostConfig.system.build.toplevel.drvPath;
|
||||
toplevelOutPath = discardStringCtx hostConfig.system.build.toplevel.outPath;
|
||||
# let /var/lib/microvm/*/flake point to the flake-update branch so that
|
||||
# `microvm -u $NAME` updates to what hydra built today.
|
||||
|
@ -117,11 +118,14 @@ lib.attrsets.mapAttrs
|
|||
|
||||
[[ $(ssh ${target} cat /etc/hostname) == ${name} ]]
|
||||
nix copy --no-check-sigs --to ssh-ng://${target} ${inputPaths}
|
||||
nix copy --no-check-sigs --derivation --to ssh-ng://${target} ${discardStringCtx hostConfig.system.build.nixos-rebuild.drvPath}
|
||||
nix copy --no-check-sigs --derivation --to ssh-ng://${target} ${toplevelDrvPath}
|
||||
|
||||
# use nixos-rebuild from target config
|
||||
nixosRebuild=$(ssh ${target} nix build ${discardStringCtx hostConfig.system.build.nixos-rebuild.drvPath} ${overrideInputsArgs} --no-link --json | ${lib.getExe hostPkgs.jq} -r '.[0].outputs.out')
|
||||
ssh ${target} $nixosRebuild/bin/nixos-rebuild ${rebuildArg} "$@"
|
||||
ssh ${target} bash -e <<END
|
||||
nix build ${toplevelDrvPath}
|
||||
nix-env -p /nix/var/nix/profiles/system --set ${toplevelOutPath}
|
||||
${toplevelOutPath}/bin/switch-to-configuration "''${@:-switch}"
|
||||
END
|
||||
'';
|
||||
|
||||
"${name}-nixos-rebuild-hydra" = pkgs.writeScriptBin "${name}-nixos-rebuild" ''
|
||||
|
@ -190,13 +194,13 @@ lib.attrsets.mapAttrs
|
|||
then ''
|
||||
set -eou pipefail
|
||||
|
||||
${hostConfig.system.build.copyToServer} ${inputPaths} ${declaredRunnerDrvPath}
|
||||
${hostConfig.system.build.copyToServer} ${declaredRunnerDrvPath}
|
||||
|
||||
${hostConfig.system.build.runOnServer} NIXOS_REBUILD="''${NIXOS_REBUILD:-}" bash -e <<END
|
||||
set -eou pipefail
|
||||
${createDirsCopyCurrent name}
|
||||
|
||||
nix build -L --accept-flake-config -o current ${overrideInputsArgs} ${declaredRunnerDrvPath}
|
||||
nix build -L --accept-flake-config -o current ${declaredRunnerDrvPath}
|
||||
echo '${selfRef}' > flake
|
||||
|
||||
${createSymlinks name}
|
||||
|
|
Loading…
Reference in New Issue