diff options
Diffstat (limited to 'modules/private/system/dilion.nix')
-rw-r--r-- | modules/private/system/dilion.nix | 242 |
1 files changed, 0 insertions, 242 deletions
diff --git a/modules/private/system/dilion.nix b/modules/private/system/dilion.nix deleted file mode 100644 index fa92cd9..0000000 --- a/modules/private/system/dilion.nix +++ /dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | { config, pkgs, name, lib, ... }: | ||
2 | { | ||
3 | deployment = { | ||
4 | targetUser = "root"; | ||
5 | targetHost = config.hostEnv.ips.main.ip4; | ||
6 | substituteOnDestination = true; | ||
7 | }; | ||
8 | # ssh-keyscan dilion | nix-shell -p ssh-to-age --run ssh-to-age | ||
9 | secrets.ageKeys = [ "age1x49n6qa0arkdpq8530s7umgm0gqkq90exv4jep97q30rfnzknpaqate06a" ]; | ||
10 | nixpkgs.system = lib.mkOverride 900 "x86_64-linux"; | ||
11 | boot = { | ||
12 | loader = { | ||
13 | grub = { | ||
14 | version = 2; | ||
15 | devices = [ "/dev/sda" "/dev/sdb" "/dev/sdc" "/dev/sdd" ]; | ||
16 | }; | ||
17 | timeout = 1; | ||
18 | }; | ||
19 | blacklistedKernelModules = [ "nvidiafb" ]; | ||
20 | supportedFilesystems = [ "zfs" ]; | ||
21 | kernelPackages = pkgs.linuxPackages_latest; | ||
22 | kernelModules = [ "kvm-intel" ]; | ||
23 | initrd.availableKernelModules = [ "ahci" "sd_mod" ]; | ||
24 | initrd.secrets = { | ||
25 | "/boot/pass.key" = "/boot/pass.key"; | ||
26 | }; | ||
27 | kernel.sysctl."vm.nr_hugepages" = 256; # for xmr-stak | ||
28 | # available in nixos-20.09 | ||
29 | #zfs.requestEncryptionCredentials = [ "zpool/root" ]; | ||
30 | }; | ||
31 | nix.maxJobs = 8; | ||
32 | powerManagement.cpuFreqGovernor = "powersave"; | ||
33 | hardware.enableRedistributableFirmware = true; | ||
34 | |||
35 | myEnv = import ../../../nixops/secrets/environment.nix; | ||
36 | |||
37 | swapDevices = [ { label = "swap"; } ]; | ||
38 | fileSystems = { | ||
39 | "/" = { fsType = "zfs"; device = "zpool/root"; }; | ||
40 | "/boot" = { fsType = "ext4"; device = "/dev/disk/by-uuid/fd1c511e-2bc0-49d5-b8bb-95e7e8c8c816"; }; | ||
41 | "/etc" = { fsType = "zfs"; device = "zpool/root/etc"; }; | ||
42 | "/home" = { fsType = "zfs"; device = "zpool/root/home"; }; | ||
43 | "/home/immae" = { fsType = "zfs"; device = "zpool/root/home/immae"; }; | ||
44 | "/tmp" = { fsType = "zfs"; device = "zpool/root/tmp"; }; | ||
45 | "/var" = { fsType = "zfs"; device = "zpool/root/var"; }; | ||
46 | "/data" = { fsType = "ext4"; label = "data"; }; | ||
47 | "/nix" = { fsType = "ext4"; label = "nix"; }; | ||
48 | }; | ||
49 | |||
50 | services.udev.extraRules = '' | ||
51 | ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="10:bf:48:7f:e6:3b", NAME="eth0" | ||
52 | ''; | ||
53 | |||
54 | networking = { | ||
55 | hostId = "27c3048d"; # generated with head -c4 /dev/urandom | od -A none -t x4 | ||
56 | firewall.enable = false; | ||
57 | interfaces."eth0".ipv4.addresses = | ||
58 | [ { address = config.hostEnv.ips.main.ip4; prefixLength = 27; } ] | ||
59 | ++ pkgs.lib.attrsets.mapAttrsToList | ||
60 | (n: ips: { address = ips.ip4; prefixLength = 32; }) | ||
61 | (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips); | ||
62 | interfaces."eth0".ipv6.addresses = | ||
63 | [ { address = "2a01:4f8:141:53e7::"; prefixLength = 64; } ] | ||
64 | ++ pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList | ||
65 | (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) | ||
66 | config.hostEnv.ips); | ||
67 | defaultGateway = { address = "176.9.10.225"; interface = "eth0"; }; | ||
68 | defaultGateway6 = { address = "fe80::1"; interface = "eth0"; }; | ||
69 | nameservers = [ | ||
70 | "213.133.98.98" | ||
71 | "213.133.99.99" | ||
72 | "213.133.100.100" | ||
73 | "2a01:4f8:0:a0a1::add:1010" | ||
74 | "2a01:4f8:0:a102::add:9999" | ||
75 | "2a01:4f8:0:a111::add:9898" | ||
76 | ]; | ||
77 | }; | ||
78 | |||
79 | myServices.ssh.modules = [ config.myServices.ssh.predefinedModules.regular ]; | ||
80 | imports = builtins.attrValues (import ../..) ++ [ ./dilion/vms.nix ]; | ||
81 | |||
82 | system.nssModules = [ pkgs.libvirt ]; | ||
83 | system.nssDatabases.hosts = lib.mkForce [ "files" "libvirt_guest" "mymachines" "dns" "myhostname" ]; | ||
84 | programs.zsh.enable = true; | ||
85 | |||
86 | users.users.libvirt = { | ||
87 | hashedPassword = "!"; | ||
88 | shell = pkgs.bashInteractive; | ||
89 | isSystemUser = true; | ||
90 | group = "libvirtd"; | ||
91 | packages = [ pkgs.netcat-openbsd ]; | ||
92 | openssh.authorizedKeys.keys = [ | ||
93 | config.myEnv.buildbot.ssh_key.public | ||
94 | config.myEnv.sshd.rootKeys.ismael_flony | ||
95 | ]; | ||
96 | }; | ||
97 | |||
98 | users.users.backup = { | ||
99 | hashedPassword = "!"; | ||
100 | isSystemUser = true; | ||
101 | extraGroups = [ "keys" ]; | ||
102 | shell = pkgs.bashInteractive; | ||
103 | openssh.authorizedKeys.keys = let | ||
104 | zreplConfig = config.secrets.fullPaths."zrepl/zrepl.yml"; | ||
105 | in | ||
106 | ["command=\"${pkgs.zrepl}/bin/zrepl stdinserver --config ${zreplConfig} eldiron\",restrict ${config.myEnv.zrepl_backup.ssh_key.public}"]; | ||
107 | }; | ||
108 | security.sudo.extraRules = pkgs.lib.mkAfter [ | ||
109 | { | ||
110 | commands = [ | ||
111 | { command = "/home/immae/.nix-profile/root_scripts/*"; options = [ "NOPASSWD" ]; } | ||
112 | ]; | ||
113 | users = [ "immae" ]; | ||
114 | runAs = "root"; | ||
115 | } | ||
116 | ]; | ||
117 | |||
118 | system.activationScripts.libvirtd_exports = '' | ||
119 | install -m 0755 -o root -g root -d /var/lib/caldance | ||
120 | ''; | ||
121 | virtualisation.docker.enable = true; | ||
122 | virtualisation.docker.storageDriver = "zfs"; | ||
123 | virtualisation.libvirtd.enable = true; | ||
124 | users.extraUsers.immae.extraGroups = [ "libvirtd" "docker" ]; | ||
125 | systemd.services.libvirtd.postStart = '' | ||
126 | install -m 0770 -g libvirtd -d /var/lib/libvirt/images | ||
127 | ''; | ||
128 | systemd.services.socat-caldance = { | ||
129 | description = "Forward ssh port to caldance"; | ||
130 | wantedBy = [ "multi-user.target" ]; | ||
131 | after = [ "network.target" ]; | ||
132 | |||
133 | serviceConfig = { | ||
134 | ExecStart = "${pkgs.socat}/bin/socat TCP-LISTEN:8022,fork TCP:caldance:22"; | ||
135 | }; | ||
136 | }; | ||
137 | |||
138 | time.timeZone = "Europe/Paris"; | ||
139 | nix = { | ||
140 | useSandbox = "relaxed"; | ||
141 | extraOptions = '' | ||
142 | keep-outputs = true | ||
143 | keep-derivations = true | ||
144 | allow-unsafe-native-code-during-evaluation = true | ||
145 | experimental-features = nix-command flakes | ||
146 | #Assumed in NUR | ||
147 | allow-import-from-derivation = true | ||
148 | ''; | ||
149 | }; | ||
150 | |||
151 | security.pki.certificateFiles = [ | ||
152 | (pkgs.fetchurl { | ||
153 | url = "http://downloads.e.eriomem.net/eriomemca.pem"; | ||
154 | sha256 = "1ixx4c6j3m26j8dp9a3dkvxc80v1nr5aqgmawwgs06bskasqkvvh"; | ||
155 | }) | ||
156 | ]; | ||
157 | |||
158 | # This is equivalent to setting environment.sessionVariables.NIX_PATH | ||
159 | nix.nixPath = [ | ||
160 | "home-manager=${pkgs.sources.home-manager.url}" | ||
161 | "nixpkgs=${pkgs.sources.nixpkgs-home-manager.url}" | ||
162 | ]; | ||
163 | nix.binaryCaches = [ "https://hydra.iohk.io" "https://cache.nixos.org" ]; | ||
164 | nix.binaryCachePublicKeys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ]; | ||
165 | |||
166 | myServices.monitoring.enable = true; | ||
167 | myServices.certificates.enable = true; | ||
168 | security.acme.certs."${name}-immae" = config.myServices.certificates.certConfig // { | ||
169 | user = "immae"; | ||
170 | domain = "dilion.immae.eu"; | ||
171 | }; | ||
172 | security.acme.certs."${name}" = { | ||
173 | user = config.services.nginx.user; | ||
174 | group = config.services.nginx.group; | ||
175 | extraDomains = { | ||
176 | "dilion.immae.dev" = null; | ||
177 | "caldance.cs.immae.dev" = null; | ||
178 | }; | ||
179 | }; | ||
180 | services.nginx = { | ||
181 | enable = true; | ||
182 | recommendedOptimisation = true; | ||
183 | recommendedGzipSettings = true; | ||
184 | recommendedProxySettings = true; | ||
185 | upstreams = { | ||
186 | caldance.servers."caldance:3031" = {}; | ||
187 | }; | ||
188 | virtualHosts = { | ||
189 | "dilion.immae.dev" = { | ||
190 | acmeRoot = config.myServices.certificates.webroot; | ||
191 | useACMEHost = name; | ||
192 | forceSSL = true; | ||
193 | root = "/home/immae/www"; | ||
194 | }; | ||
195 | "caldance.cs.immae.dev" = { | ||
196 | acmeRoot = config.myServices.certificates.webroot; | ||
197 | useACMEHost = name; | ||
198 | forceSSL = true; | ||
199 | locations."/".extraConfig = '' | ||
200 | uwsgi_pass caldance; | ||
201 | ''; | ||
202 | locations."/static/".alias = "/var/lib/caldance/caldance/app/www/static/"; | ||
203 | locations."/media/".alias = "/var/lib/caldance/caldance/media/"; | ||
204 | extraConfig = '' | ||
205 | auth_basic "Authentification requise"; | ||
206 | auth_basic_user_file ${pkgs.writeText "htpasswd" config.myEnv.websites.caldance.integration.password}; | ||
207 | ''; | ||
208 | }; | ||
209 | }; | ||
210 | }; | ||
211 | |||
212 | systemd.services.zrepl.serviceConfig.RuntimeDirectory = lib.mkForce "zrepl zrepl/stdinserver"; | ||
213 | systemd.services.zrepl.serviceConfig.User = "backup"; | ||
214 | # zfs allow backup create,mount,receive,destroy,rename,snapshot,hold,bookmark,release zpool/backup | ||
215 | services.zrepl = { | ||
216 | enable = true; | ||
217 | config = '' | ||
218 | global: | ||
219 | control: | ||
220 | sockpath: /run/zrepl/control | ||
221 | serve: | ||
222 | stdinserver: | ||
223 | sockdir: /run/zrepl/stdinserver | ||
224 | jobs: | ||
225 | - type: sink | ||
226 | # must not change | ||
227 | name: "backup-from-eldiron" | ||
228 | root_fs: "zpool/backup" | ||
229 | serve: | ||
230 | type: stdinserver | ||
231 | client_identities: | ||
232 | - eldiron | ||
233 | ''; | ||
234 | }; | ||
235 | # This value determines the NixOS release with which your system is | ||
236 | # to be compatible, in order to avoid breaking some software such as | ||
237 | # database servers. You should change this only after NixOS release | ||
238 | # notes say you should. | ||
239 | # https://nixos.org/nixos/manual/release-notes.html | ||
240 | system.stateVersion = "20.03"; # Did you read the comment? | ||
241 | } | ||
242 | |||