2 { config, pkgs, name, lib, ... }:
4 boot.supportedFilesystems = [ "zfs" ];
5 boot.kernelPackages = pkgs.linuxPackages_latest;
6 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
9 "/" = lib.mkForce { fsType = "zfs"; device = "zpool/root"; };
10 "/boot" = { fsType = "ext4"; device = "/dev/disk/by-uuid/fd1c511e-2bc0-49d5-b8bb-95e7e8c8c816"; };
11 "/etc" = { fsType = "zfs"; device = "zpool/root/etc"; };
12 "/home" = { fsType = "zfs"; device = "zpool/root/home"; };
13 "/home/immae" = { fsType = "zfs"; device = "zpool/root/home/immae"; };
14 "/tmp" = { fsType = "zfs"; device = "zpool/root/tmp"; };
15 "/var" = { fsType = "zfs"; device = "zpool/root/var"; };
17 boot.initrd.secrets = {
18 "/boot/pass.key" = "/boot/pass.key";
22 hostId = "27c3048d"; # generated with head -c4 /dev/urandom | od -A none -t x4
23 firewall.enable = false;
24 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
25 (n: ips: { address = ips.ip4; prefixLength = 32; })
26 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
27 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
28 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
32 myServices.ssh.modules = [ config.myServices.ssh.predefinedModules.regular ];
33 imports = builtins.attrValues (import ../..);
36 targetEnv = "hetzner";
38 robotUser = config.myEnv.hetzner.user;
39 robotPass = config.myEnv.hetzner.pass;
40 mainIPv4 = config.hostEnv.ips.main.ip4;
42 clearpart --all --initlabel --drives=sda,sdb,sdc,sdd
44 part swap --recommended --label=swap --fstype=swap --ondisk=sda
46 part raid.1 --grow --ondisk=sdc
47 part raid.2 --grow --ondisk=sdd
49 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
51 part /nix --grow --label=nix --ondisk=sda
52 part /data --grow --label=data --ondisk=sdb
57 system.nssModules = [ pkgs.libvirt ];
58 system.nssDatabases.hosts = lib.mkForce [ "files" "libvirt_guest" "mymachines" "dns" "myhostname" ];
59 programs.zsh.enable = true;
61 users.users.backup = {
62 home = "/var/lib/backup";
66 shell = pkgs.bashInteractive;
67 openssh.authorizedKeys.keys = let
69 ["command=\"${pkgs.rrsync_sudo}/bin/rrsync /var/lib/backup/eldiron/\" ${config.myEnv.rsync_backup.ssh_key.public}"];
71 security.sudo.extraRules = pkgs.lib.mkAfter [
74 { command = "${pkgs.rsync}/bin/rsync"; options = [ "NOPASSWD" ]; }
81 { command = "/home/immae/.nix-profile/root_scripts/*"; options = [ "NOPASSWD" ]; }
88 boot.kernel.sysctl."vm.nr_hugepages" = 256; # for xmr-stak
89 system.activationScripts.backup_home = ''
90 chown root:root /var/lib/backup
91 install -m 0750 -o backup -g root -d /var/lib/backup/eldiron
94 system.activationScripts.libvirtd_exports = ''
95 install -m 0755 -o root -g root -d /var/lib/caldance
97 virtualisation.docker.enable = true;
98 virtualisation.docker.storageDriver = "zfs";
99 virtualisation.libvirtd.enable = true;
100 users.extraUsers.immae.extraGroups = [ "libvirtd" "docker" ];
101 systemd.services.libvirtd.postStart = ''
102 install -m 0770 -g libvirtd -d /var/lib/libvirt/images
104 systemd.services.socat-caldance = {
105 description = "Forward ssh port to caldance";
106 wantedBy = [ "multi-user.target" ];
107 after = [ "network.target" ];
110 ExecStart = "${pkgs.socat}/bin/socat TCP-LISTEN:8022,fork TCP:nixops-99a7e1ba-54dc-11ea-a965-10bf487fe63b-caldance:22";
114 time.timeZone = "Europe/Paris";
116 useSandbox = "relaxed";
119 keep-derivations = true
121 allow-import-from-derivation = true
125 security.pki.certificateFiles = [
127 url = "http://downloads.e.eriomem.net/eriomemca.pem";
128 sha256 = "1ixx4c6j3m26j8dp9a3dkvxc80v1nr5aqgmawwgs06bskasqkvvh";
132 # This is equivalent to setting environment.sessionVariables.NIX_PATH
134 "home-manager=${pkgs.sources.home-manager.url}"
135 "nixpkgs=${pkgs.sources.nixpkgs-home-manager.url}"
137 nix.binaryCaches = [ "https://hydra.iohk.io" "https://cache.nixos.org" ];
138 nix.binaryCachePublicKeys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
140 myServices.certificates.enable = true;
141 security.acme.certs."${name}" = {
142 user = config.services.nginx.user;
143 group = config.services.nginx.group;
145 "discourse.immae.eu" = null;
146 "discourse.cip-ca.fr" = null;
147 "dev.immae.eu" = null;
148 "caldance.immae.eu" = null;
153 recommendedOptimisation = true;
154 recommendedGzipSettings = true;
155 recommendedProxySettings = true;
157 caldance.servers."nixops-99a7e1ba-54dc-11ea-a965-10bf487fe63b-caldance:3031" = {};
161 acmeRoot = config.myServices.certificates.webroot;
164 root = "/home/immae/www";
166 "discourse.immae.eu" = {
167 acmeRoot = config.myServices.certificates.webroot;
170 locations."/".proxyPass = "http://localhost:18031";
172 "discourse.cip-ca.fr" = {
173 acmeRoot = config.myServices.certificates.webroot;
176 locations."/".proxyPass = "http://localhost:18031";
178 "caldance.immae.eu" = {
179 acmeRoot = config.myServices.certificates.webroot;
182 locations."/".extraConfig = ''
185 locations."/static/".alias = "/var/lib/caldance/caldance/app/www/static/";
186 locations."/media/".alias = "/var/lib/caldance/caldance/media/";
188 auth_basic "Authentification requise";
189 auth_basic_user_file ${pkgs.writeText "htpasswd" config.myEnv.websites.caldance.integration.password};
195 # This value determines the NixOS release with which your system is
196 # to be compatible, in order to avoid breaking some software such as
197 # database servers. You should change this only after NixOS release
198 # notes say you should.
199 # https://nixos.org/nixos/manual/release-notes.html
200 system.stateVersion = "20.03"; # Did you read the comment?