Nix/HM module: add sources and extraConfig

This commit is contained in:
Mihai Fufezan 2024-03-25 23:16:05 +02:00
parent 87fce7923f
commit 03720cd9e4
No known key found for this signature in database

View file

@ -5,7 +5,7 @@ self: {
... ...
}: let }: let
inherit (builtins) toString; inherit (builtins) toString;
inherit (lib.types) bool float int listOf package str submodule; inherit (lib.types) bool float int listOf lines nullOr package str submodule;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
@ -64,6 +64,18 @@ in {
default = self.packages.${pkgs.stdenv.hostPlatform.system}.hyprlock; default = self.packages.${pkgs.stdenv.hostPlatform.system}.hyprlock;
}; };
extraConfig = mkOption {
description = "Extra configuration lines, written verbatim";
type = nullOr lines;
default = null;
};
sources = mkOption {
description = "List of files to `source`";
type = listOf str;
default = [];
};
general = { general = {
disable_loading_bar = mkOption { disable_loading_bar = mkOption {
description = "Whether to disable loading bar"; description = "Whether to disable loading bar";
@ -490,6 +502,10 @@ in {
home.packages = [cfg.package]; home.packages = [cfg.package];
xdg.configFile."hypr/hyprlock.conf".text = '' xdg.configFile."hypr/hyprlock.conf".text = ''
${builtins.concatStringsSep "\n" (map (source: ''
source = ${source}
'') cfg.sources)}
general { general {
disable_loading_bar = ${boolToString cfg.general.disable_loading_bar} disable_loading_bar = ${boolToString cfg.general.disable_loading_bar}
grace = ${toString cfg.general.grace} grace = ${toString cfg.general.grace}
@ -586,6 +602,8 @@ in {
} }
'') '')
cfg.labels)} cfg.labels)}
${lib.optionalString (cfg.extraConfig != null) cfg.extraConfig}
''; '';
}; };
} }