2 { config, pkgs, name, lib, ... }:
4 boot.supportedFilesystems = [ "zfs" ];
5 boot.kernelPackages = pkgs.linuxPackages_latest;
6 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
9 hostId = "27c3048d"; # generated with head -c4 /dev/urandom | od -A none -t x4
10 firewall.enable = false;
11 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
12 (n: ips: { address = ips.ip4; prefixLength = 32; })
13 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
14 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
15 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
19 myServices.ssh.modules = [ config.myServices.ssh.predefinedModules.regular ];
20 imports = builtins.attrValues (import ../..);
23 targetEnv = "hetzner";
25 robotUser = config.myEnv.hetzner.user;
26 robotPass = config.myEnv.hetzner.pass;
27 mainIPv4 = config.hostEnv.ips.main.ip4;
29 clearpart --all --initlabel --drives=sda,sdb,sdc,sdd
31 part swap --recommended --label=swap --fstype=swap --ondisk=sda
33 part raid.1 --grow --ondisk=sdc
34 part raid.2 --grow --ondisk=sdd
36 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
38 part /nix --grow --label=nix --ondisk=sda
39 part /data --grow --label=data --ondisk=sdb
44 system.nssModules = [ pkgs.libvirt ];
45 system.nssHosts = lib.mkForce [ "files" "libvirt_guest" "mymachines" "dns" "myhostname" ];
46 programs.zsh.enable = true;
48 users.users.backup = {
49 home = "/var/lib/backup";
53 shell = pkgs.bashInteractive;
54 openssh.authorizedKeys.keys = let
56 ["command=\"${pkgs.rrsync_sudo}/bin/rrsync /var/lib/backup/eldiron/\" ${config.myEnv.rsync_backup.ssh_key.public}"];
58 security.sudo.extraRules = pkgs.lib.mkAfter [
61 { command = "${pkgs.rsync}/bin/rsync"; options = [ "NOPASSWD" ]; }
68 { command = "/home/immae/.nix-profile/root_scripts/*"; options = [ "NOPASSWD" ]; }
75 boot.kernel.sysctl."vm.nr_hugepages" = 256; # for xmr-stak
76 system.activationScripts.backup_home = ''
77 chown root:root /var/lib/backup
78 install -m 0750 -o backup -g root -d /var/lib/backup/eldiron
81 system.activationScripts.libvirtd_exports = ''
82 install -m 0755 -o root -g root -d /var/lib/caldance
84 virtualisation.docker.enable = true;
85 virtualisation.libvirtd.enable = true;
86 users.extraUsers.immae.extraGroups = [ "libvirtd" "docker" ];
87 systemd.services.libvirtd.postStart = ''
88 install -m 0770 -g libvirtd -d /var/lib/libvirt/images
90 systemd.services.socat-caldance = {
91 description = "Forward ssh port to caldance";
92 wantedBy = [ "multi-user.target" ];
93 after = [ "network.target" ];
96 ExecStart = "${pkgs.socat}/bin/socat TCP-LISTEN:8022,fork TCP:nixops-99a7e1ba-54dc-11ea-a965-10bf487fe63b-caldance:22";
100 time.timeZone = "Europe/Paris";
102 useSandbox = "relaxed";
105 keep-derivations = true
107 allow-import-from-derivation = true
111 security.pki.certificateFiles = [
113 url = "http://downloads.e.eriomem.net/eriomemca.pem";
114 sha256 = "1ixx4c6j3m26j8dp9a3dkvxc80v1nr5aqgmawwgs06bskasqkvvh";
118 # This is equivalent to setting environment.sessionVariables.NIX_PATH
120 "home-manager=${pkgs.sources.home-manager.url}"
121 "nixpkgs=${pkgs.sources.nixpkgs-home-manager.url}"
123 nix.binaryCaches = [ "https://hydra.iohk.io" "https://cache.nixos.org" ];
124 nix.binaryCachePublicKeys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
126 myServices.certificates.enable = true;
127 security.acme.certs."${name}" = {
128 user = config.services.nginx.user;
129 group = config.services.nginx.group;
131 "discourse.immae.eu" = null;
132 "discourse.cip-ca.fr" = null;
133 "dev.immae.eu" = null;
134 "caldance.immae.eu" = null;
139 recommendedOptimisation = true;
140 recommendedGzipSettings = true;
141 recommendedProxySettings = true;
143 caldance.servers."nixops-99a7e1ba-54dc-11ea-a965-10bf487fe63b-caldance:3031" = {};
147 acmeRoot = config.myServices.certificates.webroot;
150 root = "/home/immae/www";
152 "discourse.immae.eu" = {
153 acmeRoot = config.myServices.certificates.webroot;
156 locations."/".proxyPass = "http://localhost:18031";
158 "discourse.cip-ca.fr" = {
159 acmeRoot = config.myServices.certificates.webroot;
162 locations."/".proxyPass = "http://localhost:18031";
164 "caldance.immae.eu" = {
165 acmeRoot = config.myServices.certificates.webroot;
168 locations."/".extraConfig = ''
171 locations."/static/".alias = "/var/lib/caldance/caldance/app/www/static/";
172 locations."/media/".alias = "/var/lib/caldance/caldance/media/";
174 auth_basic "Authentification requise";
175 auth_basic_user_file ${pkgs.writeText "htpasswd" config.myEnv.websites.caldance.integration.password};
181 # This value determines the NixOS release with which your system is
182 # to be compatible, in order to avoid breaking some software such as
183 # database servers. You should change this only after NixOS release
184 # notes say you should.
185 # https://nixos.org/nixos/manual/release-notes.html
186 system.stateVersion = "20.03"; # Did you read the comment?