aboutsummaryrefslogtreecommitdiff
path: root/snowfall/lib/modules
diff options
context:
space:
mode:
authorCaroline Larimore <caroline@larimo.re>2025-02-08 16:22:49 -0800
committerCaroline Larimore <caroline@larimo.re>2025-04-14 18:58:50 -0700
commit00d3797991dc45022909707549029657074bb549 (patch)
treef9219dcb8dcac8333e7d7a8f2bc3830b317d5785 /snowfall/lib/modules
parent6f6b6b59e64ee94be095e856e1e6943bbf574349 (diff)
migration: simple module generator functions
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;
+}