feat: Make modules evauluate without dependencies

Previously, module checks would stop us from evaluating if we didn't
include all of our dependencies' modules too. This became cumbersome if
someone was importing our flake, especially since as Nix doesn't stop
duplicate dependencies from being imported twice...

...by using optionalAttrs anywhere a dependency is needed, we stop Nix
being able to check that our options are valid, working around the issue

---

It's way too easy to make a mistake here, a first version of this change
had a bug where due to something like this...

x = lib.mkIf cfg.enable {  } // { foo = lib.optionalAttrs ... }

...which evaluates as...

x = { _type = "if"; value = ...; foo = lib.optionalAttrs ...; ...; }

...we ended up dropping the impermanence options which mount our storage

It's really critical, therefore, to check that you aren't munging
attrsets into mkIf statements when you start using a mix of them

Change-Id: I7b786af965b3fd1012d956262aea72305b60db27
Reviewed-on: https://git.clicks.codes/c/Infra/NixFiles/+/811
Reviewed-by: Skyler Grey <minion@clicks.codes>
Tested-by: Skyler Grey <minion@clicks.codes>
diff --git a/modules/nixos/clicks/storage/impermanence/default.nix b/modules/nixos/clicks/storage/impermanence/default.nix
index 646e7b5..7d2a94b 100644
--- a/modules/nixos/clicks/storage/impermanence/default.nix
+++ b/modules/nixos/clicks/storage/impermanence/default.nix
@@ -64,7 +64,7 @@
     };
   };
 
-  config = lib.mkIf cfg.enable {
+  config = lib.mkIf cfg.enable ({
     boot.initrd.postDeviceCommands = lib.mkAfter ''
       mkdir /impermanent_fs
       mount ${cfg.devices.root} /impermanent_fs
@@ -102,18 +102,20 @@
       neededForBoot = true;
       fsType = "btrfs";
     };
-
-    environment.persistence."/persist/${cfg.volumes.persistent_data}" = {
-      directories = [
-        "/var/lib/nixos" # https://github.com/nix-community/impermanence/issues/178
-      ] ++ cfg.persist.directories;
-      files = [
-        "/etc/machine-id"
-        "/etc/ssh/ssh_host_ed25519_key"
-        "/etc/ssh/ssh_host_ed25519_key.pub"
-        "/etc/ssh/ssh_host_rsa_key"
-        "/etc/ssh/ssh_host_rsa_key.pub"
-      ] ++ cfg.persist.files;
+  } // {
+    environment = lib.optionalAttrs cfg.enable {
+      persistence."/persist/${cfg.volumes.persistent_data}" = {
+        directories = [
+          "/var/lib/nixos" # https://github.com/nix-community/impermanence/issues/178
+        ] ++ cfg.persist.directories;
+        files = [
+          "/etc/machine-id"
+          "/etc/ssh/ssh_host_ed25519_key"
+          "/etc/ssh/ssh_host_ed25519_key.pub"
+          "/etc/ssh/ssh_host_rsa_key"
+          "/etc/ssh/ssh_host_rsa_key.pub"
+        ] ++ cfg.persist.files;
+      };
     };
-  };
+  });
 }