Commit 47148c9

HPCesia <me@hpcesia.com>
2026-07-12 06:45:39
Use NCRO for binary cache substituters
1 parent 9621339
Changed files (5)
modules/core/nix/nix.nix
@@ -24,22 +24,6 @@
         trusted-users = ["@wheel"];
 
         flake-registry = "";
-
-        substituters = [
-          # Official cache's mirrors located in China
-          "https://mirrors.ustc.edu.cn/nix-channels/store?priority=10"
-          "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store?priority=10"
-          # Official cache
-          "https://nix-community.cachix.org?priority=11"
-
-          # Nixpkgs with CUDA enabled cache
-          "https://cache.flox.dev?priority=20"
-        ];
-        trusted-public-keys = [
-          "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
-
-          "flox-cache-public-1:7F4OyH7ZCnFhcze3fJdfyXYLQw/aV7GEed86nQ7IsOs="
-        ];
       };
       nix.channel.enable = false;
 
modules/core/nix/substituters.nix
@@ -0,0 +1,71 @@
+{
+  inputs,
+  lib,
+  ...
+}: {
+  flake-file.inputs.ncro = {
+    url = "github:manic-systems/ncro";
+    inputs.nixpkgs.follows = "nixpkgs";
+  };
+
+  den.aspects.core.nix.substituters = {
+    cache = {
+      directories = [
+        {
+          directory = "/var/lib/private/ncro";
+          user = "nobody";
+          group = "nogroup";
+        }
+      ];
+    };
+
+    nixos = {config, ...}: {
+      imports = [inputs.ncro.nixosModules.ncro];
+
+      nix.settings = {
+        substituters = lib.mkForce ["http://${config.services.ncro.settings.server.listen}"];
+        trusted-public-keys = [
+        ];
+      };
+
+      services.ncro = {
+        enable = true;
+        settings = {
+          server = {
+            listen = "localhost:9000";
+            read_timeout = "15s";
+            write_timeout = "15s";
+          };
+          cache = {
+            db_path = "/var/lib/ncro/routes.db";
+          };
+          upstreams = [
+            {
+              url = "https://cache.nixos.org";
+              priority = 15;
+              public_key = "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=";
+            }
+            {
+              url = "https://nix-community.cachix.org";
+              priority = 20;
+              public_key = "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=";
+            }
+            {
+              url = "https://mirrors.ustc.edu.cn/nix-channels/store";
+              priority = 10;
+            }
+            {
+              url = "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store";
+              priority = 10;
+            }
+            {
+              url = "https://cache.flox.dev";
+              priority = 30;
+              public_key = "flox-cache-public-1:7F4OyH7ZCnFhcze3fJdfyXYLQw/aV7GEed86nQ7IsOs=";
+            }
+          ];
+        };
+      };
+    };
+  };
+}
modules/roles/default.nix
@@ -6,6 +6,7 @@
       core.nix.nh
       core.nix.nixpkgs
       core.nix.state-versions
+      core.nix.substituters
       core.nix.tokens
 
       core.hardware.cpu.intel
flake.lock
@@ -323,6 +323,26 @@
         "type": "github"
       }
     },
+    "ncro": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1783665058,
+        "narHash": "sha256-WNl+0YP4/XCshpj5c0ZYNBuTzg/bLIaLcf7qtxrLIfU=",
+        "owner": "manic-systems",
+        "repo": "ncro",
+        "rev": "eec6c0ed0577312779b0842d8c15cce8fd4dcbc9",
+        "type": "github"
+      },
+      "original": {
+        "owner": "manic-systems",
+        "repo": "ncro",
+        "type": "github"
+      }
+    },
     "nix-flatpak": {
       "locked": {
         "lastModified": 1780908363,
@@ -453,6 +473,7 @@
         "impermanence": "impermanence",
         "import-tree": "import-tree",
         "llm-agents": "llm-agents",
+        "ncro": "ncro",
         "nix-flatpak": "nix-flatpak",
         "nixpkgs": "nixpkgs",
         "noctalia": "noctalia",
flake.nix
@@ -47,6 +47,10 @@
         nixpkgs.follows = "nixpkgs";
       };
     };
+    ncro = {
+      url = "github:manic-systems/ncro";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
     nix-flatpak.url = "github:gmodena/nix-flatpak";
     nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
     noctalia = {