mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
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.
This commit is contained in:
parent
1c6f3054ca
commit
1d94de5604
6 changed files with 69 additions and 14 deletions
|
@ -59,6 +59,9 @@ in {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
home.sessionVariables = cfg.settings;
|
home.sessionVariables = cfg.settings;
|
||||||
|
|
||||||
|
services.pass-secret-service.storePath =
|
||||||
|
mkDefault cfg.settings.PASSWORD_STORE_DIR;
|
||||||
|
|
||||||
xsession.importedVariables = mkIf config.xsession.enable
|
xsession.importedVariables = mkIf config.xsession.enable
|
||||||
(mapAttrsToList (name: value: name) cfg.settings);
|
(mapAttrsToList (name: value: name) cfg.settings);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,31 +2,46 @@
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let serviceCfg = config.services.pass-secret-service;
|
let
|
||||||
|
cfg = config.services.pass-secret-service;
|
||||||
|
|
||||||
|
serviceArgs =
|
||||||
|
optionalString (cfg.storePath != null) "--path ${cfg.storePath}";
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ maintainers.cab404 ];
|
meta.maintainers = with maintainers; [ cab404 houstdav000 ];
|
||||||
|
|
||||||
options.services.pass-secret-service = {
|
options.services.pass-secret-service = {
|
||||||
enable = mkEnableOption "Pass libsecret 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 serviceCfg.enable {
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
assertions = [
|
assertions = [
|
||||||
(hm.assertions.assertPlatform "services.pass-secret-service" pkgs
|
(hm.assertions.assertPlatform "services.pass-secret-service" pkgs
|
||||||
platforms.linux)
|
platforms.linux)
|
||||||
|
|
||||||
{
|
|
||||||
assertion = config.programs.password-store.enable;
|
|
||||||
message = "The 'services.pass-secret-service' module requires"
|
|
||||||
+ " 'programs.password-store.enable = true'.";
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.user.services.pass-secret-service = {
|
systemd.user.services.pass-secret-service = {
|
||||||
Unit = { Description = "Pass libsecret service"; };
|
Unit = {
|
||||||
Service = {
|
AssertFileIsExecutable = "${cfg.package}/bin/pass_secret_service";
|
||||||
# pass-secret-service doesn't use environment variables for some reason.
|
Description = "Pass libsecret service";
|
||||||
ExecStart =
|
Documentation = "https://github.com/mdellweg/pass_secret_service";
|
||||||
"${pkgs.pass-secret-service}/bin/pass_secret_service --path ${config.programs.password-store.settings.PASSWORD_STORE_DIR}";
|
PartOf = [ "default.target" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
ExecStart = "${cfg.package}/bin/pass_secret_service ${serviceArgs}";
|
||||||
|
};
|
||||||
|
|
||||||
Install = { WantedBy = [ "default.target" ]; };
|
Install = { WantedBy = [ "default.target" ]; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -189,6 +189,7 @@ import nmt {
|
||||||
./modules/services/mpdris2
|
./modules/services/mpdris2
|
||||||
./modules/services/pantalaimon
|
./modules/services/pantalaimon
|
||||||
./modules/services/parcellite
|
./modules/services/parcellite
|
||||||
|
./modules/services/pass-secret-service
|
||||||
./modules/services/pbgopy
|
./modules/services/pbgopy
|
||||||
./modules/services/picom
|
./modules/services/picom
|
||||||
./modules/services/playerctld
|
./modules/services/playerctld
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.pass-secret-service = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage { };
|
||||||
|
storePath = "/mnt/password-store";
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
serviceFile=home-files/.config/systemd/user/pass-secret-service.service
|
||||||
|
|
||||||
|
assertFileExists $serviceFile
|
||||||
|
assertFileRegex $serviceFile 'ExecStart=.*/bin/pass_secret_service'
|
||||||
|
assertFileRegex $serviceFile '/mnt/password-store'
|
||||||
|
'';
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.pass-secret-service = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage { };
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
serviceFile=home-files/.config/systemd/user/pass-secret-service.service
|
||||||
|
|
||||||
|
assertFileExists $serviceFile
|
||||||
|
assertFileRegex $serviceFile 'ExecStart=.*/bin/pass_secret_service'
|
||||||
|
'';
|
||||||
|
}
|
4
tests/modules/services/pass-secret-service/default.nix
Normal file
4
tests/modules/services/pass-secret-service/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
pass-secret-service-default-configuration = ./default-configuration.nix;
|
||||||
|
pass-secret-service-basic-configuration = ./basic-configuration.nix;
|
||||||
|
}
|
Loading…
Reference in a new issue