feat(nix): add keys enum to global cfg

This commit is contained in:
2025-07-07 03:22:16 +02:00
parent 4611ad87a8
commit d85ebc0e78
4 changed files with 42 additions and 22 deletions

View File

@@ -102,21 +102,24 @@ pass:
* A string to copy the config from a theme in `themes/` with said name * A string to copy the config from a theme in `themes/` with said name
(**name**, e.g `"cherry"`). (**name**, e.g `"cherry"`).
* An attribute tree with the same names as the config file, e.g: * An attribute tree with the same names as the config file, e.g:
```nix ```nix
{ with config.lidm.keysEnum; {
strings = { strings = {
f_poweroff = "custom_poweroff"; f_poweroff = "custom_poweroff";
# etc
}; };
behavior = { behavior = {
include_defshell = true; include_defshell = true;
source = [ source = [
"path1" "path1"
"path2" "path2"
]; ];
# etc
}; };
# etc
functions = { poweroff = F1; };
# etc...
}; };
``` ```

View File

@@ -10,11 +10,14 @@ let
keys-h-file = builtins.readFile "${src}/include/keys.h"; keys-h-file = builtins.readFile "${src}/include/keys.h";
}; };
in in
builtins.toFile "lidm.conf" ( {
inherit maker;
file = builtins.toFile "lidm.conf" (
if builtins.isString cfg then if builtins.isString cfg then
builtins.readFile "${src}/themes/${cfg}.ini" builtins.readFile "${src}/themes/${cfg}.ini"
else if builtins.isAttrs cfg then else if builtins.isAttrs cfg then
maker.make cfg maker.make cfg
else else
builtins.throw "invalid cfg type, expected str or attrs" builtins.throw "invalid cfg type, expected str or attrs"
) );
}

View File

@@ -5,7 +5,7 @@
... ...
}: }:
let let
cfg-file = get-cfg =
if config.cfg != null then if config.cfg != null then
import ./get-cfg-file.nix { import ./get-cfg-file.nix {
inherit lib; inherit lib;
@@ -13,6 +13,8 @@ let
} }
else else
null; null;
cfg-file = get-cfg.file;
maker = get-cfg.maker;
in in
pkgs.stdenv.mkDerivation rec { pkgs.stdenv.mkDerivation rec {
pname = "lidm"; pname = "lidm";
@@ -41,4 +43,8 @@ pkgs.stdenv.mkDerivation rec {
fixupPhase = '' fixupPhase = ''
rm -rf $out/etc rm -rf $out/etc
''; '';
passthru = {
keysEnum = maker.keys-enum;
};
} }

View File

@@ -30,7 +30,14 @@ let
}; };
in in
{ {
options.services.lidm.config = lib.mkOption { options = {
lidm.keysEnum = lib.mkOption {
type = with lib.types; attrs;
default = lidm.passthru.keysEnum;
readOnly = true;
description = "Keys enum constants";
};
services.lidm.config = lib.mkOption {
type = type =
with lib.types; with lib.types;
oneOf [ oneOf [
@@ -40,6 +47,7 @@ in
default = { }; default = { };
description = "Config options for lidm | Either attr tree or name of bundled themes"; description = "Config options for lidm | Either attr tree or name of bundled themes";
}; };
};
config = { config = {
services.displayManager.defaultSession = "lidm"; services.displayManager.defaultSession = "lidm";