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:
@@ -1,21 +1,8 @@
|
||||
{ ... }: {
|
||||
flake.homeManagerModules.wisdomBrowsersChrome =
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
root = config.chiasson.home;
|
||||
cfg = config.chiasson.home.browsers.chrome;
|
||||
in
|
||||
{
|
||||
options.chiasson.home.browsers.chrome.enable = lib.mkEnableOption ''
|
||||
Chrome (unfree, needs `allowUnfree`); skipped if nixpkgs has no build for this platform.
|
||||
'' // {
|
||||
default = false;
|
||||
};
|
||||
|
||||
config = lib.mkIf (root.enable && cfg.enable) {
|
||||
home.packages = lib.optional (
|
||||
lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.google-chrome
|
||||
) pkgs.google-chrome;
|
||||
};
|
||||
};
|
||||
{ self, ... }: {
|
||||
flake.homeManagerModules.wisdomBrowsersChrome = self.lib.wisdomSimpleSlice {
|
||||
path = "browsers.chrome";
|
||||
default = false;
|
||||
description = "Chrome (unfree, needs `allowUnfree`); skipped if nixpkgs has no build for this platform.";
|
||||
packages = pkgs: [ pkgs.google-chrome ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
{ ... }: {
|
||||
flake.homeManagerModules.wisdomBrowsersEdge =
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
root = config.chiasson.home;
|
||||
cfg = config.chiasson.home.browsers.edge;
|
||||
in
|
||||
{
|
||||
options.chiasson.home.browsers.edge.enable = lib.mkEnableOption "Edge (unfree); skipped if unavailable on this platform." // {
|
||||
default = false;
|
||||
};
|
||||
|
||||
config = lib.mkIf (root.enable && cfg.enable) {
|
||||
home.packages = lib.optional (
|
||||
lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.microsoft-edge
|
||||
) pkgs.microsoft-edge;
|
||||
};
|
||||
};
|
||||
{ self, ... }: {
|
||||
flake.homeManagerModules.wisdomBrowsersEdge = self.lib.wisdomSimpleSlice {
|
||||
path = "browsers.edge";
|
||||
default = false;
|
||||
description = "Edge (unfree); skipped if unavailable on this platform.";
|
||||
packages = pkgs: [ pkgs.microsoft-edge ];
|
||||
};
|
||||
}
|
||||
|
||||
+29
-25
@@ -1,24 +1,23 @@
|
||||
# HM side of the flake; option tree is `chiasson.home.*` (docs/conventions.md).
|
||||
{ self, inputs, ... }: {
|
||||
# Root module: chiasson.home.enable + bash. Other `wisdom*` slices auto-wire via
|
||||
# `lib.wisdomCatalogExtraModules`; hosts flip `chiasson.home.*.enable` rather than re-importing.
|
||||
# Root module: chiasson.home.enable + git identity. Other `wisdom*` slices (including
|
||||
# the bash shell) auto-wire via `lib.wisdomCatalogExtraModules`; hosts flip
|
||||
# `chiasson.home.*.enable` rather than re-importing.
|
||||
flake.homeManagerModules.wisdom =
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.chiasson.home;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
self.homeManagerModules.wisdomShellBash
|
||||
];
|
||||
|
||||
options.chiasson.home = {
|
||||
enable = lib.mkEnableOption ''
|
||||
HM profile root for this flake (bash on by default). Desktop hosts use
|
||||
`lib.wisdomCatalogExtraModules` once per user and flip `chiasson.home.*.enable` on the host.
|
||||
'' // {
|
||||
default = true;
|
||||
};
|
||||
enable =
|
||||
lib.mkEnableOption ''
|
||||
HM profile root for this flake (bash on by default). Desktop hosts use
|
||||
`lib.wisdomCatalogExtraModules` once per user and flip `chiasson.home.*.enable` on the host.
|
||||
''
|
||||
// {
|
||||
default = true;
|
||||
};
|
||||
|
||||
extraPackages = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.package;
|
||||
@@ -29,20 +28,25 @@
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
{ home.packages = cfg.extraPackages; }
|
||||
config = lib.mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
{ home.packages = cfg.extraPackages; }
|
||||
|
||||
# Base git identity + encryption/player tools shared by every HM user.
|
||||
{
|
||||
programs.git = {
|
||||
enable = true;
|
||||
settings.user = {
|
||||
name = "OlivierChiasson";
|
||||
email = "olivierchiasson@hotmail.fr";
|
||||
# Base git identity + encryption/player tools shared by every HM user.
|
||||
{
|
||||
programs.git = {
|
||||
enable = true;
|
||||
settings.user = {
|
||||
name = "OlivierChiasson";
|
||||
email = "olivierchiasson@hotmail.fr";
|
||||
};
|
||||
};
|
||||
};
|
||||
home.packages = [ pkgs.git-crypt pkgs.feishin ];
|
||||
}
|
||||
]);
|
||||
home.packages = [
|
||||
pkgs.git-crypt
|
||||
pkgs.feishin
|
||||
];
|
||||
}
|
||||
]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
{ ... }: {
|
||||
flake.homeManagerModules.wisdomEditorsKate =
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
root = config.chiasson.home;
|
||||
cfg = config.chiasson.home.editors.kate;
|
||||
in
|
||||
{
|
||||
options.chiasson.home.editors.kate.enable = lib.mkEnableOption "Kate." // {
|
||||
default = false;
|
||||
};
|
||||
|
||||
config = lib.mkIf (root.enable && cfg.enable) {
|
||||
home.packages = lib.optional (
|
||||
lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.kdePackages.kate
|
||||
) pkgs.kdePackages.kate;
|
||||
};
|
||||
};
|
||||
{ self, ... }: {
|
||||
flake.homeManagerModules.wisdomEditorsKate = self.lib.wisdomSimpleSlice {
|
||||
path = "editors.kate";
|
||||
default = false;
|
||||
description = "Kate.";
|
||||
packages = pkgs: [ pkgs.kdePackages.kate ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
{ ... }: {
|
||||
flake.homeManagerModules.wisdomEditorsObsidian =
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
root = config.chiasson.home;
|
||||
cfg = config.chiasson.home.editors.obsidian;
|
||||
in
|
||||
{
|
||||
options.chiasson.home.editors.obsidian.enable = lib.mkEnableOption ''
|
||||
Obsidian (unfree); skipped if unavailable here.
|
||||
'' // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
config = lib.mkIf (root.enable && cfg.enable) {
|
||||
home.packages = lib.optional (
|
||||
lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.obsidian
|
||||
) pkgs.obsidian;
|
||||
};
|
||||
};
|
||||
{ self, ... }: {
|
||||
flake.homeManagerModules.wisdomEditorsObsidian = self.lib.wisdomSimpleSlice {
|
||||
path = "editors.obsidian";
|
||||
default = true;
|
||||
description = "Obsidian (unfree); skipped if unavailable here.";
|
||||
packages = pkgs: [ pkgs.obsidian ];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user