From f3b7a6a33588ad425de02c4b841df19f30733e44 Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Mon, 9 Jun 2025 19:43:34 +0000 Subject: reorganize programs, move functions to library, and remove the rest of hyprland (all sway now) --- lib/lib.nix | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lib/lib.nix (limited to 'lib/lib.nix') 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; +} -- cgit v1.3.1