git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/modules/misc/wordlist: init

Addresses #16545. Allows for user defined environment variables that hold paths to wordlists. This is to allow for easy access to wordlists for users and scripts, (in other distributions a convenient wordlist is typically found in /usr/share/dict/words or similar). The default wordlist is the one found in scowl, for no other reason than that's the one that was mentioned in the linked issue. It is possible to specify multiple environment variables as well. This is for users who need multiple wordlists (such as multilingual users).

commit787219edafa4c79418e3ecc1be06fb8e787d0307 authorMichael Reilly <OmnipotentEntity@gmail.com> dateThu 3 Feb 2022, 14:48 (5 years ago) parent84a3eb3
4 files changed+70
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+8 nixos/doc/manual/release-notes/rl-2205.section.md+2 nixos/modules/misc/wordlist.nix+59 nixos/modules/module-list.nix+1
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+8
@@ -790,6 +790,14 @@
790790 renamed to <literal>linux-firmware</literal>.
791791 </para>
792792 </listitem>
793+ <listitem>
794+ <para>
795+ It is now possible to specify wordlists to include as handy to
796+ access environment variables using the
797+ <literal>config.environment.wordlist</literal> configuration
798+ options.
799+ </para>
800+ </listitem>
793801 <listitem>
794802 <para>
795803 The <literal>services.mbpfan</literal> module was converted to
nixos/doc/manual/release-notes/rl-2205.section.md+2
@@ -269,6 +269,8 @@ In addition to numerous new and upgraded packages, this release has the followin
269269
270270- The `firmwareLinuxNonfree` package has been renamed to `linux-firmware`.
271271
272+- It is now possible to specify wordlists to include as handy to access environment variables using the `config.environment.wordlist` configuration options.
273+
272274- The `services.mbpfan` module was converted to a [RFC 0042](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md) configuration.
273275
274276- The default value for `programs.spacefm.settings.graphical_su` got unset. It previously pointed to `gksu` which has been removed.
nixos/modules/misc/wordlist.nixnew file+59
@@ -0,0 +1,59 @@
1+{ config, lib, pkgs, ... }:
2+with lib;
3+let
4+ concatAndSort = name: files: pkgs.runCommand name {} ''
5+ awk 1 ${lib.escapeShellArgs files} | sed '{ /^\s*$/d; s/^\s\+//; s/\s\+$// }' | sort | uniq > $out
6+ '';
7+in
8+{
9+ options = {
10+ environment.wordlist = {
11+ enable = mkEnableOption "environment variables for lists of words";
12+
13+ lists = mkOption {
14+ type = types.attrsOf (types.nonEmptyListOf types.path);
15+
16+ default = {
17+ WORDLIST = [ "${pkgs.scowl}/share/dict/words.txt" ];
18+ };
19+
20+ defaultText = literalExpression ''
21+ {
22+ WORDLIST = [ "''${pkgs.scowl}/share/dict/words.txt" ];
23+ }
24+ '';
25+
26+ description = ''
27+ A set with the key names being the environment variable you'd like to
28+ set and the values being a list of paths to text documents containing
29+ lists of words. The various files will be merged, sorted, duplicates
30+ removed, and extraneous spacing removed.
31+
32+ If you have a handful of words that you want to add to an already
33+ existing wordlist, you may find `builtins.toFile` useful for this
34+ task.
35+ '';
36+
37+ example = literalExpression ''
38+ {
39+ WORDLIST = [ "''${pkgs.scowl}/share/dict/words.txt" ];
40+ AUGMENTED_WORDLIST = [
41+ "''${pkgs.scowl}/share/dict/words.txt"
42+ "''${pkgs.scowl}/share/dict/words.variants.txt"
43+ (builtins.toFile "extra-words" '''
44+ desynchonization
45+ oobleck''')
46+ ];
47+ }
48+ '';
49+ };
50+ };
51+ };
52+
53+ config = mkIf config.environment.wordlist.enable {
54+ environment.variables =
55+ lib.mapAttrs
56+ (name: value: "${concatAndSort "wordlist-${name}" value}")
57+ config.environment.wordlist.lists;
58+ };
59+}
nixos/modules/module-list.nix+1
@@ -115,6 +115,7 @@
115115 ./misc/nixpkgs.nix
116116 ./misc/passthru.nix
117117 ./misc/version.nix
118+ ./misc/wordlist.nix
118119 ./misc/nixops-autoluks.nix
119120 ./programs/adb.nix
120121 ./programs/appgate-sdp.nix