{ systemConfig ? null, lib, buildEnv, writeTextFile, writeScriptBin, runtimeShell, deploy-rs, }: if systemConfig != null then buildEnv { name = "activatable-${systemConfig.system.build.toplevel.name}"; paths = [ systemConfig.system.build.toplevel (writeTextFile { name = "${systemConfig.system.build.toplevel.name}-activate-path"; text = '' #!${runtimeShell} set -euo pipefail if [[ "''${DRY_ACTIVATE:-}" == "1" ]] then $PROFILE/bin/switch-to-configuration dry-activate elif [[ "''${BOOT:-}" == "1" ]] then $PROFILE/bin/switch-to-configuration boot else # work around https://github.com/NixOS/nixpkgs/issues/73404 cd /tmp $PROFILE/bin/switch-to-configuration switch # https://github.com/serokell/deploy-rs/issues/31 ${lib.optionalString systemConfig.boot.loader.systemd-boot.enable "sed -i '/^default /d' ${systemConfig.boot.loader.efi.efiSysMountPoint}/loader/loader.conf"} fi ''; executable = true; destination = "/deploy-rs-activate"; }) (writeTextFile { name = "${systemConfig.system.build.toplevel.name}-activate-rs"; destination = "/activate-rs"; executable = true; text = '' #!${runtimeShell} exec ${deploy-rs}/bin/activate "$@" ''; }) ]; } else writeScriptBin "activate" "echo 'No system config given!'"