]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Configure nginx and containers / virtualisation for zoldene
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 10 Feb 2024 23:28:56 +0000 (00:28 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 24 Feb 2024 11:22:45 +0000 (12:22 +0100)
deploy/flake.lock
flake.lock
flakes/flake.lock
systems/zoldene/base.nix
systems/zoldene/certificates.nix [new file with mode: 0644]
systems/zoldene/flake.nix
systems/zoldene/virtualisation.nix [new file with mode: 0644]

index 74f3cb350b0753f957474e7a502ae5d5df6408de..711f7ea578143cf5919c86ea729c711040351b84 100644 (file)
       },
       "locked": {
         "lastModified": 1,
-        "narHash": "sha256-JZAb5V2upUFe8gDKiHtA0iksciLTuZgtLikxZpE2ZkY=",
+        "narHash": "sha256-On+vOgbdQGNAUM9YxLHmju3ci2yvD5Us4pVLGMAIUw4=",
         "path": "../flakes",
         "type": "path"
       },
       },
       "locked": {
         "lastModified": 1,
-        "narHash": "sha256-/H0YNxn7csP3GR/5e5DSv5FLAK8VBCySiyGXch+ykMg=",
+        "narHash": "sha256-26XpjFSVM3B3k2dsnmGGLwUwctJPaGiCr0u2I6MaXFA=",
         "path": "../systems/zoldene",
         "type": "path"
       },
         "nixpkgs": "nixpkgs_106"
       },
       "locked": {
-        "lastModified": 1700953172,
-        "narHash": "sha256-KcFb43yLFsVOMevka1G2ddTE5JFsS72h+6XfjO7ivAs=",
+        "lastModified": 1708773401,
+        "narHash": "sha256-5UeCrBFAypxoiJ3TkmtXw40g1durDVV6AiPmzaumeQk=",
         "ref": "master",
-        "rev": "4518b25634f2274d2a65bf5bfc4c78c4ab450787",
-        "revCount": 715,
+        "rev": "890a76ab7f560b8a8d547d2066fe5e10083b0689",
+        "revCount": 721,
         "type": "git",
         "url": "git+ssh://gitolite@git.immae.eu/perso/Immae/Config/Nix/Nixops/Secrets"
       },
index 19de0cb77dc3fff7653a5b04a67233431d09cee1..2b6bd189dceea773edaa700f9ccfaa104f04f7b3 100644 (file)
       },
       "locked": {
         "lastModified": 1,
-        "narHash": "sha256-JZAb5V2upUFe8gDKiHtA0iksciLTuZgtLikxZpE2ZkY=",
+        "narHash": "sha256-On+vOgbdQGNAUM9YxLHmju3ci2yvD5Us4pVLGMAIUw4=",
         "path": "./flakes",
         "type": "path"
       },
       },
       "locked": {
         "lastModified": 1,
-        "narHash": "sha256-/H0YNxn7csP3GR/5e5DSv5FLAK8VBCySiyGXch+ykMg=",
+        "narHash": "sha256-26XpjFSVM3B3k2dsnmGGLwUwctJPaGiCr0u2I6MaXFA=",
         "path": "../systems/zoldene",
         "type": "path"
       },
index 051086e95042d7f5a0f6e178c22d25af14a57f17..f4e88e4d8a717305f76982a272edd1ffc290d648 100644 (file)
       },
       "locked": {
         "lastModified": 1,
-        "narHash": "sha256-/H0YNxn7csP3GR/5e5DSv5FLAK8VBCySiyGXch+ykMg=",
+        "narHash": "sha256-26XpjFSVM3B3k2dsnmGGLwUwctJPaGiCr0u2I6MaXFA=",
         "path": "../systems/zoldene",
         "type": "path"
       },
index 8ca5d52df8203ea94d013a2233090b337dc7293f..2c0a4611b66c20a2cd8269ede3777ecadde85861 100644 (file)
@@ -1,4 +1,4 @@
-{ name, config, lib, pkgs, secrets, ... }:
+{ name, config, lib, pkgs, secrets, pkgs-no-overlay, ... }:
 let
   # udev rules to be able to boot from qemu in a rescue
   udev-qemu-rules =
