1 { pkgs, lib, config, ... }:
3 inherit (builtins) listToAttrs;
5 inherit (config) networking;
7 nixRunDefaultCommand = "bash";
11 enable = lib.mkEnableOption "Install";
12 shellScript = lib.mkOption {
15 apply = lines: pkgs.writeShellScriptBin nixRunDefaultCommand "set -eu\n${lines}";
17 target = lib.mkOption {
19 default = "root@${networking.hostName}.${networking.domain}";
21 profile = lib.mkOption {
23 default = "/nix/var/nix/profiles/system";
26 config = lib.mkIf cfg.enable {
28 let nixos = config.system.build.toplevel; in ''
30 PATH="$PATH:${with pkgs; lib.makeBinPath [nix openssh]}"
32 nix ''${TRACE:+-L} copy \
33 --to ssh://${cfg.target} --substitute-on-destination \
35 ssh ${cfg.target} nix-env --profile "${cfg.profile}" --set "${nixos}" \
36 '&&' "${cfg.profile}"/bin/switch-to-configuration "''${switch:-switch}"