mirror of
https://github.com/nix-community/home-manager.git
synced 2026-10-03 12:09:19 +00:00
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:
committed by
Robert Helgesson
parent
1944398834
commit
a26f7158fb
9
modules/misc/news/2026/08/2026-08-29_08-55-25.nix
Normal file
9
modules/misc/news/2026/08/2026-08-29_08-55-25.nix
Normal 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.
|
||||
'';
|
||||
}
|
||||
52
modules/programs/yopass.nix
Normal file
52
modules/programs/yopass.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
}
|
||||
3
tests/modules/programs/yopass/default.nix
Normal file
3
tests/modules/programs/yopass/default.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
yopass-settings = ./settings.nix;
|
||||
}
|
||||
19
tests/modules/programs/yopass/settings.nix
Normal file
19
tests/modules/programs/yopass/settings.nix
Normal 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}
|
||||
'';
|
||||
}
|
||||
1
tests/modules/programs/yopass/settings.yml
Normal file
1
tests/modules/programs/yopass/settings.yml
Normal file
@@ -0,0 +1 @@
|
||||
{"api":"https://api.example.com","expiration":"1d","one-time":false,"url":"https://example.com"}
|
||||
Reference in New Issue
Block a user