1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-05 02:39:45 +01:00
home-manager/modules/services/pass-secret-service.nix
David Houston 1d94de5604
pass-secret-service: various improvements
Allow setting the application package and storePath used by the
config. Since the `programs.password-store` Home Manager module sets
config values via global environment variables, the default behavior
of the module should continue to behave as before for the user.

Additionally,

- Adds a few tests.

- Use "escapeShellArg" function call to the path parameter call to
  ensure paths with spaces work.

- Allow not setting storePath, which will cause `pass_secret_service`
  to default to using `~/.password-store`.

- If `pass-secret-service` is enabled, set its store path to default
  to the one defined in our password-store environment settings.

- Add myself (houstdav000) as maintainer.
2023-01-31 23:19:09 +01:00

48 lines
1.3 KiB
Nix

{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.services.pass-secret-service;
serviceArgs =
optionalString (cfg.storePath != null) "--path ${cfg.storePath}";
in {
meta.maintainers = with maintainers; [ cab404 houstdav000 ];
options.services.pass-secret-service = {
enable = mkEnableOption "Pass libsecret service";
package = mkPackageOption pkgs "pass-secret-service" { };
storePath = mkOption {
type = with types; nullOr str;
default = null;
defaultText = "~/.password-store";
example = "/home/user/.local/share/password-store";
description = "Absolute path to password store.";
};
};
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "services.pass-secret-service" pkgs
platforms.linux)
];
systemd.user.services.pass-secret-service = {
Unit = {
AssertFileIsExecutable = "${cfg.package}/bin/pass_secret_service";
Description = "Pass libsecret service";
Documentation = "https://github.com/mdellweg/pass_secret_service";
PartOf = [ "default.target" ];
};
Service = {
ExecStart = "${cfg.package}/bin/pass_secret_service ${serviceArgs}";
};
Install = { WantedBy = [ "default.target" ]; };
};
};
}