1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-05 16:41:04 +01:00
home-manager/modules/services/pass-secret-service.nix

77 lines
2.1 KiB
Nix

{
pkgs,
config,
lib,
...
}:
let
inherit (lib) mkOption types;
cfg = config.services.pass-secret-service;
busName = "org.freedesktop.secrets";
in
{
meta.maintainers = with lib.maintainers; [
cab404
cyntheticfox
];
options.services.pass-secret-service = {
enable = lib.mkEnableOption "Pass libsecret service";
package = lib.mkPackageOption pkgs "pass-secret-service" { };
storePath = mkOption {
type = with types; nullOr str;
default = null;
defaultText = "$HOME/.password-store";
example = "/home/user/.local/share/password-store";
description = ''
Absolute path to the password store. If the
{option}`programs.password-store` module is enabled, the
{option}`programs.password-store.settings.PASSWORD_STORE_DIR` option
will be checked, if found it will be inherited as the default.
'';
};
};
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.pass-secret-service" pkgs lib.platforms.linux)
{
assertion = !config.services.gnome-keyring.enable;
message = ''
Only one secrets service per user can be enabled at a time.
Other services enabled:
- gnome-keyring
'';
}
];
systemd.user.services.pass-secret-service =
let
binPath = "${cfg.package}/bin/pass_secret_service";
in
{
Unit = {
AssertFileIsExecutable = binPath;
Description = "Pass libsecret service";
Documentation = "https://github.com/mdellweg/pass_secret_service";
PartOf = [ "default.target" ];
};
Service = {
Type = "dbus";
ExecStart = binPath + lib.optionalString (cfg.storePath != null) " --path ${cfg.storePath}";
BusName = busName;
Environment = [ "GNUPGHOME=${config.programs.gpg.homedir}" ];
};
Install.WantedBy = [ "default.target" ];
};
xdg.dataFile."dbus-1/services/${busName}.service".source =
"${cfg.package}/share/dbus-1/services/${busName}.service";
};
}