about summary refs log tree commit diff
path: root/nixos/kanata/configuration.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/kanata/configuration.nix')
-rw-r--r--nixos/kanata/configuration.nix83
1 files changed, 43 insertions, 40 deletions
diff --git a/nixos/kanata/configuration.nix b/nixos/kanata/configuration.nix
index a5ed1be..32e4cee 100644
--- a/nixos/kanata/configuration.nix
+++ b/nixos/kanata/configuration.nix
@@ -62,7 +62,7 @@ in
 
   modules.tailscale-initrd = {
     enable = true;
-    # XXX: This has to be manually generatd during NixOS install.
+    # XXX: This has to be manually generated during NixOS install.
     # The files are then copied to initrd secrets during activation.
     tailscaleStatePath = "/persist/initrd/tailscale-initrd.state";
   };
@@ -70,22 +70,6 @@ in
   services.openssh.enable = true;
   users.users.root.openssh.authorizedKeys.keys = maintainerKeys;
 
-  # NOTE: managed by modules.persistence
-  # TODO: remove?
-  # fileSystems."/persist".neededForBoot = true;
-  #
-  # services.openssh.hostKeys = [
-  #   {
-  #     path = "/persist/ssh/ssh_host_ed25519_key";
-  #     type = "ed25519";
-  #   }
-  #   {
-  #     path = "/persist/ssh/ssh_host_rsa_key";
-  #     type = "rsa";
-  #     bits = 4096;
-  #   }
-  # ];
-
   sops.defaultSopsFile = ./secrets/secrets.yaml;
 
   powerManagement.cpuFreqGovernor = "ondemand";
@@ -118,6 +102,46 @@ in
     enableIPv6 = true;
   };
 
+  services.nscd = {
+    enable = true;
+    config = ''
+      # We basically use nscd as a proxy for forwarding nss requests to appropriate
+      # nss modules, as we run nscd with LD_LIBRARY_PATH set to the directory
+      # containing all such modules
+      # Note that we can not use `enable-cache no` As this will actually cause nscd
+      # to just reject the nss requests it receives, which then causes glibc to
+      # fallback to trying to handle the request by itself. Which won't work as glibc
+      # is not aware of the path in which the nss modules live.  As a workaround, we
+      # have `enable-cache yes` with an explicit ttl of 0
+      server-user             nscd
+
+      enable-cache            passwd          yes
+      positive-time-to-live   passwd          0
+      negative-time-to-live   passwd          0
+      shared                  passwd          yes
+
+      enable-cache            group           yes
+      positive-time-to-live   group           0
+      negative-time-to-live   group           0
+      shared                  group           yes
+
+      enable-cache            netgroup        yes
+      positive-time-to-live   netgroup        0
+      negative-time-to-live   netgroup        0
+      shared                  netgroup        yes
+
+      enable-cache            hosts           yes
+      positive-time-to-live   hosts           3600 # Invidious spams DNS queries to PubSubHubBub
+      negative-time-to-live   hosts           0
+      shared                  hosts           yes
+
+      enable-cache            services        yes
+      positive-time-to-live   services        0
+      negative-time-to-live   services        0
+      shared                  services        yes
+    '';
+  };
+
   services.tailscale = {
     enable = true;
     useRoutingFeatures = "both";
@@ -136,6 +160,7 @@ in
   networking.firewall.allowedTCPPorts = [ 80 443 ];
   modules = {
     persistence.directories = [
+      "/var/lib/nixos"
       "/var/lib/tailscale"
       "/var/lib/nixos-containers"
     ];
@@ -143,6 +168,7 @@ in
     persistence = {
       enable = true;
       storagePath = "/persist";
+      setupSshHostKeys = true;
     };
 
     # NOTE: This module only populates route entries,
@@ -285,29 +311,6 @@ in
     };
   };
 
-  services.changedetection-io = {
-    enable = true;
-
-    listenAddress = "localhost";
-    port = 4901;
-
-    baseURL = "https://change.labs.kusanari.network";
-    behindProxy = true;
-    webDriverSupport = true;
-  };
-
-  services.nginx.virtualHosts."change.labs.kusanari.network".locations."/" = {
-    proxyWebsockets = true;
-    extraConfig = ''
-      proxy_redirect off;
-      proxy_set_header Host $host;
-      proxy_set_header X-Real-IP $remote_addr;
-      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-      proxy_set_header X-Forwarded-Proto $scheme;
-      proxy_set_header Referer "https://change.labs.kusanari.network";
-    '';
-  };
-
   containers.v-interlink = {
     autoStart = true;
     enableTun = true;