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