aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.nix
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2025-06-09 19:43:34 +0000
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2025-06-09 19:43:34 +0000
commitf3b7a6a33588ad425de02c4b841df19f30733e44 (patch)
treeab6a8524350fda5868bf3f43187affbdb0895ce6 /lib/lib.nix
parenta45c4551712c1ba5cb82eaf290f311ab0e8690e4 (diff)
reorganize programs, move functions to library, and remove the rest of hyprland (all sway now)
Diffstat (limited to 'lib/lib.nix')
-rw-r--r--lib/lib.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/lib.nix b/lib/lib.nix
new file mode 100644
index 0000000..5310a6d
--- /dev/null
+++ b/lib/lib.nix
@@ -0,0 +1,52 @@
+let
+ optionalAttrs = cond: as:
+ if cond
+ then as
+ else {};
+
+ mkIfNull = cond: as:
+ if cond
+ then as
+ else null;
+
+ globimport = {
+ lazyImport = path: optionalAttrs (builtins.pathExists path) (import path);
+
+ getSubdirs = dir:
+ builtins.filter (x: x != null)
+ (builtins.attrValues
+ (builtins.mapAttrs
+ (name: value: mkIfNull (value == "directory") name)
+ (builtins.readDir dir)));
+
+ getSubfiles = dir:
+ builtins.filter (x: x != null)
+ (builtins.attrValues
+ (builtins.mapAttrs
+ (name: value: mkIfNull (value == "file") name)
+ (builtins.readDir dir)));
+ };
+
+ options = {
+ lib,
+ config,
+ }: let
+ inherit (lib) mkOption mkEnableOption;
+ mkProgramOption' = name: extraOpts:
+ {
+ enable = mkEnableOption "whether to enable ${name}";
+ theme = mkOption {
+ type = lib.types.enum ["catppuccin" "adwaita"];
+ default = config.collinux.terminal.theme;
+ };
+ }
+ // extraOpts;
+
+ mkProgramOption = name: mkProgramOption' name {};
+ in {
+ inherit mkProgramOption' mkProgramOption;
+ };
+in {
+ inherit globimport;
+ inherit options;
+}