]> Git — Sourcephile - sourcephile-nix.git/blob - nixos/modules/install.nix
nix: fix install and security.pass
[sourcephile-nix.git] / nixos / modules / install.nix
1 { pkgs, lib, config, ... }:
2 let
3 inherit (builtins) listToAttrs;
4 inherit (lib) types;
5 inherit (config) networking;
6 cfg = config.install;
7 nixRunDefaultCommand = "bash";
8 in
9 {
10 options.install = {
11 enable = lib.mkEnableOption "Install";
12 shellScript = lib.mkOption {
13 type = types.lines;
14 default = "";
15 apply = lines: pkgs.writeShellScriptBin nixRunDefaultCommand "set -eu\n${lines}";
16 };
17 target = lib.mkOption {
18 type = types.str;
19 default = "root@${networking.hostName}.${networking.domain}";
20 };
21 profile = lib.mkOption {
22 type = types.str;
23 default = "/nix/var/nix/profiles/system";
24 };
25 };
26 config = lib.mkIf cfg.enable {
27 install.shellScript =
28 let nixos = config.system.build.toplevel; in ''
29 (
30 PATH="$PATH:${with pkgs; lib.makeBinPath [nix openssh]}"
31 set -x
32 nix ''${TRACE:+-L} copy \
33 --to ssh://${cfg.target} --substitute-on-destination \
34 ${nixos}
35 ssh ${cfg.target} nix-env --profile "${cfg.profile}" --set "${nixos}" \
36 '&&' "${cfg.profile}"/bin/switch-to-configuration "''${switch:-switch}"
37 )
38 '';
39 };
40 }