2021-04-27 19:36:29 +00:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2022-05-07 18:05:10 +00:00
|
|
|
let
|
|
|
|
cfg = config.services.pass-secret-service;
|
|
|
|
|
2023-05-07 21:44:48 +00:00
|
|
|
busName = "org.freedesktop.secrets";
|
2021-04-27 19:36:29 +00:00
|
|
|
in {
|
2023-04-03 18:28:29 +00:00
|
|
|
meta.maintainers = with maintainers; [ cab404 cyntheticfox ];
|
2022-05-07 18:05:10 +00:00
|
|
|
|
2021-04-27 19:36:29 +00:00
|
|
|
options.services.pass-secret-service = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption "Pass libsecret service";
|
2022-05-07 18:05:10 +00:00
|
|
|
|
2023-07-01 23:45:18 +00:00
|
|
|
package = mkPackageOption pkgs "pass-secret-service" { };
|
2022-05-07 18:05:10 +00:00
|
|
|
|
|
|
|
storePath = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2023-05-07 21:44:48 +00:00
|
|
|
defaultText = "$HOME/.password-store";
|
2022-05-07 18:05:10 +00:00
|
|
|
example = "/home/user/.local/share/password-store";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2023-05-07 21:44:48 +00:00
|
|
|
Absolute path to password store. Defaults to
|
2023-06-30 23:30:13 +00:00
|
|
|
{file}`$HOME/.password-store` if the
|
|
|
|
{option}`programs.password-store` module is not enabled, and
|
|
|
|
{option}`programs.password-store.settings.PASSWORD_STORE_DIR` if it is.
|
2023-05-07 21:44:48 +00:00
|
|
|
'';
|
2022-05-07 18:05:10 +00:00
|
|
|
};
|
2021-04-27 19:36:29 +00:00
|
|
|
};
|
2022-05-07 18:05:10 +00:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 21:24:27 +00:00
|
|
|
assertions = [
|
|
|
|
(hm.assertions.assertPlatform "services.pass-secret-service" pkgs
|
|
|
|
platforms.linux)
|
2023-05-07 21:44:48 +00:00
|
|
|
{
|
|
|
|
assertion = !config.services.gnome-keyring.enable;
|
|
|
|
message = ''
|
|
|
|
Only one secrets service per user can be enabled at a time.
|
|
|
|
Other services enabled:
|
|
|
|
- gnome-keyring
|
|
|
|
'';
|
|
|
|
}
|
2021-07-07 21:24:27 +00:00
|
|
|
];
|
2021-04-27 19:36:29 +00:00
|
|
|
|
2023-05-07 21:44:48 +00:00
|
|
|
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} ${
|
|
|
|
optionalString (cfg.storePath != null) "--path ${cfg.storePath}"
|
|
|
|
}";
|
|
|
|
BusName = busName;
|
2024-10-04 07:19:02 +00:00
|
|
|
Environment = [ "GNUPGHOME=${config.programs.gpg.homedir}" ];
|
2023-05-07 21:44:48 +00:00
|
|
|
};
|
2022-05-07 18:05:10 +00:00
|
|
|
|
2023-05-07 21:44:48 +00:00
|
|
|
Install.WantedBy = [ "default.target" ];
|
2021-04-27 19:36:29 +00:00
|
|
|
};
|
2022-05-07 18:05:10 +00:00
|
|
|
|
2023-05-07 21:44:48 +00:00
|
|
|
xdg.dataFile."dbus-1/services/${busName}.service".source =
|
|
|
|
"${cfg.package}/share/dbus-1/services/${busName}.service";
|
2021-04-27 19:36:29 +00:00
|
|
|
};
|
|
|
|
}
|