summary refs log tree commit diff
path: root/lib/attrsets.nix
Commit message (Collapse)AuthorAge
* lib/attrsets: add getMan functionrnhmjoj2020-06-18
|
* lib/attrsets: fix typo in the comment of mapAttrsRecursiveCondPierre Allix2020-06-16
|
* Merge pull request #83241 from Infinisil/valid-drv-nameSilvan Mosberger2020-04-02
|\ | | | | lib/strings: Add `sanitizeDerivationName` function
| * lib/strings: Add sanitizeDerivationName functionSilvan Mosberger2020-03-30
| |
* | Merge pull request #68491 from roberth/fix-dontRecurseIntoAttrsRobert Hensing2020-03-01
|\ \ | |/ |/| Fix dontRecurseIntoAttrs + add to lib + doc
| * Document attrsets.recurseIntoAttrsRobert Hensing2019-09-11
| |
| * top-level: Fix dontRecurseIntoAttrs and include in libRobert Hensing2019-09-11
| | | | | | | | | | dontRecurseIntoAttrs was a noop (x: x), causing the expression dontRecurseIntoAttrs (recurseIntoAttrs a) to have the wrong effect.
| * lib: Add recurseIntoAttrsRobert Hensing2019-09-11
| | | | | | | | | | | | | | | | | | This makes the function available without having to evaluate the Nixpkgs fix-point, making it available in a more natural way for code that deals with multiple Nixpkgs invocations. Its definition is coupled to Nix rather than Nixpkgs, so it will feel right at home in lib.
* | lib/attrsets: Fix error in comment for getAttrFromPathSilvan Mosberger2020-01-20
| |
* | lib: fix typo in 'zipAttrsWith' documentationPeter Simons2019-09-11
|/
* bundlerEnv: ensure dependencies always includedAlyssa Ross2018-12-11
| | | | | | | | | | | | | | | | | | | | | | | | Suppose I have a Gemfile like this: source "https://rubygems.org" gem "actioncable" gem "websocket-driver", group: :test The gemset.nix generated by Bundix 2.4.1 will set ActionCable's groups to [ "default" ], and websocket-driver's to [ "test" ]. This means that the generated bundlerEnv wouldn't include websocket-driver unless the test group was included, even though it's required by the default group. This is arguably a bug in Bundix (websocket-driver's groups should probably be [ "default" "test" ] or just [ "default" ]), but there's no reason bundlerEnv should omit dependencies even given such an input -- it won't necessarily come from Bundix, and it would be good for bundlerEnv to do the right thing. To fix this, filterGemset is now a recursive function, that adds dependencies of gems in the group to the filtered gemset until it stabilises on the gems that match the required groups, and all of their recursive dependencies.
* lib.overrideExisting: Better exampleSilvan Mosberger2018-09-17
|
* lib: Improve overrideExisting implementationSilvan Mosberger2018-09-07
|
* Merge pull request #45038 from symphorien/optoptSilvan Mosberger2018-08-30
|\ | | | | module system: rework module merging
| * module system: rework module mergingSymphorien Gibol2018-08-27
| | | | | | | | The asymptotic complexity is now much lower.
* | lib/recursiveUpdateUntil: fix code to match documentationMathijs Kwik2018-08-15
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ nix repl lib Welcome to Nix version 2.0.2. Type :? for help. Loading 'lib'... Added 350 variables. -- this is the exact example from the function's documentation: nix-repl> recursiveUpdateUntil (path: l: r: path == ["foo"]) { # first attribute set foo.bar = 1; foo.baz = 2; bar = 3; } { #second attribute set foo.bar = 1; foo.quz = 2; baz = 4; } { bar = 3; baz = 4; foo = { bar = 1; baz = 2; quz = 2; }; } -- although the documentation says: { foo.bar = 1; # 'foo.*' from the second set foo.quz = 2; # bar = 3; # 'bar' from the first set baz = 4; # 'baz' from the second set }
* [bot] treewide: remove unused 'inherit' in let blocksvolth2018-07-20
|
* lib.concatMap and lib.mapAttrs to be builtinsvolth2018-07-05
|
* Convert libs to a fixed-pointGraham Christensen2017-09-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This does break the API of being able to import any lib file and get its libs, however I'm not sure people did this. I made this while exploring being able to swap out docFn with a stub in #2305, to avoid functor performance problems. I don't know if that is going to move forward (or if it is a problem or not,) but after doing all this work figured I'd put it up anyway :) Two notable advantages to this approach: 1. when a lib inherits another lib's functions, it doesn't automatically get put in to the scope of lib 2. when a lib implements a new obscure functions, it doesn't automatically get put in to the scope of lib Using the test script (later in this commit) I got the following diff on the API: + diff master fixed-lib 11764a11765,11766 > .types.defaultFunctor > .types.defaultTypeMerge 11774a11777,11778 > .types.isOptionType > .types.isType 11781a11786 > .types.mkOptionType 11788a11794 > .types.setType 11795a11802 > .types.types This means that this commit _adds_ to the API, however I can't find a way to fix these last remaining discrepancies. At least none are _removed_. Test script (run with nix-repl in the PATH): #!/bin/sh set -eux repl() { suff=${1:-} echo "(import ./lib)$suff" \ | nix-repl 2>&1 } attrs_to_check() { repl "${1:-}" \ | tr ';' $'\n' \ | grep "\.\.\." \ | cut -d' ' -f2 \ | sed -e "s/^/${1:-}./" \ | sort } summ() { repl "${1:-}" \ | tr ' ' $'\n' \ | sort \ | uniq } deep_summ() { suff="${1:-}" depth="${2:-4}" depth=$((depth - 1)) summ "$suff" for attr in $(attrs_to_check "$suff" | grep -v "types.types"); do if [ $depth -eq 0 ]; then summ "$attr" | sed -e "s/^/$attr./" else deep_summ "$attr" "$depth" | sed -e "s/^/$attr./" fi done } ( cd nixpkgs #git add . #git commit -m "Auto-commit, sorry" || true git checkout fixed-lib deep_summ > ../fixed-lib git checkout master deep_summ > ../master ) if diff master fixed-lib; then echo "SHALLOW MATCH!" fi ( cd nixpkgs git checkout fixed-lib repl .types )
* lib: trivial spelling fixesTom Saeger2017-04-19
|
* lib: Fix `matchAttrs`John Ericson2017-04-17
|
* Get rid of all `with { inherit... }` and just used `let inherit...`John Ericson2017-03-30
| | | | | | The old forms presumably predates, or were made in ignorance of, `let inherit`. This way is better style as the scoping as more lexical, something which Nix can (or might already!) take advantage of.
* lib: fix typoFranz Pletz2016-12-04
|
* toDerivation: Provide "out" and "outputName" attributesEelco Dolstra2016-09-19
|
* lib.chooseDevOutputs: Use lib.getDevTuomas Tynkkynen2016-09-12
| | | | | Reduces duplication, plus is actually needed for Go packages (at least go-repo-root).
* stdenv.mkDerivation: Use chooseDevOutputsTuomas Tynkkynen2016-08-29
|
* Really remove library functionsEelco Dolstra2016-07-11
| | | | | Throwing a message like "removed 2016-02-29 because unused and broken" is unhelpful because it doesn't show what function was removed.
* add get* helper functions and mass-replace manual outputs search with themNikolay Amiantov2016-04-25
|
* getOutput function: initNikolay Amiantov2016-04-25
|
* Revert "tryAttrs: init function"Nikolay Amiantov2016-04-25
| | | | This reverts commit 338340f993563551d8cb45941da987408abef65f.
* tryAttrs: init functionNikolay Amiantov2016-04-13
|
* lib/attrsets: document all the functionszimbatm2016-03-09
|
* Remove lib.deepSeqList and lib.deepSeqAttrszimbatm2016-03-09
| | | | Both functions are broken and unused in the repo.
* Revert "Merge #12357: nixos docs: show references to packages"Vladimír Čunát2016-02-03
| | | | | | The PR wasn't good enough yet. This reverts commit b2a37ceeea8c38ec71447f8dae1e6890a8cf982d, reversing changes made to 7fa9a1abce623aaf18b22f5dca3fc8a44a494e8d.
* nixos manuals: allow displaying package referencesVladimír Čunát2016-01-13
| | | | | | | | | | | | | | The manuals are now evaluated with each derivation in `pkgs` (recursively) replaced by a fake with path "\${pkgs.path.to.the.attribute}". It isn't perfect, but it seems to cover a vast majority of use cases. Caveat: even if the package is reached by a different means, the path above will be shown and not e.g. `${config.services.foo.package}`. As before, defaults created by `mkDefault` aren't displayed, but documentation shouldn't (mostly) be a reason to use that anymore. Note: t wouldn't be enough to just use `lib.mapAttrsRecursive`, because derivations are also (special) attribute sets.
* add helper to lib/attrsets: hasAttrByPathChristian Zagrodnick2015-12-07
|
* Add stdenv bootstrap tools generation to release.nixEelco Dolstra2015-10-23
|
* Add lib.filterAttrsRecursive functionJaka Hudoklin2015-09-19
|
* Allow options with type "package" to be store pathsEelco Dolstra2015-08-07
| | | | | | | | For example, this allows writing nix.package = /nix/store/786mlvhd17xvcp2r4jmmay6jj4wj6b7f-nix-1.10pre4206_896428c; Also, document types.package in the manual.
* Rename misc.nix -> deprecated.nixEelco Dolstra2015-07-23
|
* More efficient version of filterAttrsEelco Dolstra2015-07-23
|
* lib: Fix matchAttrs by importing builtins.lengthBenjamin Staffin2014-12-30
| | | | | | | | | | | | | | | | Before: nix-repl> :l <nixpkgs> nix-repl> lib.matchAttrs { foo = "bar"; } { bar = "bas"; } error: undefined variable ‘length’ at "/home/benley/nix/nixpkgs/lib/attrsets.nix":317:10 After: nix-repl> :l <nixpkgs> nix-repl> lib.matchAttrs { foo = "bar"; } { bar = "bas"; } false Change-Id: I548d69d50cffe1c63a6f39f76fd09d1835d8d9a2
* Replace hasAttr/getAttr calls with the ? and . operatorsEelco Dolstra2014-10-05
| | | | | For NixOS evaluation, this gives a ~21% reduction in the number of values allocated and a ~4% speedup. It's also more readable.
* Use new primopsEelco Dolstra2014-10-05
|
* Remove backward-compatible implementations of some primopsEelco Dolstra2013-11-12
| | | | Nixpkgs requires at least Nix 1.2 anyway, so these are now useless.
* Add some primops to libEelco Dolstra2013-11-12
|
* Inline some functions on the critical pathEelco Dolstra2013-10-28
|
* Keep position information for option declarations and definitionsEelco Dolstra2013-10-28
| | | | | | | Also, when an option definition fails to type-check, print the file name of the module in which the offending definition occurs, e.g. error: user-thrown exception: The option value `boot.loader.grub.version' in `/etc/nixos/configuration.nix' is not a integer.
* Move pkgs/lib/ to lib/Eelco Dolstra2013-10-10