summary refs log tree commit diff
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-10-22 17:49:08 +0200
committerMel <einebeere@gmail.com>2024-10-22 17:49:08 +0200
commitdd47581a5f347ec8070abbd5eee690d599ee95ed (patch)
tree25504e4d96719739773929f7edc2b3c4d91a499f
parentc8a01f9753cc0c074c08855c9a2cb87ed75f369c (diff)
downloadminerals-dd47581a5f347ec8070abbd5eee690d599ee95ed.tar.zst
minerals-dd47581a5f347ec8070abbd5eee690d599ee95ed.zip
Create nix store binary cache from bismuth for slower machines
Signed-off-by: Mel <einebeere@gmail.com>
-rw-r--r--flake.nix4
-rw-r--r--machines/bismuth/default.nix8
-rw-r--r--modules/common.nix10
3 files changed, 19 insertions, 3 deletions
diff --git a/flake.nix b/flake.nix
index 0d04ff9..7075583 100644
--- a/flake.nix
+++ b/flake.nix
@@ -32,7 +32,9 @@
       (machine: nixpkgs.lib.nixosSystem {
         inherit system;
 
-        specialArgs = inputs // packageSets;
+        specialArgs = inputs // packageSets // {
+          me = machine;
+        };
 
         modules = [
           ./machines/${machine}
diff --git a/machines/bismuth/default.nix b/machines/bismuth/default.nix
index 8dbdd14..2663703 100644
--- a/machines/bismuth/default.nix
+++ b/machines/bismuth/default.nix
@@ -13,6 +13,14 @@
 
   networking.hostName = "Bismuth";
 
+  # run binary cache for slower machines
+  services.nix-serve = {
+    enable = true;
+    # note: can we get this value from somewhere?
+    bindAddress = "100.85.58.31"; # bismuth tailnet ip
+    secretKeyFile = "/var/bismuth-cache.pem";
+  };
+
   # expose vm web interface to tailnet
   services.tailscale.extraUpFlags = [
     "--advertise-routes=192.168.122.100/32"
diff --git a/modules/common.nix b/modules/common.nix
index e7de738..f586579 100644
--- a/modules/common.nix
+++ b/modules/common.nix
@@ -1,4 +1,4 @@
-{ config, pkgs, unstablePkgs, auxiliaryPkgs, ... }:
+{ me, config, lib, pkgs, unstablePkgs, auxiliaryPkgs, ... }:
 
 {
   imports = [
@@ -13,7 +13,13 @@
 
   boot.kernelPackages = pkgs.linuxPackages_latest;
 
-  nix.settings.experimental-features = [ "flakes" "nix-command" ];
+  nix.settings = {
+    experimental-features = [ "flakes" "nix-command" ];
+  } // lib.optionalAttrs (me != "bismuth") {
+    # add the bismuth binary cache, if we're not bismuth;
+    substituters = [ "http://bismuth:5000" ];
+    trusted-public-keys = [ "bismuth-1:XW9nsNsccipbmdfchyb3YIIWNT058iSpHLwlj1xgB7A=" ];
+  };
 
   services.envfs.enable = true;
   virtualisation.libvirtd.enable = true;