nix: enable creating config file via home-manager (#109)

This commit is contained in:
Johan
2024-04-25 14:06:31 +02:00
committed by GitHub
parent 43c16a537b
commit 9edd2f7f3b
2 changed files with 19 additions and 0 deletions

View File

@@ -34,6 +34,9 @@ enable lan-mouse
enable = true;
# systemd = false;
# package = inputs.lan-mouse.packages.${pkgs.stdenv.hostPlatform.system}.default
# Optional configuration in nix syntax, see config.toml for available options
# settings = { };
};
};
}

View File

@@ -7,6 +7,7 @@ self: {
with lib; let
cfg = config.programs.lan-mouse;
defaultPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
tomlFormat = pkgs.formats.toml {};
in {
options.programs.lan-mouse = with types; {
enable = mkEnableOption "Whether or not to enable lan-mouse.";
@@ -25,6 +26,17 @@ in {
default = pkgs.stdenv.isLinux;
description = "Whether to enable to systemd service for lan-mouse.";
};
settings = lib.mkOption {
inherit (tomlFormat) type;
default = {};
example = builtins.fromTOML (builtins.readFile (self + /config.toml));
description = ''
Optional configuration written to {file}`$XDG_CONFIG_HOME/lan-mouse/config.toml`.
See <https://github.com/feschber/lan-mouse/> for
available options and documentation.
'';
};
};
config = mkIf cfg.enable {
@@ -46,5 +58,9 @@ in {
home.packages = [
cfg.package
];
xdg.configFile."lan-mouse/config.toml" = lib.mkIf (cfg.settings != {}) {
source = tomlFormat.generate "config.toml" cfg.settings;
};
};
}