1 { config, pkgs, name, lib, pkgs-no-overlay, secrets, ... }:
3 # ssh-keyscan dilion | nix-shell -p ssh-to-age --run ssh-to-age
4 secrets.ageKeys = [ "age1x49n6qa0arkdpq8530s7umgm0gqkq90exv4jep97q30rfnzknpaqate06a" ];
8 devices = [ "/dev/sda" "/dev/sdb" "/dev/sdc" "/dev/sdd" ];
12 blacklistedKernelModules = [ "nvidiafb" ];
13 supportedFilesystems = [ "zfs" ];
14 kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
15 kernelModules = [ "kvm-intel" ];
16 initrd.availableKernelModules = [ "ahci" "sd_mod" ];
18 "/boot/pass.key" = "/boot/pass.key";
20 kernel.sysctl."vm.nr_hugepages" = 256; # for xmr-stak
21 # available in nixos-20.09
22 #zfs.requestEncryptionCredentials = [ "zpool/root" ];
24 powerManagement.cpuFreqGovernor = "powersave";
25 hardware.enableRedistributableFirmware = true;
27 swapDevices = [ { label = "swap"; } ];
29 "/" = { fsType = "zfs"; device = "zpool/root"; };
30 "/boot" = { fsType = "ext4"; device = "/dev/disk/by-uuid/fd1c511e-2bc0-49d5-b8bb-95e7e8c8c816"; };
31 "/etc" = { fsType = "zfs"; device = "zpool/root/etc"; };
32 "/home" = { fsType = "zfs"; device = "zpool/root/home"; };
33 "/home/immae" = { fsType = "zfs"; device = "zpool/root/home/immae"; };
34 "/tmp" = { fsType = "zfs"; device = "zpool/root/tmp"; };
35 "/var" = { fsType = "zfs"; device = "zpool/root/var"; };
36 "/data" = { fsType = "ext4"; label = "data"; };
37 "/nix" = { fsType = "ext4"; label = "nix"; };
40 services.udev.extraRules = ''
41 ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="10:bf:48:7f:e6:3b", NAME="eth0"
44 nixpkgs.config.permittedInsecurePackages = [
45 "python-2.7.18.6" # for nagios-cli
49 hostId = "27c3048d"; # generated with head -c4 /dev/urandom | od -A none -t x4
50 firewall.enable = false;
51 interfaces."eth0".ipv4.addresses =
52 [ { address = lib.head config.hostEnv.ips.main.ip4; prefixLength = 27; } ]
53 ++ pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
54 (n: ips: map (ip: { address = ip; prefixLength = 32; }) (ips.ip4 or []))
55 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips));
56 interfaces."eth0".ipv6.addresses =
57 [ { address = "2a01:4f8:141:53e7::"; prefixLength = 64; } ]
58 ++ pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
59 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
61 defaultGateway = { address = "176.9.10.225"; interface = "eth0"; };
62 defaultGateway6 = { address = "fe80::1"; interface = "eth0"; };
67 "2a01:4f8:0:a0a1::add:1010"
68 "2a01:4f8:0:a102::add:9999"
69 "2a01:4f8:0:a111::add:9898"
73 myServices.ssh.modules.regular.snippet = builtins.readFile ./ssh_ldap_regular.sh;
76 secrets.nixosModules.users-config-dilion
81 myServices.vms.libvirt-guests = {
88 destroyVolumeOnExit = true;
91 myServices.vms.libvirt-images = {
92 nixos = ./vms/base_configuration.nix;
93 buildbot = ./vms/buildbot_configuration.nix;
95 myServices.vms.libvirt-networks.immae = {
97 ipRange = "192.168.100";
99 myServices.vms.libvirt-pools = {
102 target = "/etc/libvirtd/base-images";
104 buildbot-disks = rec {
106 target = "/var/lib/libvirt/images/buildbot-disks";
112 # pool-define-as --name zfspool --source-name zpool/libvirt --type zfs
116 <name>zpool/libvirt</name>
122 system.nssModules = [ pkgs.libvirt ];
123 system.nssDatabases.hosts = lib.mkForce [ "files" "libvirt_guest" "mymachines" "dns" "myhostname" ];
124 programs.zsh.enable = true;
126 users.users.libvirt = {
127 hashedPassword = "!";
128 shell = pkgs.bashInteractive;
131 packages = [ pkgs.libressl.nc ];
132 openssh.authorizedKeys.keys = [
133 config.myEnv.buildbot.ssh_key.public
134 config.myEnv.sshd.rootKeys.ismael_flony
138 users.groups.backup = {};
139 users.users.backup = {
140 hashedPassword = "!";
142 extraGroups = [ "keys" ];
144 shell = pkgs.bashInteractive;
145 openssh.authorizedKeys.keys = let
146 zreplConfig = "/etc/zrepl/zrepl.yml";
148 ["command=\"${pkgs.zrepl}/bin/zrepl stdinserver --config ${zreplConfig} eldiron\",restrict ${config.myEnv.zrepl_backup.ssh_key.public}"];
150 security.sudo.extraRules = pkgs.lib.mkAfter [
153 { command = "/home/immae/.nix-profile/root_scripts/*"; options = [ "NOPASSWD" ]; }
160 virtualisation.docker.enable = true;
161 virtualisation.docker.storageDriver = "zfs";
162 virtualisation.libvirtd.enable = true;
163 virtualisation.libvirtd.qemu.package = pkgs-no-overlay.qemu;
164 systemd.services.libvirtd.path = lib.mkAfter [ config.boot.zfs.package ];
165 users.groups.immae = {};
166 users.extraUsers.immae.extraGroups = [ "immae" "libvirtd" "docker" ];
167 systemd.services.libvirtd.postStart = ''
168 install -m 0770 -g libvirtd -d /var/lib/libvirt/images
171 time.timeZone = "Europe/Paris";
176 substituters = [ "https://hydra.iohk.io" "https://cache.nixos.org" ];
177 trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
178 trusted-users = [ "root" "@wheel"] ;
182 keep-derivations = true
183 allow-unsafe-native-code-during-evaluation = true
184 experimental-features = nix-command flakes
186 allow-import-from-derivation = true
190 security.pki.certificateFiles = [
192 url = "http://downloads.e.eriomem.net/eriomemca.pem";
193 sha256 = "1ixx4c6j3m26j8dp9a3dkvxc80v1nr5aqgmawwgs06bskasqkvvh";
197 myServices.monitoring.enable = true;
198 security.acme.certs."${name}-immae" = {
200 domain = "dilion.immae.eu";
202 security.acme.certs."${name}" = {
203 group = config.services.nginx.group;
208 systemd.services.nginx.serviceConfig.ProtectHome = "read-only";
211 recommendedOptimisation = true;
212 recommendedGzipSettings = true;
213 recommendedProxySettings = true;
215 "dilion.immae.dev" = {
216 acmeRoot = config.security.acme.defaults.webroot;
219 locations."/".root = "/home/immae/www";
225 "zrepl/${name}.key" = {
226 permissions = "0400";
227 text = config.myEnv.zrepl_backup.certs."${name}".key;
231 } // builtins.listToAttrs (map (x: lib.attrsets.nameValuePair "zrepl/certificates/${x}.crt" {
232 permissions = "0400";
233 text = config.myEnv.zrepl_backup.certs."${x}".certificate;
236 }) (builtins.attrNames config.myEnv.zrepl_backup.certs));
238 environment.etc."mdadm.conf" = {
242 text = "MAILADDR ${config.myEnv.monitoring.email}";
246 systemd.services.zrepl.serviceConfig.User = "backup";
247 systemd.services.zrepl.path = [ pkgs.openssh ];
249 # zfs allow backup create,mount,receive,destroy,rename,snapshot,hold,bookmark,release zpool/backup
251 # zfs allow backup hold,release,bookmark,snapshot,send zpool
255 global.control.sockpath = "/run/zrepl/control";
256 global.serve.stdinserver.sockdir = "/run/zrepl/stdinserver";
261 name = "backup-from-eldiron";
262 root_fs = "zpool/backup";
264 serve.listen = ":19000";
265 serve.ca = config.secrets.fullPaths."zrepl/certificates/eldiron.crt";
266 serve.cert = config.secrets.fullPaths."zrepl/certificates/dilion.crt";
267 serve.key = config.secrets.fullPaths."zrepl/dilion.key";
268 serve.client_cns = [ "eldiron" ];
273 name = "backup-to-wd-zpool";
276 serve.listen = ":19001";
277 serve.ca = config.secrets.fullPaths."zrepl/certificates/flony.crt";
278 serve.cert = config.secrets.fullPaths."zrepl/certificates/dilion.crt";
279 serve.key = config.secrets.fullPaths."zrepl/dilion.key";
280 serve.client_cns = [ "flony" ];
281 filesystems."zpool/libvirt<" = true;
282 filesystems."zpool/root<" = true;
283 snapshotting.type = "manual";
288 name = "backup-to-wd-zpool-docker";
291 serve.listen = ":19002";
292 serve.ca = config.secrets.fullPaths."zrepl/certificates/flony.crt";
293 serve.cert = config.secrets.fullPaths."zrepl/certificates/dilion.crt";
294 serve.key = config.secrets.fullPaths."zrepl/dilion.key";
295 serve.client_cns = [ "flony" ];
296 filesystems."zpool/docker<" = true;
297 snapshotting.type = "manual";
302 # This value determines the NixOS release with which your system is
303 # to be compatible, in order to avoid breaking some software such as
304 # database servers. You should change this only after NixOS release
305 # notes say you should.
306 # https://nixos.org/nixos/manual/release-notes.html
307 system.stateVersion = "23.05"; # Did you read the comment?