Merge pull request #328381 from tie/map-attrs-flatten

This commit is contained in:
Silvan Mosberger 2024-07-24 13:32:34 +02:00 committed by GitHub
commit 473e469d5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 7 deletions

View File

@ -29,9 +29,10 @@ let
nameValuePair
tail
toList
warn
;
inherit (lib.attrsets) removeAttrs;
inherit (lib.attrsets) removeAttrs mapAttrsToList;
# returns default if env var is not set
maybeEnv = name: default:
@ -212,7 +213,7 @@ let
else closePropagationSlow;
# calls a function (f attr value ) for each record item. returns a list
mapAttrsFlatten = f: r: map (attr: f attr r.${attr}) (attrNames r);
mapAttrsFlatten = warn "lib.misc.mapAttrsFlatten is deprecated, please use lib.attrsets.mapAttrsToList instead." mapAttrsToList;
# attribute set containing one attribute
nvs = name: value: listToAttrs [ (nameValuePair name value) ];

View File

@ -252,6 +252,8 @@
- [`lib.options.mkPackageOptionMD`](https://nixos.org/manual/nixpkgs/unstable#function-library-lib.options.mkPackageOptionMD) is now obsolete; use the identical [`lib.options.mkPackageOption`](https://nixos.org/manual/nixpkgs/unstable#function-library-lib.options.mkPackageOption) instead.
- `lib.misc.mapAttrsFlatten` is now formally deprecated and will be removed in future releases; use the identical [`lib.attrsets.mapAttrsToList`](https://nixos.org/manual/nixpkgs/unstable#function-library-lib.attrsets.mapAttrsToList) instead.
- `nixosTests` now provide a working IPv6 setup for VLAN 1 by default.
- To facilitate dependency injection, the `imgui` package now builds a static archive using vcpkg' CMake rules.

View File

@ -10,7 +10,7 @@ let
cfg = config.programs.bash;
bashAliases = builtins.concatStringsSep "\n" (
lib.mapAttrsFlatten (k: v: "alias -- ${k}=${lib.escapeShellArg v}")
lib.mapAttrsToList (k: v: "alias -- ${k}=${lib.escapeShellArg v}")
(lib.filterAttrs (k: v: v != null) cfg.shellAliases)
);

View File

@ -7,12 +7,12 @@ let
cfg = config.programs.fish;
fishAbbrs = lib.concatStringsSep "\n" (
lib.mapAttrsFlatten (k: v: "abbr -ag ${k} ${lib.escapeShellArg v}")
lib.mapAttrsToList (k: v: "abbr -ag ${k} ${lib.escapeShellArg v}")
cfg.shellAbbrs
);
fishAliases = lib.concatStringsSep "\n" (
lib.mapAttrsFlatten (k: v: "alias ${k} ${lib.escapeShellArg v}")
lib.mapAttrsToList (k: v: "alias ${k} ${lib.escapeShellArg v}")
(lib.filterAttrs (k: v: v != null) cfg.shellAliases)
);

View File

@ -10,7 +10,7 @@ let
opt = options.programs.zsh;
zshAliases = builtins.concatStringsSep "\n" (
lib.mapAttrsFlatten (k: v: "alias -- ${k}=${lib.escapeShellArg v}")
lib.mapAttrsToList (k: v: "alias -- ${k}=${lib.escapeShellArg v}")
(lib.filterAttrs (k: v: v != null) cfg.shellAliases)
);

View File

@ -223,7 +223,7 @@ in
config = mkIf (cfg.servers != { }) {
systemd.services = (listToAttrs (mapAttrsFlatten (name: value: nameValuePair "openvpn-${name}" (makeOpenVPNJob value name)) cfg.servers))
systemd.services = (listToAttrs (mapAttrsToList (name: value: nameValuePair "openvpn-${name}" (makeOpenVPNJob value name)) cfg.servers))
// restartService;
environment.systemPackages = [ openvpn ];