2021-04-27 21:36:29 +02:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2022-05-07 20:05:10 +02:00
|
|
|
let
|
|
|
|
cfg = config.services.pass-secret-service;
|
|
|
|
|
2023-05-07 23:44:48 +02:00
|
|
|
busName = "org.freedesktop.secrets";
|
2021-04-27 21:36:29 +02:00
|
|
|
in {
|
2023-04-03 20:28:29 +02:00
|
|
|
meta.maintainers = with maintainers; [ cab404 cyntheticfox ];
|
2022-05-07 20:05:10 +02:00
|
|
|
|
2021-04-27 21:36:29 +02:00
|
|
|
options.services.pass-secret-service = {
|
|
|
|
enable = mkEnableOption "Pass libsecret service";
|
2022-05-07 20:05:10 +02:00
|
|
|
|
|
|
|
package = mkPackageOption pkgs "pass-secret-service" { };
|
|
|
|
|
|
|
|
storePath = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2023-05-07 23:44:48 +02:00
|
|
|
defaultText = "$HOME/.password-store";
|
2022-05-07 20:05:10 +02:00
|
|
|
example = "/home/user/.local/share/password-store";
|
2023-05-07 23:44:48 +02:00
|
|
|
description = ''
|
|
|
|
Absolute path to password store. Defaults to
|
|
|
|
<filename>$HOME/.password-store</filename> if the
|
|
|
|
<option>programs.password-store</option> module is not enabled, and
|
|
|
|
<option>programs.password-store.settings.PASSWORD_STORE_DIR</option> if it is.
|
|
|
|
'';
|
2022-05-07 20:05:10 +02:00
|
|
|
};
|
2021-04-27 21:36:29 +02:00
|
|
|
};
|
2022-05-07 20:05:10 +02:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 23:24:27 +02:00
|
|
|
assertions = [
|
|
|
|
(hm.assertions.assertPlatform "services.pass-secret-service" pkgs
|
|
|
|
platforms.linux)
|
2023-05-07 23:44:48 +02: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 23:24:27 +02:00
|
|
|
];
|
2021-04-27 21:36:29 +02:00
|
|
|
|
2023-05-07 23:44:48 +02: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;
|
|
|
|
};
|
2022-05-07 20:05:10 +02:00
|
|
|
|
2023-05-07 23:44:48 +02:00
|
|
|
Install.WantedBy = [ "default.target" ];
|
2021-04-27 21:36:29 +02:00
|
|
|
};
|
2022-05-07 20:05:10 +02:00
|
|
|
|
2023-05-07 23:44:48 +02:00
|
|
|
xdg.dataFile."dbus-1/services/${busName}.service".source =
|
|
|
|
"${cfg.package}/share/dbus-1/services/${busName}.service";
|
2021-04-27 21:36:29 +02:00
|
|
|
};
|
|
|
|
}
|