@@ -9,6 +9,12 @@ let
     '') (builtins.attrNames disks));
 in
 {
+  imports = [
+    secrets.nixosModules.users-config-zoldene
+    ./virtualisation.nix
+    ./certificates.nix
+  ];
+
   services.openssh = {
     settings.KbdInteractiveAuthentication = false;
     hostKeys = [
@@ -119,4 +125,6 @@ in
   secrets.decryptKey = "/persist/zpool/etc/ssh/ssh_host_ed25519_key";
   # ssh-keyscan zoldene | nix-shell -p ssh-to-age --run ssh-to-age
   secrets.ageKeys = [ "age1rqr7qdpjm8fy9nf3x07fa824v87n40g0ljrgdysuayuklnvhcynq4c8en8" ];
+
+
 }
diff --git a/systems/zoldene/certificates.nix b/systems/zoldene/certificates.nix
new file mode 100644 (file)
index 0000000..d6ffd12
--- /dev/null
@@ -0,0 +1,23 @@
+{ ... }:
+{
+  disko.devices.zpool.zfast.datasets."root/persist/var/lib/acme" =
+    { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/acme"; options.mountpoint = "legacy"; };
+
+  environment.persistence."/persist/zfast".directories = [
+    {
+      directory = "/var/lib/acme";
+      user = "root";
+      group = "root";
+      mode = "0755";
+    }
+  ];
+
+  users.users.nginx.extraGroups = [ "acme" ];
+  services.nginx = {
+    enable = true;
+    recommendedOptimisation = true;
+    recommendedGzipSettings = true;
+    recommendedProxySettings = true;
+  };
+
+}
index 42466e81e8bf35b0714fa1c43ecc545436bc9bcc..7b7b4b768713b38fdcd013c7e33460d65d495a9b 100644 (file)
@@ -14,6 +14,9 @@
       system = "x86_64-linux";
       targetHost = "88.198.39.152";
       targetUser = "root";
+      moduleArgs = {
+        pkgs-no-overlay = inputs.nixpkgs.legacyPackages.x86_64-linux;
+      };
       nixosModules = with inputs; {
         impermanence = impermanence.nixosModule;
         base = ./base.nix;
diff --git a/systems/zoldene/virtualisation.nix b/systems/zoldene/virtualisation.nix
new file mode 100644 (file)
index 0000000..d2212fe
--- /dev/null
@@ -0,0 +1,46 @@
+{ pkgs-no-overlay, ... }:
+{
+  boot.kernelModules = [ "nf_nat_ftp" ];
+
+  ### Enable Docker
+  virtualisation.docker.enable = true;
+  disko.devices.zpool.zfast.datasets."root/persist/var/lib/docker" =
+    { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/docker"; options.mountpoint = "legacy"; };
+
+  ### Enable LXC
+  disko.devices.zpool.zfast.datasets."root/persist/var/lib/lxc" =
+    { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/lxc"; options.mountpoint = "legacy"; };
+  virtualisation.lxc = {
+    enable = true;
+    lxcfs.enable = true;
+  };
+
+  ### Enable libvirtd
+  virtualisation.libvirtd = {
+    enable = true;
+    qemu.package = pkgs-no-overlay.qemu;
+  };
+
+  ### Persistence for LXC / Docker
+  environment.persistence."/persist/zfast".directories = [
+    {
+      directory = "/var/lib/lxc";
+      user = "root";
+      group = "root";
+      mode = "0755";
+    }
+    {
+      directory = "/var/lib/docker";
+      user = "root";
+      group = "root";
+      mode = "0750";
+    }
+  ];
+
+  # ip forwarding is needed for NAT'ing to work in containers/VMs.
+  boot.kernel.sysctl = {
+    "net.ipv4.conf.all.forwarding" = true;
+    "net.ipv4.conf.default.forwarding" = true;
+  };
+}
+