summaryrefslogtreecommitdiff
path: root/lib (follow)
Commit message (Expand)AuthorAgeFilesLines
* Merge pull request #152392 from polykernel/attrset-optimizations-patch-1•••lib/attrset: various function optimizationspennae2022-01-111-17/+14
|\
| * lib/attrset: miscellaneous optimizations•••- Eta reduce `mapAttrsRecursiveCond`, `foldAttrs`, `getAttrFromPath`. - Modify `matchAttrs` to use `elemAt` instead of `head (tail xs)` to access elements. - Modify `matchAttrs` to use `any id` instead of `foldr and true`. polykernel2021-12-271-10/+10
| * lib/attrset: optimize element access in recursiveUpdateUntil•••- Eta reduce formal arguments of `recursiveUpdate'. - Access elements in `recursiveUpdateUntil` using `elemAt` and `head` directly instead of `head (tail xs)` which copies a singleton unnecessarily. (`elemAt` is used instead of `last` to save a primitive call to `length`, this is possible because the 2-tuple structure is guranteed) - Use `length` instead of comparison to empty list to save a copy. polykernel2021-12-271-7/+4
* | Merge pull request #152046 from pennae/optimize-modules-byName•••lib/modules: optimize byNameRobert Hensing2022-01-102-9/+9
|\ \
| * | lib/modules: extract multiply-used value in byName•••module.${attr} is used at least twice, so it must be evaluated at least twice (and since it's a function argument, be turned into a thunk twice). pennae2021-12-281-4/+4
| * | lib/attrsets: use builtins.zipAttrsWith if availablepennae2021-12-251-1/+2
| * | lib/modules: optimize byName•••the foldl is equivalent to a zip with concat. list concatenation in nix is an O(n) operation, which makes this operation extremely inefficient when large numbers of modules are involved. this change reduces the number of list elements by 7 million on the system used to write this, total memory spent on lists by 58MB, and total memory allocated on the GC heap by almost 100MB (with a similar reduction in GC heap size). it's also slightly faster. pennae2021-12-251-6/+5
| |/
* | lib.checkListOfEnum: initJosé Romildo2022-01-092-1/+18
* | Merge pull request #151748 from hercules-ci/check-nixpkgs-overlays-type•••Check nixpkgs overlays argument typesRobert Hensing2022-01-052-1/+24
|\ \
| * | lib.throwIfNot: initRobert Hensing2021-12-222-1/+24
| |/
* / nixos/documentation: split options doc build•••most modules can be evaluated for their documentation in a very restricted environment that doesn't include all of nixpkgs. this evaluation can then be cached and reused for subsequent builds, merging only documentation that has changed into the cached set. since nixos ships with a large number of modules of which only a few are used in any given config this can save evaluation a huge percentage of nixos options available in any given config. in tests of this caching, despite having to copy most of nixos/, saves about 80% of the time needed to build the system manual, or about two second on the machine used for testing. build time for a full system config shrank from 9.4s to 7.4s, while turning documentation off entirely shortened the build to 7.1s. pennae2022-01-021-1/+1
|/
* Merge pull request #148785 from pennae/more-option-doc-staticizing•••treewide: more defaultText for optionsGraham Christensen2021-12-171-0/+2
|\
| * nixos/modules: Allow options to be coerced to a string for convenienceSilvan Mosberger2021-12-081-0/+2
* | lib.systems.supported: remove aarch64-darwin from Tier 3 list•••While it is a fact of life that aarch64-darwin is built on Hydra, it has never formally been elevated from the Tier 7 state it was originally assigned in RFC 0046. Since platform Tier status is not only descriptive, but also normative, a consensus to commit to supporting aarch64-darwin would need to be reached. sternenseemann2021-12-161-2/+3
* | lib: fix flake check•••`builtins.currentSystem` is not available in pure eval. For this particular test, we don't really care since it's all about generating .drv files. Fixes the following error: $ nix flake check warning: unknown flake output 'lib' error: attribute 'currentSystem' missing at /nix/store/8wvnlbjxlr90kq2qa6d9zjpj8rqkilr5-source/lib/tests/misc.nix:499:73: 498| let 499| deriv = derivation { name = "test"; builder = "/bin/sh"; system = builtins.currentSystem; }; | ^ 500| in { (use '--show-trace' to show detailed location informat zimbatm2021-12-131-1/+1
* | Merge pull request #149924 from Mic92/aarch64be-embedded•••pkgsCross.aarch64be-embedded: fix evalJörg Thalheim2021-12-091-2/+2
|\ \
| * | pkgsCross.ppcle-embedded: fix evalJörg Thalheim2021-12-091-1/+1
| * | pkgsCross.aarch64be-embedded: fix evalJörg Thalheim2021-12-091-1/+1
* | | pkgsCross.x86_64-netbsd-llvm: mark as brokenJörg Thalheim2021-12-091-0/+1
|/ /
* | Merge pull request #144022 from hercules-ci/lib-modules-optimize-unmatchedDefns•••lib/modules: Short-circuit unmatchedDefns when configs is emptySilvan Mosberger2021-12-073-15/+34
|\ \
| * | lib/modules: Use strict fold' as recursiveUpdate is also strict•••recursiveUpdate does not produce an attrset until it has evaluated both its arguments to weak head normal form. nix-repl> lib.recursiveUpdate (throw "a") (throw "b") error: b nix-repl> lib.recursiveUpdate (throw "a") {} error: a Robert Hensing2021-11-031-2/+1
| * | lib/modules: Fix import* comments•••Very confusing otherwise. Robert Hensing2021-11-031-2/+2
| * | lib/modules: Remove a lib.flip•••In hot code, the overhead (envs, applies) can matter. Robert Hensing2021-11-031-3/+2
| * | lib/tests/modules: Test non-strictness some more•••Doesn't seem to have been a problem actually, but now it won't regress. Robert Hensing2021-11-032-2/+16
| * | lib/modules: Short-circuit unmatchedDefns earlierRobert Hensing2021-11-031-15/+16
| * | lib/modules: Short-circuit unmatchedDefns when configs is emptyRobert Hensing2021-10-311-4/+10
* | | Merge pull request #141856 from ShamrockLee/lib-spdx-license•••lib/meta: add getLicenseFromSpdxId function (resumed)Silvan Mosberger2021-12-072-1/+28
|\ \ \
| * | | lib/meta: add getLicenseFromSpdxId function•••Move function spdxLicense, internally used in yarn2nix to lib/meta.nix, and rename to getLicenseFromSpdxId A similar function is implemented in poetry2nix, but the one originally in yarn2nix seems beter. since it falls back to an license-like attrset for mismatched case instead of a plain string Shamrock Lee2021-12-022-1/+28
* | | | lib/modules: Deprecate args and checkRobert Hensing2021-12-021-1/+6
* | | | lib/modules: Pass legacy args argument along through extendModulesRobert Hensing2021-12-021-4/+21
| |_|/ |/| |
* | | lib/tests: Use standard test syntax•••For consistency. Victor Engmark2021-11-261-1/+1
* | | lib/tests: Anchor config output regexes•••Strengthens the tests by making sure the whole line is matched. Victor Engmark2021-11-261-98/+98
* | | lib/tests: Set hardening pragmas•••Makes any programming errors more likely to show up early. Non-obvious changes because of this: - Ignore the `evalConfig` result in `reportFailure`; we're not checking it at that point. - Pre-increment `$fail` and `$pass` to make sure the arithmetic doesn't result in a zero, which would result in a non-zero exit code for the expression. Victor Engmark2021-11-262-4/+8
* | | lib/tests: Don't return non-zero values from checks•••The exit codes aren't used for anything. Victor Engmark2021-11-261-5/+0
* | | lib/tests: Avoid assigning an array to a string•••As per <https://github.com/koalaman/shellcheck/wiki/SC2124>. Victor Engmark2021-11-261-2/+2
* | | lib/tests: Remove redundant semicolonsVictor Engmark2021-11-261-6/+6
* | | lib/tests: Clarify assignment•••The extra equal sign was confusing, and doesn't seem to be relevant. Victor Engmark2021-11-261-1/+1
* | | lib/tests: Use correct shebang line•••The script uses plenty of non-POSIX features, such as referencing `$BASH_SOURCE`. Victor Engmark2021-11-261-1/+1
* | | lib/tests: Quote variable referencesVictor Engmark2021-11-261-5/+5
* | | lib/tests: `export` separately from assignment•••Avoids hiding the exit code from the assignment. See <https://github.com/koalaman/shellcheck/wiki/SC2155>. Victor Engmark2021-11-261-2/+3
* | | add release notes for 22.05 and update codenameTimothy DeHerrera2021-11-221-1/+1
* | | modules: Add moduleType to module argumentsRobert Hensing2021-11-224-0/+39
* | | modules: Document that extendModules is also a module argumentRobert Hensing2021-11-221-0/+2
|/ /
* | lib.modules: add mkDerivedConfig•••mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b Create config definitions with the same priority as the definition of another option. This should be used for option definitions where one option sets the value of another as a convenience. For instance a config file could be set with a `text` or `source` option, where text translates to a `source` value using `mkDerivedConfig options.text (pkgs.writeText "filename.conf")`. It takes care of setting the right priority using `mkOverride`. Taeer Bar-Yam2021-11-152-1/+21
* | lib/systems: add x86_64-darwin hostPlatformJonathan Ringer2021-11-101-0/+6
* | lib/tests/sources: update to Nix 2.4 cli syntaxBernardo Meurer2021-11-092-3/+7
* | lib/tests/modules.sh: update to Nix 2.4 syntaxBernardo Meurer2021-11-091-12/+12
* | lib: fix escapeXML example in documentation•••The previous example output was forgotten copy-paste from some other function. Robert Helgesson2021-11-021-1/+1
* | Merge pull request #144072 from polykernel/lib-lists-mutuallyexclusive-optimi...Ben Siraphob2021-11-021-5/+2
|\ \
| * | lib/lists: mutuallyExclusive function optimization•••The current implementation of `mutuallyExclusive` builds a new list with length subtracted by one on every recursive call which is expensive. When b is empty, the function still traverses a in its entirety before returning a result. The new implementation uses `any` to check if each element of list b is in list a using `elem`. This maintains short circuiting when list a or b is empty and has a worst case time complexity of O(nm). polykernel2021-11-011-5/+2
| |/