nixos/wordlist: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-28 21:18:52 +02:00 committed by Jörg Thalheim
parent 609e57485d
commit 30c85fe74d

View File

@ -1,5 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
concatAndSort = name: files: pkgs.runCommand name {} ''
awk 1 ${lib.escapeShellArgs files} | sed '{ /^\s*$/d; s/^\s\+//; s/\s\+$// }' | sort | uniq > $out
@ -8,16 +7,16 @@ in
{
options = {
environment.wordlist = {
enable = mkEnableOption "environment variables for lists of words";
enable = lib.mkEnableOption "environment variables for lists of words";
lists = mkOption {
type = types.attrsOf (types.nonEmptyListOf types.path);
lists = lib.mkOption {
type = lib.types.attrsOf (lib.types.nonEmptyListOf lib.types.path);
default = {
WORDLIST = [ "${pkgs.scowl}/share/dict/words.txt" ];
};
defaultText = literalExpression ''
defaultText = lib.literalExpression ''
{
WORDLIST = [ "''${pkgs.scowl}/share/dict/words.txt" ];
}
@ -34,7 +33,7 @@ in
task.
'';
example = literalExpression ''
example = lib.literalExpression ''
{
WORDLIST = [ "''${pkgs.scowl}/share/dict/words.txt" ];
AUGMENTED_WORDLIST = [
@ -50,7 +49,7 @@ in
};
};
config = mkIf config.environment.wordlist.enable {
config = lib.mkIf config.environment.wordlist.enable {
environment.variables =
lib.mapAttrs
(name: value: "${concatAndSort "wordlist-${name}" value}")