···10571057`dontBenchmark drv`
10581058: Set `doBenchmark` to `false` for `drv`.
1059105910601060-`setBuildTargets list drv`
10601060+`setBuildTargets drv list`
10611061: Sets the `buildTarget` argument for `drv` so that the targets specified in `list` are built.
1062106210631063`doCoverage drv`
+32-2
lib/lists.nix
···198198 default:
199199 # Input list
200200 list:
201201- let found = filter pred list;
202202- in if found == [] then default else head found;
201201+ let
202202+ # A naive recursive implementation would be much simpler, but
203203+ # would also overflow the evaluator stack. We use `foldl'` as a workaround
204204+ # because it reuses the same stack space, evaluating the function for one
205205+ # element after another. We can't return early, so this means that we
206206+ # sacrifice early cutoff, but that appears to be an acceptable cost. A
207207+ # clever scheme with "exponential search" is possible, but appears over-
208208+ # engineered for now. See https://github.com/NixOS/nixpkgs/pull/235267
209209+210210+ # Invariant:
211211+ # - if index < 0 then el == elemAt list (- index - 1) and all elements before el didn't satisfy pred
212212+ # - if index >= 0 then pred (elemAt list index) and all elements before (elemAt list index) didn't satisfy pred
213213+ #
214214+ # We start with index -1 and the 0'th element of the list, which satisfies the invariant
215215+ resultIndex = foldl' (index: el:
216216+ if index < 0 then
217217+ # No match yet before the current index, we need to check the element
218218+ if pred el then
219219+ # We have a match! Turn it into the actual index to prevent future iterations from modifying it
220220+ - index - 1
221221+ else
222222+ # Still no match, update the index to the next element (we're counting down, so minus one)
223223+ index - 1
224224+ else
225225+ # There's already a match, propagate the index without evaluating anything
226226+ index
227227+ ) (-1) list;
228228+ in
229229+ if resultIndex < 0 then
230230+ default
231231+ else
232232+ elemAt list resultIndex;
203233204234 /* Return true if function `pred` returns true for at least one
205235 element of `list`.
+40
lib/tests/misc.nix
···518518 expected = false;
519519 };
520520521521+ testFindFirstExample1 = {
522522+ expr = findFirst (x: x > 3) 7 [ 1 6 4 ];
523523+ expected = 6;
524524+ };
525525+526526+ testFindFirstExample2 = {
527527+ expr = findFirst (x: x > 9) 7 [ 1 6 4 ];
528528+ expected = 7;
529529+ };
530530+531531+ testFindFirstEmpty = {
532532+ expr = findFirst (abort "when the list is empty, the predicate is not needed") null [];
533533+ expected = null;
534534+ };
535535+536536+ testFindFirstSingleMatch = {
537537+ expr = findFirst (x: x == 5) null [ 5 ];
538538+ expected = 5;
539539+ };
540540+541541+ testFindFirstSingleDefault = {
542542+ expr = findFirst (x: false) null [ (abort "if the predicate doesn't access the value, it must not be evaluated") ];
543543+ expected = null;
544544+ };
545545+546546+ testFindFirstNone = {
547547+ expr = builtins.tryEval (findFirst (x: x == 2) null [ 1 (throw "the last element must be evaluated when there's no match") ]);
548548+ expected = { success = false; value = false; };
549549+ };
550550+551551+ # Makes sure that the implementation doesn't cause a stack overflow
552552+ testFindFirstBig = {
553553+ expr = findFirst (x: x == 1000000) null (range 0 1000000);
554554+ expected = 1000000;
555555+ };
556556+557557+ testFindFirstLazy = {
558558+ expr = findFirst (x: x == 1) 7 [ 1 (abort "list elements after the match must not be evaluated") ];
559559+ expected = 1;
560560+ };
521561522562# ATTRSETS
523563
+1-1
nixos/modules/config/qt.nix
···2020 pkgs.adwaita-qt6
2121 ]
2222 else if isQtStyle then [ pkgs.libsForQt5.qtstyleplugins ]
2323- else if isQt5ct then [ pkgs.libsForQt5.qt5ct ]
2323+ else if isQt5ct then [ pkgs.libsForQt5.qt5ct pkgs.qt6Packages.qt6ct ]
2424 else if isLxqt then [ pkgs.lxqt.lxqt-qtplugin pkgs.lxqt.lxqt-config ]
2525 else if isKde then [ pkgs.libsForQt5.plasma-integration pkgs.libsForQt5.systemsettings ]
2626 else throw "`qt.platformTheme` ${cfg.platformTheme} and `qt.style` ${cfg.style} are not compatible.";