aboutsummaryrefslogtreecommitdiff
path: root/snowfall/lib/modules
diff options
context:
space:
mode:
Diffstat (limited to 'snowfall/lib/modules')
-rw-r--r--snowfall/lib/modules/default.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/snowfall/lib/modules/default.nix b/snowfall/lib/modules/default.nix
new file mode 100644
index 0000000..b351f7e
--- /dev/null
+++ b/snowfall/lib/modules/default.nix
@@ -0,0 +1,27 @@
+{ lib, namespace }:
+
+let
+ mkSimpleModule = category: name: { packages ? null, persist ? [] }: (
+ { options, config, lib, pkgs, ... }:
+
+ with lib; with lib.${namespace}; let
+ cfg = config.${namespace}.${category}.${name};
+ impermanence = config.${namespace}.impermanence;
+ in {
+ options.${namespace}.${category}.${name} = with types; {
+ enable = mkEnableOption "${name}";
+ };
+
+ config = mkIf cfg.enable {
+ home.packages = if (packages != null) then packages else [ pkgs.${name} ];
+
+ home.persistence.${impermanence.location} = {
+ directories = persist;
+ };
+ };
+ }
+ );
+in {
+ mkSimpleApp = name: args@{ ... }: mkSimpleModule "apps" name args;
+ mkSimpleTool = name: args@{ ... }: mkSimpleModule "tools" name args;
+}