diff --git a/doc/integrations/cachix.md b/doc/integrations/cachix.md index de732dc7..3e4f3b5a 100644 --- a/doc/integrations/cachix.md +++ b/doc/integrations/cachix.md @@ -1,8 +1,13 @@ # Cachix -The cachix directory simple captures the output of `sudo cachix use` for the -developers personal cache, as well as the nix-community cache. You can easily -add your own cache, assuming the template lives in /etc/nixos, by simply -running `sudo cachix use yourcache`. +The system will automatically pull a cachix.nix at the root if one exists. +This is usually created automatically by a `sudo cachix use`. If your more +inclined to keep the root clean, you can drop any generated files in the +`cachix` directory into the `profiles/cachix` directory without further +modification. + +For example, to add your own cache, assuming the template lives in /etc/nixos, +by simply running `sudo cachix use yourcache`. Then, optionally, move +`cachix/yourcache.nix` to `profiles/cachix/yourcache.nix` These caches are only added to the system after a `nixos-rebuild switch`, so it is recommended to call `cachix use nrdxp` before the initial deployment, as it diff --git a/lib/devos/mkHosts.nix b/lib/devos/mkHosts.nix index 8a8abdb7..b48b440c 100644 --- a/lib/devos/mkHosts.nix +++ b/lib/devos/mkHosts.nix @@ -63,7 +63,11 @@ let # Everything in `./modules/list.nix`. flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; }; - cachix = ../../cachix.nix; + cachix = let rootCachix = ../../cachix.nix; in + if builtins.pathExists rootCachix + then rootCachix + else { } + ; }; specialArgs = extern.specialArgs // { suites = suites.system; }; diff --git a/cachix.nix b/profiles/cachix/default.nix similarity index 76% rename from cachix.nix rename to profiles/cachix/default.nix index 32a3e8df..d88a3f75 100644 --- a/cachix.nix +++ b/profiles/cachix/default.nix @@ -1,9 +1,8 @@ -# WARN: this file will get overwritten by $ cachix use { pkgs, lib, ... }: let - folder = ./cachix; + folder = ./.; toImport = name: value: folder + ("/" + name); - filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key; + filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key && key != "default.nix"; imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder)); in { diff --git a/cachix/nix-community.nix b/profiles/cachix/nix-community.nix similarity index 100% rename from cachix/nix-community.nix rename to profiles/cachix/nix-community.nix diff --git a/cachix/nrdxp.nix b/profiles/cachix/nrdxp.nix similarity index 100% rename from cachix/nrdxp.nix rename to profiles/cachix/nrdxp.nix diff --git a/profiles/core/default.nix b/profiles/core/default.nix index f5a654c0..1bca2b9d 100644 --- a/profiles/core/default.nix +++ b/profiles/core/default.nix @@ -2,6 +2,7 @@ let inherit (lib) fileContents; in { + imports = [ ../cachix ]; nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];