]> Git — Sourcephile - sourcephile-nix.git/blob - servers/mermet.nix
nix: revamp nixos/{base => profiles}/
[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 # or:
6 # nix eval servers.mermet.config.networking.hostName
7 # Install/upgrade with:
8 # nix run install -f servers/mermet.nix
9 # or:
10 # nix run servers.mermet.install
11 let
12 ipv4 = "80.67.180.129";
13 system = import <nixpkgs/nixos/lib/eval-config.nix> {
14 system = "x86_64-linux";
15 modules = [
16 ../nixos/defaults.nix
17 ../nixos/profiles/services/unbound.nix
18 mermet/acme.nix
19 mermet/debug.nix
20 mermet/dovecot.nix
21 mermet/fileSystems.nix
22 mermet/gitolite.nix
23 mermet/hardware.nix
24 mermet/knot.nix
25 #mermet/mlmmj.nix
26 mermet/networking.nix
27 mermet/nginx.nix
28 mermet/openldap.nix
29 mermet/postfix.nix
30 mermet/public-inbox.nix
31 mermet/redis.nix
32 mermet/rspamd.nix
33 mermet/sanoid.nix
34 mermet/shorewall.nix
35 mermet/system.nix
36 mermet/users.nix
37 ];
38 extraArgs = {
39 name = "mermet";
40 inherit ipv4;
41 servers = import ../servers.nix;
42 };
43 };
44 inherit (system.config) networking;
45 lib = system.pkgs.lib;
46 in with system; system // {
47 inherit ipv4;
48 install =
49 let target = "root@${networking.hostName}.${networking.domain}";
50 profile = "/nix/var/nix/profiles/system";
51 generations = "+10";
52 nixos = config.system.build.toplevel;
53 in
54 pkgs.writeShellScriptBin "bash" ''
55 PATH="$PATH:${with pkgs; lib.makeBinPath [nix openssh pass]}"
56 set -eux
57 nix ''${TRACE:+-L} copy \
58 --to ssh://${target} --substitute-on-destination \
59 ${nixos}
60 target="${target}"
61 ${config.security.install.shellHook}
62 ssh ${target} nix-env --profile "${profile}" --set "${nixos}" \
63 '&&' nix-env --profile "${profile}" --delete-generations "${generations}" \
64 '&&' "${profile}"/bin/switch-to-configuration "''${switch:-switch}"
65 '';
66 }