]> Git — Sourcephile - sourcephile-nix.git/blob - nixos/modules/install/ssh-nixos.nix
nginx: fix auth_basic
[sourcephile-nix.git] / nixos / modules / install / ssh-nixos.nix
1 { pkgs, lib, config, ... }:
2 let
3 inherit (lib) types;
4 inherit (config) networking;
5 cfg = config.install.ssh-nixos;
6 nixRunDefaultCommand = "bash";
7 in
8 {
9 options.install.ssh-nixos = {
10 PATH = lib.mkOption {
11 type = types.listOf types.package;
12 default = [];
13 apply = lib.makeBinPath;
14 };
15 script = lib.mkOption {
16 type = types.lines;
17 default = "";
18 apply = script: pkgs.writeShellScriptBin nixRunDefaultCommand ''
19 set -eu
20 PATH="$PATH:${cfg.PATH}"
21 set -x
22 ${script}
23 '';
24 };
25 target = lib.mkOption {
26 type = types.str;
27 default = "root@${networking.hostName}.${networking.domain}";
28 };
29 profile = lib.mkOption {
30 type = types.str;
31 default = "/nix/var/nix/profiles/system";
32 };
33 };
34 config = {
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 \
40 ${nixos}
41 ssh ${cfg.target} nix-env --profile "${cfg.profile}" --set "${nixos}" \
42 '&&' "${cfg.profile}"/bin/switch-to-configuration "''${switch:-switch}"
43 '';
44 };
45 meta.maintainers = [ lib.maintainers.julm ];
46 }