Skip to content

Commit

Permalink
nix: enable creating config file via home-manager (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
meck authored Apr 25, 2024
1 parent 43c16a5 commit 9edd2f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { };
};
};
}
Expand Down
16 changes: 16 additions & 0 deletions nix/hm-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand All @@ -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 {
Expand All @@ -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;
};
};
}

0 comments on commit 9edd2f7

Please sign in to comment.