mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 17:39:37 +08:00
keepassxc: add autostart option
This commit is contained in:
committed by
Austin Horstman
parent
cb8cfa0eb9
commit
62fdc8d410
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
14
tests/modules/programs/keepassxc/autostart.nix
Normal file
14
tests/modules/programs/keepassxc/autostart.nix
Normal 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.
|
||||
''
|
||||
];
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
keepassxc-autostart = ./autostart.nix;
|
||||
keepassxc-default-settings = ./default-settings.nix;
|
||||
keepassxc-example-settings = ./example-settings.nix;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user