1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

keepassxc: add autostart option

This commit is contained in:
Benedikt Rips 2025-08-06 08:51:25 +02:00 committed by Austin Horstman
parent cb8cfa0eb9
commit 62fdc8d410
3 changed files with 39 additions and 4 deletions

View file

@ -46,16 +46,36 @@ in
for the full list of options.
'';
};
autostart = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = ''
Whether to start Keepassxc automatically on login through the XDG autostart mechanism.
'';
};
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
xdg.configFile = {
"keepassxc/keepassxc.ini" = lib.mkIf (cfg.settings != { }) {
source = iniFormat.generate "keepassxc-settings" cfg.settings;
};
assertions = [
{
assertion = cfg.autostart -> config.xdg.autostart.enable;
message = ''
{option}`xdg.autostart.enable` has to be enabled in order for
{option}`programs.keepassxc.autostart` to be effective.
'';
}
];
xdg.autostart.entries = lib.mkIf cfg.autostart [
"${cfg.package}/share/applications/org.keepassxc.KeePassXC.desktop"
];
xdg.configFile."keepassxc/keepassxc.ini" = lib.mkIf (cfg.settings != { }) {
source = iniFormat.generate "keepassxc-settings" cfg.settings;
};
}

View file

@ -0,0 +1,14 @@
{
programs.keepassxc = {
enable = true;
autostart = true;
};
xdg.autostart.enable = false;
test.asserts.assertions.expected = [
''
{option}`xdg.autostart.enable` has to be enabled in order for
{option}`programs.keepassxc.autostart` to be effective.
''
];
}

View file

@ -1,4 +1,5 @@
{
keepassxc-autostart = ./autostart.nix;
keepassxc-default-settings = ./default-settings.nix;
keepassxc-example-settings = ./example-settings.nix;
}