1 { pkgs, lib, config, ... }:
3 inherit (builtins) listToAttrs;
5 inherit (config) networking;
10 enable = lib.mkEnableOption "Install";
11 shellHook = lib.mkOption {
15 shellScript = lib.mkOption {
18 apply = pkgs.writeShellScriptBin "bash";
20 target = lib.mkOption {
22 default = "root@${networking.hostName}.${networking.domain}";
24 generations = lib.mkOption {
28 profile = lib.mkOption {
30 default = "/nix/var/nix/profiles/system";
33 config = lib.mkIf cfg.enable {
35 let nixos = config.system.build.toplevel; in ''
36 PATH="$PATH:${with pkgs; lib.makeBinPath [nix openssh]}"
38 nix ''${TRACE:+-L} copy \
39 --to ssh://${cfg.target} --substitute-on-destination \
41 ssh ${cfg.target} nix-env --profile "${cfg.profile}" --set "${nixos}" \
42 '&&' nix-env --profile "${cfg.profile}" --delete-generations "${cfg.generations}" \
43 '&&' "${cfg.profile}"/bin/switch-to-configuration "''${switch:-switch}"