2 { config, pkgs, name, lib, ... }:
6 targetHost = config.hostEnv.ips.main.ip4;
7 substituteOnDestination = true;
9 nixpkgs.system = lib.mkOverride 900 "x86_64-linux";
14 devices = [ "/dev/sda" "/dev/sdb" "/dev/sdc" "/dev/sdd" ];
18 blacklistedKernelModules = [ "nvidiafb" ];
19 supportedFilesystems = [ "zfs" ];
20 kernelPackages = pkgs.linuxPackages_latest;
21 kernelModules = [ "kvm-intel" ];
22 initrd.availableKernelModules = [ "ahci" "sd_mod" ];
24 "/boot/pass.key" = "/boot/pass.key";
26 kernel.sysctl."vm.nr_hugepages" = 256; # for xmr-stak
27 # available in nixos-20.09
28 #zfs.requestEncryptionCredentials = [ "zpool/root" ];
31 powerManagement.cpuFreqGovernor = "powersave";
32 hardware.enableRedistributableFirmware = true;
34 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
36 swapDevices = [ { label = "swap"; } ];
38 "/" = { fsType = "zfs"; device = "zpool/root"; };
39 "/boot" = { fsType = "ext4"; device = "/dev/disk/by-uuid/fd1c511e-2bc0-49d5-b8bb-95e7e8c8c816"; };
40 "/etc" = { fsType = "zfs"; device = "zpool/root/etc"; };
41 "/home" = { fsType = "zfs"; device = "zpool/root/home"; };
42 "/home/immae" = { fsType = "zfs"; device = "zpool/root/home/immae"; };
43 "/tmp" = { fsType = "zfs"; device = "zpool/root/tmp"; };
44 "/var" = { fsType = "zfs"; device = "zpool/root/var"; };
45 "/data" = { fsType = "ext4"; label = "data"; };
46 "/nix" = { fsType = "ext4"; label = "nix"; };
49 services.udev.extraRules = ''
50 ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="10:bf:48:7f:e6:3b", NAME="eth0"
54 hostId = "27c3048d"; # generated with head -c4 /dev/urandom | od -A none -t x4
55 firewall.enable = false;
56 interfaces."eth0".ipv4.addresses =
57 [ { address = config.hostEnv.ips.main.ip4; prefixLength = 27; } ]
58 ++ pkgs.lib.attrsets.mapAttrsToList
59 (n: ips: { address = ips.ip4; prefixLength = 32; })
60 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
61 interfaces."eth0".ipv6.addresses =
62 [ { address = "2a01:4f8:141:53e7::"; prefixLength = 64; } ]
63 ++ pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
64 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
66 defaultGateway = { address = "176.9.10.225"; interface = "eth0"; };
67 defaultGateway6 = { address = "fe80::1"; interface = "eth0"; };
72 "2a01:4f8:0:a0a1::add:1010"
73 "2a01:4f8:0:a102::add:9999"
74 "2a01:4f8:0:a111::add:9898"
78 myServices.ssh.modules = [ config.myServices.ssh.predefinedModules.regular ];
79 imports = builtins.attrValues (import ../..) ++ [ ./dilion/vms.nix ];
81 system.nssModules = [ pkgs.libvirt ];
82 system.nssDatabases.hosts = lib.mkForce [ "files" "libvirt_guest" "mymachines" "dns" "myhostname" ];
83 programs.zsh.enable = true;
85 users.users.libvirt = {
87 shell = pkgs.bashInteractive;
90 packages = [ pkgs.netcat-openbsd ];
91 openssh.authorizedKeys.keyFiles = [
92 "${privateFiles}/buildbot_ssh_key.pub"
94 openssh.authorizedKeys.keys = [ config.myEnv.sshd.rootKeys.ismael_flony ];
97 users.users.backup = {
100 extraGroups = [ "keys" ];
101 shell = pkgs.bashInteractive;
102 openssh.authorizedKeys.keys = let
103 zreplConfig = config.secrets.fullPaths."zrepl/zrepl.yml";
105 ["command=\"${pkgs.zrepl}/bin/zrepl stdinserver --config ${zreplConfig} eldiron\",restrict ${config.myEnv.zrepl_backup.ssh_key.public}"];
107 security.sudo.extraRules = pkgs.lib.mkAfter [
110 { command = "/home/immae/.nix-profile/root_scripts/*"; options = [ "NOPASSWD" ]; }
117 system.activationScripts.libvirtd_exports = ''
118 install -m 0755 -o root -g root -d /var/lib/caldance
120 virtualisation.docker.enable = true;
121 virtualisation.docker.storageDriver = "zfs";
122 virtualisation.libvirtd.enable = true;
123 users.extraUsers.immae.extraGroups = [ "libvirtd" "docker" ];
124 systemd.services.libvirtd.postStart = ''
125 install -m 0770 -g libvirtd -d /var/lib/libvirt/images
127 systemd.services.socat-caldance = {
128 description = "Forward ssh port to caldance";
129 wantedBy = [ "multi-user.target" ];
130 after = [ "network.target" ];
133 ExecStart = "${pkgs.socat}/bin/socat TCP-LISTEN:8022,fork TCP:caldance:22";
137 time.timeZone = "Europe/Paris";
139 useSandbox = "relaxed";
142 keep-derivations = true
143 allow-unsafe-native-code-during-evaluation = true
144 experimental-features = nix-command flakes
146 allow-import-from-derivation = true
150 security.pki.certificateFiles = [
152 url = "http://downloads.e.eriomem.net/eriomemca.pem";
153 sha256 = "1ixx4c6j3m26j8dp9a3dkvxc80v1nr5aqgmawwgs06bskasqkvvh";
157 # This is equivalent to setting environment.sessionVariables.NIX_PATH
159 "home-manager=${pkgs.sources.home-manager.url}"
160 "nixpkgs=${pkgs.sources.nixpkgs-home-manager.url}"
162 nix.binaryCaches = [ "https://hydra.iohk.io" "https://cache.nixos.org" ];
163 nix.binaryCachePublicKeys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
165 myServices.monitoring.enable = true;
166 myServices.certificates.enable = true;
167 security.acme.certs."${name}-immae" = config.myServices.certificates.certConfig // {
169 domain = "dilion.immae.eu";
171 security.acme.certs."${name}" = {
172 user = config.services.nginx.user;
173 group = config.services.nginx.group;
175 "dev.immae.eu" = null;
176 "caldance.immae.eu" = null;
181 recommendedOptimisation = true;
182 recommendedGzipSettings = true;
183 recommendedProxySettings = true;
185 caldance.servers."caldance:3031" = {};
189 acmeRoot = config.myServices.certificates.webroot;
192 root = "/home/immae/www";
194 "caldance.immae.eu" = {
195 acmeRoot = config.myServices.certificates.webroot;
198 locations."/".extraConfig = ''
201 locations."/static/".alias = "/var/lib/caldance/caldance/app/www/static/";
202 locations."/media/".alias = "/var/lib/caldance/caldance/media/";
204 auth_basic "Authentification requise";
205 auth_basic_user_file ${pkgs.writeText "htpasswd" config.myEnv.websites.caldance.integration.password};
211 systemd.services.zrepl.serviceConfig.RuntimeDirectory = lib.mkForce "zrepl zrepl/stdinserver";
212 systemd.services.zrepl.serviceConfig.User = "backup";
213 # zfs allow backup create,mount,receive,destroy,rename,snapshot,hold,bookmark,release zpool/backup
219 sockpath: /run/zrepl/control
222 sockdir: /run/zrepl/stdinserver
226 name: "backup-from-eldiron"
227 root_fs: "zpool/backup"
234 # This value determines the NixOS release with which your system is
235 # to be compatible, in order to avoid breaking some software such as
236 # database servers. You should change this only after NixOS release
237 # notes say you should.
238 # https://nixos.org/nixos/manual/release-notes.html
239 system.stateVersion = "20.03"; # Did you read the comment?