refactor(desktop): clean up options formatting and simplify slice logic
Refactor `modules/desktop/options.nix` to improve code readability by expanding the `optPath` list definition and simplifying the `wisdomSimpleSlice` configuration logic. Also apply minor style fixes to `modules/wisdom/filebrowsers/nemo.nix` to ensure consistent spacing within list definitions.
This commit is contained in:
+11
-12
@@ -1,8 +1,5 @@
|
|||||||
{ lib, ... }: {
|
{ lib, ... }:
|
||||||
# Resolve `wisdom*` HM slices for NixOS `extraModules` (`self` is not an HM specialArg).
|
{
|
||||||
# Slices are gated by `chiasson.home.*.enable`; hosts only flip toggles in `home.nix`.
|
|
||||||
# Lives here (not `modules/lib/`) because `hosts/desktop-home-base.nix` consumes it and
|
|
||||||
# fragment eval order requires the definition to sort before `hosts/`.
|
|
||||||
flake.lib.wisdomCatalogExtraModules =
|
flake.lib.wisdomCatalogExtraModules =
|
||||||
self:
|
self:
|
||||||
let
|
let
|
||||||
@@ -14,22 +11,24 @@
|
|||||||
in
|
in
|
||||||
map (name: self.homeManagerModules.${name}) names;
|
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 =
|
flake.lib.wisdomSimpleSlice =
|
||||||
{ path, default, description, packages }:
|
{ path, default, description, packages }:
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
segs = lib.splitString "." path;
|
segs = lib.splitString "." path;
|
||||||
optPath = [ "chiasson" "home" ] ++ segs ++ [ "enable" ];
|
optPath = [
|
||||||
|
"chiasson"
|
||||||
|
"home"
|
||||||
|
]
|
||||||
|
++ segs
|
||||||
|
++ [ "enable" ];
|
||||||
|
root = config.chiasson.home;
|
||||||
|
cfg = lib.getAttrFromPath segs root;
|
||||||
enabled = lib.getAttrFromPath optPath config;
|
enabled = lib.getAttrFromPath optPath config;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = lib.setAttrByPath optPath (lib.mkEnableOption description // { inherit default; });
|
options = lib.setAttrByPath optPath (lib.mkEnableOption description // { inherit default; });
|
||||||
config = lib.mkIf (config.chiasson.home.enable && enabled) {
|
config = lib.mkIf (root.enable && enabled) {
|
||||||
home.packages = lib.filter (lib.meta.availableOn pkgs.stdenv.hostPlatform) (packages pkgs);
|
home.packages = lib.filter (lib.meta.availableOn pkgs.stdenv.hostPlatform) (packages pkgs);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user