ctucx.git: nixfiles

ctucx' nixfiles

commit 1c0ea98ef0b305c1be628daec41636cb1ae09aa6
parent dc55b60c17af9e5b8ad39eb39e98cbbac0871f3e
Author: Leah (ctucx) <git@ctu.cx>
Date: Tue, 13 Dec 2022 16:39:05 +0100

machines/lollo/router/dnsmasq: update dnsmqas-lease-overview
3 files changed, 46 insertions(+), 31 deletions(-)
M
flake.lock
|
33
+++++++++++++++++++++++++++++----
M
flake.nix
|
9
+++++++++
M
machines/lollo/router/dnsmasq.nix
|
35
++++++++---------------------------
diff --git a/flake.lock b/flake.lock
@@ -153,6 +153,30 @@
         "url": "https://git.ctu.cx/dns.nix"
       }
     },
+    "dnsmasq-lease-overview": {
+      "inputs": {
+        "flake-utils": [
+          "flake-utils"
+        ],
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1670773730,
+        "narHash": "sha256-DfYBGo/sXF7mPvBeFm3cYY7/V1zrDOMG/jywcuquySk=",
+        "ref": "master",
+        "rev": "72781d18c7f591dc0d166a5b1972645a10630313",
+        "revCount": 3,
+        "type": "git",
+        "url": "https://git.ctu.cx/dnsmasq-lease-overview"
+      },
+      "original": {
+        "ref": "master",
+        "type": "git",
+        "url": "https://git.ctu.cx/dnsmasq-lease-overview"
+      }
+    },
     "flake-compat": {
       "flake": false,
       "locked": {

@@ -355,11 +379,11 @@
         ]
       },
       "locked": {
-        "lastModified": 1670690187,
-        "narHash": "sha256-33AkyEzx5pVzXmhCADjYz158unykApRCJT2iP3arSAY=",
+        "lastModified": 1670944808,
+        "narHash": "sha256-NRj7wq9khChJUCf8MXcH1BHaKvdpv9MFUXbG2kY/c1c=",
         "ref": "master",
-        "rev": "c4bfefbe834e879679d4b7e69cc73c6790aa2df2",
-        "revCount": 180,
+        "rev": "0f0b70aed5014799e20bdcbe328d413c99cd922e",
+        "revCount": 18,
         "type": "git",
         "url": "https://git.ctu.cx/mqtt-webui"
       },

@@ -530,6 +554,7 @@
         "ctucx-things": "ctucx-things",
         "darwin": "darwin",
         "dns-nix": "dns-nix",
+        "dnsmasq-lease-overview": "dnsmasq-lease-overview",
         "flake-utils": "flake-utils_3",
         "flauschehorn-sexy": "flauschehorn-sexy",
         "gpx-map": "gpx-map",
diff --git a/flake.nix b/flake.nix
@@ -29,6 +29,7 @@
       inputs.oeffisearch.overlay
       inputs.oeffi-web.overlay
 
+      inputs.dnsmasq-lease-overview.overlay
       inputs.flauschehorn-sexy.overlay
     ];
 

@@ -232,6 +233,14 @@
       inputs.flake-utils.follows = "flake-utils";
     };
 
+    dnsmasq-lease-overview = {
+      type  = "git";
+      url   = "https://git.ctu.cx/dnsmasq-lease-overview";
+      ref   = "master";
+      inputs.nixpkgs.follows     = "nixpkgs";
+      inputs.flake-utils.follows = "flake-utils";
+    };
+
     local-secrets.url = "/tmp/nix-secrets";
   };
 
diff --git a/machines/lollo/router/dnsmasq.nix b/machines/lollo/router/dnsmasq.nix
@@ -1,13 +1,6 @@
 { config, pkgs, ... }:
 
-let
-  dnsmasq-lease-overview = pkgs.fetchgit {
-    url    = "https://cgit.ctu.cx/dnsmasq-lease-overview/";
-    rev    = "84c47b17361fd3273f5d7902a407d467ae937cfd";
-    sha256 = "1vs589r2ff31lf8wp4kh84ckzfd72wc1bxjf7kxwl8sgm18rijnp";
-  };
-
-in {
+{
 
   dns.zones."ctu.cx".subdomains = with pkgs.dns.lib.combinators; {
     home.NS   = [ "home.ctu.cx." ];

@@ -104,19 +97,7 @@ in {
       '';
     };
 
-    phpfpm.pools.dnsmasq  = {
-      user  = "dnsmasq";
-      group = "dnsmasq";
-      settings = {
-        pm                     = "dynamic";
-        "listen.owner"         = config.services.nginx.user;
-        "pm.max_children"      = 1;
-        "pm.start_servers"     = 1;
-        "pm.min_spare_servers" = 1;
-        "pm.max_spare_servers" = 1;
-        "pm.max_requests"      = 500;
-      };
-    };
+    fcgiwrap.enable = true;
 
     nginx = {
       enable = true;

@@ -124,13 +105,13 @@ in {
         enableACME = true;
         forceSSL   = true;
         kTLS       = true;
-        root       = dnsmasq-lease-overview;
         locations  = {
-          "/".tryFiles           = "$uri $uri/ /index.php?$query_string";
-          "/".index              = "index.php index.html";
-          "~ \.php$".extraConfig = ''
-            fastcgi_pass  unix:${config.services.phpfpm.pools.dnsmasq.socket};
-            fastcgi_index index.php;
+          "/".extraConfig = ''
+            include "${pkgs.nginx}/conf/fastcgi_params";
+            fastcgi_param SCRIPT_FILENAME "${pkgs.dnsmasq-lease-overview}/bin/overview";
+            fastcgi_param LEASE_PATH      "/var/lib/dnsmasq/dnsmasq.leases";
+            fastcgi_param QUERY_STRING    $args;
+            fastcgi_pass  unix:${config.services.fcgiwrap.socketAddress};
           '';
         };
       };