feat: auto enable programs in hm if enabled in os

This commit is contained in:
punkfairie 2025-05-26 15:42:18 -07:00
parent 230e2d0e3a
commit ede3d69907
Signed by: punkfairie
GPG key ID: B3C5488E9A1A7CA6
4 changed files with 41 additions and 20 deletions

View file

@ -1,12 +1,13 @@
{ {
inputs, inputs,
lib,
self, self,
... ...
}: { }: {
imports = [inputs.easy-hosts.flakeModule]; imports = [inputs.easy-hosts.flakeModule];
config.easy-hosts = { config.easy-hosts = {
shared.specialArgs.marleylib = import ../lib; shared.specialArgs.marleylib = import ../lib {inherit lib;};
# shared.modules = with inputs; [ # shared.modules = with inputs; [
# # TODO: Move module imports to custom module # # TODO: Move module imports to custom module

View file

@ -1,3 +1,3 @@
{ {lib}: {
module = import ./module.nix; module = import ./module.nix {inherit lib;};
} }

View file

@ -1,5 +1,4 @@
{ {lib}: {
enabled = {
## Quickly enable an option. ## Quickly enable an option.
## ##
## ```nix ## ```nix
@ -7,10 +6,10 @@
## ``` ## ```
## ##
#@ true #@ true
enabled = {
enable = true; enable = true;
}; };
disabled = {
## Quickly disable an option. ## Quickly disable an option.
## ##
## ```nix ## ```nix
@ -18,6 +17,23 @@
## ``` ## ```
## ##
#@ false #@ false
disabled = {
enable = false; enable = false;
}; };
## Like lib.mkEnableOption, but allows specifying the default.
##
## ```nix
## options.marleyos.wayland = mkEnableOption' "wayland" false;
## ```
mkEnableOption' = name: default:
lib.mkOption {
inherit default;
example = true;
description =
if name ? _type && name._type == "mdDoc"
then lib.mdDoc "Whether to enable ${name.text}."
else "Whether to enable ${name}.";
type = lib.types.bool;
};
} }

View file

@ -1,12 +1,16 @@
{ {
config, config,
lib, marleylib,
osConfig, osConfig,
lib,
... ...
}: let }: let
inherit (marleylib.module) mkEnableOption';
osCfg = osConfig.marleyos.programs.nh.enable;
cfg = config.marleyos.programs.nh; cfg = config.marleyos.programs.nh;
in { in {
options.marleyos.programs.nh.enable = lib.mkEnableOption "nh"; options.marleyos.programs.nh.enable = mkEnableOption' "nh" osCfg;
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.nh = { programs.nh = {