wayprompt: init module (#7002)
A module for configuring Wayprompt¹, a password-prompter for Wayland, that can be used as a pinentry program for GnuPG (and more). Provides a 'programs.wayprompt.settings', following RFC 42². ¹: https://git.sr.ht/~leon_plickat/wayprompt ²: https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md
This commit is contained in:
parent
c84396bda0
commit
3c59c5132b
7 changed files with 119 additions and 0 deletions
69
modules/programs/wayprompt.nix
Normal file
69
modules/programs/wayprompt.nix
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.programs.wayprompt;
|
||||
|
||||
# Matches 6-hex-digit RGB or 8-hex-digit RGBA values
|
||||
colourHexPattern = "^[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$";
|
||||
|
||||
isColourHex = str: builtins.match colourHexPattern str != null;
|
||||
|
||||
iniFormat = pkgs.formats.ini {
|
||||
mkKeyValue = lib.generators.mkKeyValueDefault {
|
||||
mkValueString =
|
||||
v:
|
||||
if lib.isString v then
|
||||
(if isColourHex v then "0x${lib.strings.toUpper v};" else ''"${v}";'')
|
||||
else
|
||||
lib.generators.mkValueStringDefault { } v + ";";
|
||||
} " = ";
|
||||
};
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.maintainers.panchoh ];
|
||||
|
||||
options.programs.wayprompt = {
|
||||
enable = lib.mkEnableOption "Wayprompt, a password-prompter for Wayland";
|
||||
|
||||
package = lib.mkPackageOption pkgs "wayprompt" { nullable = true; };
|
||||
|
||||
settings = lib.mkOption {
|
||||
inherit (iniFormat) type;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
general = {
|
||||
font-regular = "sans:size=14";
|
||||
pin-square-amount = 32;
|
||||
};
|
||||
colours = {
|
||||
background = "0xffffffaa";
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration for wayprompt written to
|
||||
{file}`$XDG_CONFIG_HOME/wayprompt/config.ini`.
|
||||
See {manpage}`wayprompt(5)` for a list of available options.
|
||||
Note that colours can be either 6-hex-digit RGB or 8-hex-digit RGBA values.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "programs.wayprompt" pkgs lib.platforms.linux)
|
||||
];
|
||||
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
xdg.configFile."wayprompt/config.ini" = lib.mkIf (cfg.settings != { }) {
|
||||
source = iniFormat.generate "config.ini" cfg.settings;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue