home-manager/programs/diceware: init

This commit is contained in:
Gabriel Arazas 2025-02-14 12:48:20 +08:00
parent eceb124e55
commit ee2785ab64
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
6 changed files with 78 additions and 0 deletions

View File

@ -4,6 +4,7 @@
./programs/pipewire.nix
./programs/pop-launcher.nix
./programs/borgmatic.nix
./programs/diceware.nix
./programs/nushell.nix
./programs/python.nix
./services/archivebox.nix

View File

@ -0,0 +1,46 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.diceware;
settingsFormat = pkgs.formats.ini { };
in
{
options.programs.diceware = {
enable = lib.mkEnableOption "configuring diceware, a passphrase generator";
package = lib.mkPackageOption pkgs "diceware" { };
settings = lib.mkOption {
type = settingsFormat.type;
default = { };
description = ''
Settings in INI format to be generated at
{file}`$XDG_CONFIG_HOME/diceware/diceware.ini`.
'';
example = lib.literalExpression ''
{
diceware = {
num = 7;
caps = false;
specials = 2;
delimiter = "MYDELIMITER";
randomsource = "system";
wordlist = "en_securedrop";
};
}
'';
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
home.packages = [ cfg.package ];
}
(lib.mkIf (cfg.settings != { }) {
xdg.configFile."diceware/diceware.ini".source =
settingsFormat.generate "diceware-user-settings" cfg.settings;
})
]);
}

View File

@ -50,6 +50,7 @@ in import nmt {
# TODO: Fix nmt to accept specialArgs or something.
tests = builtins.foldl' (a: b: a // (import b)) { } ([
#./programs/borgmatic
./programs/diceware
./programs/pipewire
./programs/pop-launcher
./programs/zed-editor

View File

@ -0,0 +1,15 @@
{ config, lib, ... }: {
programs.diceware = {
enable = true;
settings.diceware = {
num = 7;
specials = 2;
};
};
test.stubs.diceware = { };
nmt.script = ''
assertFileExists home-files/.config/diceware/diceware.ini
'';
}

View File

@ -0,0 +1,4 @@
{
diceware-basic-settings = ./basic.nix;
diceware-empty-settings = ./empty.nix;
}

View File

@ -0,0 +1,11 @@
{ ... }:
{
programs.diceware.enable = true;
test.stubs.diceware = { };
nmt.script = ''
assertPathNotExists home-files/.config/diceware/diceware.ini
'';
}