]> Git — Sourcephile - sourcephile-nix.git/blob - servers/mermet.nix
nix: enable nix run servers.$server.install
[sourcephile-nix.git] / servers / mermet.nix
1 # NixOS configuration of mermet.sourcephile.fr
2 #
3 # Show configuration options with, for example:
4 # nix-instantiate servers/mermet.nix --eval -A config.networking.hostName
5 # Install/upgrade with:
6 # nix run install -f servers/mermet.nix
7 let
8 system = import <nixpkgs/nixos/lib/eval-config.nix> {
9 system = "x86_64-linux";
10 modules = [
11 ../base/install.nix
12 ../base/unbound.nix
13 ../defaults.nix
14 mermet/debug.nix
15 mermet/dovecot.nix
16 mermet/fileSystems.nix
17 mermet/gitolite.nix
18 mermet/hardware.nix
19 mermet/knot.nix
20 mermet/networking.nix
21 mermet/nginx.nix
22 mermet/openldap.nix
23 mermet/postfix.nix
24 mermet/redis.nix
25 mermet/rspamd.nix
26 mermet/sanoid.nix
27 mermet/shorewall.nix
28 mermet/system.nix
29 mermet/users.nix
30 ];
31 extraArgs = {
32 name = "mermet";
33 };
34 };
35 inherit (system.config) networking;
36 lib = system.pkgs.lib;
37 in with system; system // {
38 install =
39 let target = "root@${networking.hostName}.${networking.domain}";
40 profile = "/nix/var/nix/profiles/system";
41 generations = "+10";
42 nixos = config.system.build.toplevel;
43 in
44 pkgs.writeShellScriptBin "bash" ''
45 PATH="$PATH:${with pkgs; lib.makeBinPath [nix openssh pass]}"
46 set -eux
47 nix ''${TRACE:+-L} copy \
48 --to ssh://${target} --substitute-on-destination \
49 ${nixos}
50 target="${target}"
51 ${config.install.shellHook}
52 ssh ${target} nix-env --profile "${profile}" --set "${nixos}" \
53 '&&' nix-env --profile "${profile}" --delete-generations "${generations}" \
54 '&&' "${profile}"/bin/switch-to-configuration "''${switch:-switch}"
55 '';
56 }