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,
lib,
self,
...
}: {
imports = [inputs.easy-hosts.flakeModule];
config.easy-hosts = {
shared.specialArgs.marleylib = import ../lib;
shared.specialArgs.marleylib = import ../lib {inherit lib;};
# shared.modules = with inputs; [
# # TODO: Move module imports to custom module

View file

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

View file

@ -1,23 +1,39 @@
{
{lib}: {
## Quickly enable an option.
##
## ```nix
## services.nginx = enabled;
## ```
##
#@ true
enabled = {
## Quickly enable an option.
##
## ```nix
## services.nginx = enabled;
## ```
##
#@ true
enable = true;
};
## Quickly disable an option.
##
## ```nix
## services.nginx = enabled;
## ```
##
#@ false
disabled = {
## Quickly disable an option.
##
## ```nix
## services.nginx = enabled;
## ```
##
#@ 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,
lib,
marleylib,
osConfig,
lib,
...
}: let
inherit (marleylib.module) mkEnableOption';
osCfg = osConfig.marleyos.programs.nh.enable;
cfg = config.marleyos.programs.nh;
in {
options.marleyos.programs.nh.enable = lib.mkEnableOption "nh";
options.marleyos.programs.nh.enable = mkEnableOption' "nh" osCfg;
config = lib.mkIf cfg.enable {
programs.nh = {