yopass: add module

Adds programs.yopass for managing the yopass CLI configuration file
(~/.config/yopass/defaults.yml), with an NMT test verifying the
generated settings.

Assisted-by: Claude Fable 5
This commit is contained in:
Santhosh Raju
2026-08-29 08:45:52 +02:00
committed by Robert Helgesson
parent 1944398834
commit a26f7158fb
5 changed files with 84 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
{
time = "2026-08-29T06:55:25+00:00";
message = ''
A new module is available: 'programs.yopass'.
Yopass is a tool for sharing secrets and files securely. The module
manages the yopass command line client's configuration file.
'';
}

View File

@@ -0,0 +1,52 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.yopass;
in
{
meta.maintainers = [ lib.maintainers.fraggerfox ];
options.programs.yopass = {
enable = lib.mkEnableOption "Yopass, a tool for sharing secrets and files securely";
package = lib.mkPackageOption pkgs "yopass" { nullable = true; };
settings = lib.mkOption {
type = lib.types.attrsOf (
lib.types.oneOf [
lib.types.bool
lib.types.int
lib.types.str
]
);
default = { };
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/yopass/defaults.yml`.
See the [CLI documentation](https://yopass.se/docs/cli) for the
full list of available settings (`api`, `api-token`, `url`,
`one-time`, `expiration`).
'';
example = {
api = "https://api.example.com";
url = "https://example.com";
"one-time" = false;
expiration = "1d";
};
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."yopass/defaults.yml" = lib.mkIf (cfg.settings != { }) {
text = lib.generators.toYAML { } cfg.settings;
};
};
}

View File

@@ -0,0 +1,3 @@
{
yopass-settings = ./settings.nix;
}

View File

@@ -0,0 +1,19 @@
{
programs.yopass = {
enable = true;
settings = {
api = "https://api.example.com";
url = "https://example.com";
"one-time" = false;
expiration = "1d";
};
};
test.stubs.yopass = { };
nmt.script = ''
assertFileExists home-files/.config/yopass/defaults.yml
assertFileContent home-files/.config/yopass/defaults.yml \
${./settings.yml}
'';
}

View File

@@ -0,0 +1 @@
{"api":"https://api.example.com","expiration":"1d","one-time":false,"url":"https://example.com"}