feat(wisdom): introduce wisdomSimpleSlice helper for package modules

Implement a `wisdomSimpleSlice` helper in `desktop/options.nix` to reduce
boilerplate for simple Home Manager modules that only manage packages.
This helper handles the `enable` option creation, platform-gating via
`availableOn`, and conditional inclusion in `home.packages`.

Refactor several existing wisdom modules to use this new helper:
- `wisdomBrowsersChrome`
- `wisdomBrowsersEdge`
- `wisdomEditorsKate`
- `wisdomEditorsObsidian`

Additionally, clean up `wisdom/default.nix` by removing the explicit
import of `wisdomShellBash` (which is now handled via auto-wiring) and
improving code formatting.
This commit is contained in:
2026-07-16 19:46:23 -03:00
parent 13f35677be
commit 103a485bf8
7 changed files with 81 additions and 103 deletions
+21 -1
View File
@@ -7,13 +7,33 @@
self:
let
names = lib.sort builtins.lessThan (
lib.filter (n: lib.hasPrefix "wisdom" n && n != "wisdom" && n != "wisdomShellBash") (
lib.filter (n: lib.hasPrefix "wisdom" n && n != "wisdom") (
builtins.attrNames self.homeManagerModules
)
);
in
map (name: self.homeManagerModules.${name}) names;
# Thin HM slice: an `enable` toggle that adds packages to `home.packages`, skipping
# any not `availableOn` this platform. `packages` is a `pkgs -> [ drv ]` function so
# callers only name each package once (the helper owns the platform-gating). Used by
# the trivial single-package wisdom slices so they stay one declarative block instead
# of the repeated `root/cfg` + `mkIf (root.enable && cfg.enable)` boilerplate.
flake.lib.wisdomSimpleSlice =
{ path, default, description, packages }:
{ config, lib, pkgs, ... }:
let
segs = lib.splitString "." path;
optPath = [ "chiasson" "home" ] ++ segs ++ [ "enable" ];
enabled = lib.getAttrFromPath optPath config;
in
{
options = lib.setAttrByPath optPath (lib.mkEnableOption description // { inherit default; });
config = lib.mkIf (config.chiasson.home.enable && enabled) {
home.packages = lib.filter (lib.meta.availableOn pkgs.stdenv.hostPlatform) (packages pkgs);
};
};
flake.nixosModules.desktopOptions =
{ config, options, lib, pkgs, self, inputs, ... }:
let