fix(non-clicks): Re-export dependencies

Due to how mkIf continues to check definitions past a `false`, this is
invalid unless `environment.persistence` is defined

config = lib.mkIf false {
  environment.persistence = {
    ...
  };
};

This is a big problem for people importing our modules, who may not have
had, say, `impermanence` imported

We considered using `lib.optionalAttrs` instead, but this causes a lot
of infinite recursion elsewhere in our config, so we decided this was a
more "cost effective" way of spending our time, even if it will likely
cause downstream configs to import more than they technically need...

Change-Id: I433d34395b0449de17af2dea2a8a3138c1ff6dba
Reviewed-on: https://git.clicks.codes/c/Infra/NixFiles/+/808
Reviewed-by: Skyler Grey <minion@clicks.codes>
Tested-by: Skyler Grey <minion@clicks.codes>
diff --git a/flake.nix b/flake.nix
index 5500287..ed9c9af 100644
--- a/flake.nix
+++ b/flake.nix
@@ -61,6 +61,12 @@
           namespace = "clicks";
         };
       }).snowfall.internal.system-lib;
+
+      nixosModuleDependencies = {
+        agenix = inputs.agenix.nixosModules.default;
+        agenix-rekey = inputs.agenix-rekey.nixosModules.default;
+        impermanence = inputs.impermanence.nixosModules.impermanence;
+      };
     in
     lib.mkFlake {
       overlays = [
@@ -68,15 +74,12 @@
       ];
 
       systems.modules.nixos = [
-        inputs.agenix.nixosModules.default
-        inputs.agenix-rekey.nixosModules.default
-        inputs.impermanence.nixosModules.impermanence
         {
           config.clicks.defaults.enable = true;
           # set defaults that are clicks-specific, such as our backups module
           # being enabled...
         }
-      ];
+      ] ++ (lib.attrsets.attrValues nixosModuleDependencies);
 
       deploy = lib.clicks.deploy.mkDeploy {
         inherit (inputs) self;
@@ -93,6 +96,21 @@
         nodes = inputs.self.nixosConfigurations;
       };
 
+      # We need to re-export dependencies, as this is *invalid* unless
+      # environment.persistence is defined, so importing all our modules will
+      # otherwise break evaluation
+      #
+      # config = lib.mkIf false {
+      #   environment.persistence = {
+      #     ...
+      #   };
+      # };
+      #
+      modules.nixos = lib.attrsets.mapAttrs' (name: value: {
+        name = "dependency/${name}";
+        inherit value;
+      }) nixosModuleDependencies;
+
       outputs-builder = channels: {
         specs = let
           nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.;