1 { pkgs, lib, config, ... }:
4 inherit (config) networking;
5 cfg = config.install.ssh-nixos;
6 nixRunDefaultCommand = "bash";
9 options.install.ssh-nixos = {
11 type = types.listOf types.package;
13 apply = lib.makeBinPath;
15 script = lib.mkOption {
18 apply = script: pkgs.writeShellScriptBin nixRunDefaultCommand ''
20 PATH="$PATH:${cfg.PATH}"
25 target = lib.mkOption {
27 default = "root@${networking.hostName}.${networking.domain}";
29 profile = lib.mkOption {
31 default = "/nix/var/nix/profiles/system";
35 install.ssh-nixos.PATH = with pkgs; [nix openssh];
36 install.ssh-nixos.script =
37 let nixos = config.system.build.toplevel; in ''
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 '&&' "${cfg.profile}"/bin/switch-to-configuration "''${switch:-switch}"
45 meta.maintainers = [ lib.maintainers.julm ];