Skip to content

Commit

Permalink
Merge remote-tracking branch 'other/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 3, 2024
2 parents 7d68864 + b8d62ad commit 2376a86
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/attrsets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let
inherit (builtins) head length;
inherit (lib.trivial) oldestSupportedReleaseIsAtLeast mergeAttrs warn warnIf;
inherit (lib.strings) concatStringsSep concatMapStringsSep escapeNixIdentifier sanitizeDerivationName;
inherit (lib.lists) foldr foldl' concatMap elemAt all partition groupBy take foldl;
inherit (lib.lists) filter foldr foldl' concatMap elemAt all partition groupBy take foldl;
in

rec {
Expand Down Expand Up @@ -644,8 +644,7 @@ rec {
filterAttrs =
pred:
set:
listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

removeAttrs set (filter (name: ! pred name set.${name}) (attrNames set));

/**
Filter an attribute set recursively by removing all attributes for
Expand Down
14 changes: 14 additions & 0 deletions lib/licenses.nix
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,11 @@ lib.mapAttrs mkLicense ({
url = "https://license.coscl.org.cn/MulanPSL2";
};

naist-2003 = {
spdxId = "NAIST-2003";
fullName = "Nara Institute of Science and Technology License (2003)";
};

nasa13 = {
spdxId = "NASA-1.3";
fullName = "NASA Open Source Agreement 1.3";
Expand Down Expand Up @@ -1285,6 +1290,15 @@ lib.mapAttrs mkLicense ({
watcom = {
spdxId = "Watcom-1.0";
fullName = "Sybase Open Watcom Public License 1.0";
# Despite being OSI‐approved, this licence is not considered FOSS
# by Debian, Fedora, or the FSF, due to an onerous restriction that
# requires publication of even privately‐deployed modifications.
# This violates the FSF’s freedom 3 and Debian’s “desert island
# test” and “dissident test”.
#
# See: <https://en.wikipedia.org/wiki/Sybase_Open_Watcom_Public_License>
free = false;
redistributable = true;
};

w3c = {
Expand Down
20 changes: 20 additions & 0 deletions lib/tests/misc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let
evalModules
extends
filter
filterAttrs
fix
fold
foldAttrs
Expand Down Expand Up @@ -1102,6 +1103,25 @@ runTests {
};
};

testFilterAttrs = {
expr = filterAttrs (n: v: n != "a" && (v.hello or false) == true) {
a.hello = true;
b.hello = true;
c = {
hello = true;
world = false;
};
d.hello = false;
};
expected = {
b.hello = true;
c = {
hello = true;
world = false;
};
};
};

# code from example
testFoldlAttrs = {
expr = {
Expand Down

0 comments on commit 2376a86

Please sign in to comment.