git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #158034 from OmnipotentEntity/wordlist
commita8de36a1d03ec1c1da7993edb2c18b35bb588b08 authorPatrick Hilhorst <git@hilhorst.be> dateWed 23 Feb 2022, 12:43 (5 years ago) parentd778e18787219e
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
@@ -932,6 +932,14 @@
932932 renamed to <literal>linux-firmware</literal>.
933933 </para>
934934 </listitem>
935+ <listitem>
936+ <para>
937+ It is now possible to specify wordlists to include as handy to
938+ access environment variables using the
939+ <literal>config.environment.wordlist</literal> configuration
940+ options.
941+ </para>
942+ </listitem>
935943 <listitem>
936944 <para>
937945 The <literal>services.mbpfan</literal> module was converted to
nixos/doc/manual/release-notes/rl-2205.section.md+2
@@ -311,6 +311,8 @@ In addition to numerous new and upgraded packages, this release has the followin
311311
312312- The `firmwareLinuxNonfree` package has been renamed to `linux-firmware`.
313313
314+- It is now possible to specify wordlists to include as handy to access environment variables using the `config.environment.wordlist` configuration options.
315+
314316- The `services.mbpfan` module was converted to a [RFC 0042](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md) configuration.
315317
316318- 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