summaryrefslogtreecommitdiff
path: root/lib (follow)
Commit message (Expand)AuthorAgeFilesLines
* 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
* | modules: Update evalModules docRobert Hensing2021-11-011-3/+26
* | modules: Add visible = "shallow" to hide only sub-optionsRobert Hensing2021-11-011-3/+7
* | modules: Add extendModules to module argsRobert Hensing2021-11-011-15/+19
* | lib.evalModules: Add extendModules and type to result•••Allows the simultaneous construction of top-level invocations and submodule types. This helps structure configuration systems integration code. Robert Hensing2021-11-014-33/+85
|/
* Merge pull request #139284 from r-burns/powernv-kernel-config•••lib/systems: update powernv kernel configRyan Burns2021-10-281-3/+5
|\
| * lib/systems: update powernv kernel config•••PowerNV was looking for a nonexisting zImage file. Remove unnecessary .file / .installTarget. Also add config options needed for default minimal NixOS config and QEMU VirtIO/VirtFS devices. Ryan Burns2021-09-281-3/+5
* | Merge pull request #141789 from pennae/eval-opt•••lib: make extendDerivation lighter on evalSilvan Mosberger2021-10-212-4/+3
|\ \
| * | lib: make extendDerivation lighter on eval•••the fix to extendDerivation in #140051 unwittingly worsened eval performance by quite a bit. set elements alone needed over 1GB extra after the change, which seems disproportionate to how small it was. if we flip the logic used to determine which outputs to install around and keep a "this one exactly" flag in the specific outputs instead of a "all of them" in the root we can avoid most of that cost. pennae2021-10-152-4/+3
* | | licenses: add CAPECMarkus S. Wamser2021-10-151-0/+5
|/ /
* | Merge pull request #140763 from hercules-ci/abort-on-warn•••lib.warn: Add NIX_ABORT_ON_WARN for call tracesRobert Hensing2021-10-131-1/+20
|\ \
| * | lib.warn: Add NIX_ABORT_ON_WARN for call tracesRobert Hensing2021-10-131-1/+20
* | | lib.systems.supported.tier3: add aarch64-darwin•••aarch64-darwin is getting built by hydra zimbatm2021-10-061-0/+1
|/ /
* | Merge pull request #140284 from Infinisil/types-anything-lambdas•••lib/types: Make types.anything merge functionsSilvan Mosberger2021-10-053-4/+18
|\ \
| * | lib/types: Make types.anything merge functions•••Previously it would give an error if there were multiple function definitions. Silvan Mosberger2021-10-023-4/+18
| |/
* | lib: add list of supported systems (#140428)•••Adds the first 3 tiers of RFC0046 that are being used in flake.nix.Jonas Chevalier2021-10-052-0/+25
* | Merge pull request #136909 from ncfavier/cleanup-defaults-examples•••nixos/doc: clean up defaults and examplesRobert Hensing2021-10-042-7/+21
|\ \
| * | lib/options: add literalExpression and literalDocBook, deprecate literalExampleNaïm Favier2021-10-032-7/+21
* | | Merge pull request #140136 from rnhmjoj/matrix-ids•••maintainers/maintainers-list: add Matrix IDsMichele Guerini Rocco2021-10-031-0/+4
|\ \ \
| * | | lib/tests/maintainers: add matrix optionrnhmjoj2021-10-011-0/+4
* | | | lib: add function escapeXML•••Given a string, this function returns a string that can be inserted verbatim in an XML document. Robert Helgesson2021-10-033-1/+19
| |/ / |/| |
* | | Merge pull request #140051 from pennae/extend-derivation•••fix nested calls to extendDerivationSilvan Mosberger2021-10-021-1/+2
|\ \ \ | |/ / |/| |
| * | fix nested calls to extendDerivation•••if extendDerivation is called on something that already had extendDerivation called on it (eg a mkDerivation result) the second call will set outputUnspecified=true on every output by way of propagating attributes of the full derivation to the individual outputs. this in turn causes buildEnv--and thus nix-shell and environment.systemPackages--to install every output of such a derivation even when only a specific output was requested, which renders the point of multiple outputs moot. this happens in python modules (see #139756), though it seems that tcl and possibly others should also be affected. pennae2021-09-301-1/+2
| |/
* | ocamlPackages.lustre-v6: init at 6.103.3Delta2021-09-301-0/+5
* | Merge pull request #131205 from Ma27/showdefs-overflow•••lib/modules: improve errors for `options`/`config`-mixupsLinus Heckemann2021-09-294-8/+65
|\ \ | |/ |/|
| * lib/generators: fix error messageMaximilian Bosch2021-09-281-2/+2
| * lib/modules: grammar fix in error msgMaximilian Bosch2021-08-261-1/+1
| * lib/generators: move limit detection into `withRecursion`•••As suggested in #131205. Now it's possible to pretty-print a value with `lib.generators` like this: with lib.generators; toPretty { } (withRecursion { depthLimit = 10; } /* arbitrarily complex value */) Also, this can be used for any other pretty-printer now if needed. Maximilian Bosch2021-08-263-19/+37
| * lib/modules: fix error-message when declaring an option inside `config'•••The message I originally implemented here was to catch a mixup of `config' and `options' in a `types.submodule'[1]. However it looks rather weird for a wrongly declared top-level option. So I decided to throw error: The option `foo' does not exist. Definition values: - In `<unknown-file>': { bar = { _type = "option"; type = { _type = "option-type"; ... It seems as you're trying to declare an option by placing it into `config' rather than `options'! for an expression like with import ./lib; evalModules { modules = [ { foo.bar = mkOption { type = types.str; }; } ]; } [1] fa30c9abed61f30218a211842204705986d486f9 Maximilian Bosch2021-08-251-6/+17
| * lib/options: use `depthLimit` for `toPretty` when showing a definition•••When having a bogus declaration such as { lib, ... }: { foo.bar = mkOption { type = types.str; }; } the evaluation will terminate with a not-so helpful error: stack overflow (possible infinite recursion) To make sure a useful error is still provided, I added a `depthLimit` of `10` which should be perfectly sufficient to `toPretty` when it's used in an error-case for `showDefs`. Maximilian Bosch2021-08-251-1/+1
| * lib/generators/toPretty: add evaluation-limit•••When having e.g. recursive attr-set, it cannot be printed which is solved by Nix itself like this: $ nix-instantiate --eval -E 'let a.b = 1; a.c = a; in builtins.trace a 1' trace: { b = 1; c = <CYCLE>; } 1 However, `generators.toPretty` tries to evaluate something until it's done which can result in a spurious `stack-overflow`-error: $ nix-instantiate --eval -E 'with import <nixpkgs/lib>; generators.toPretty { } (mkOption { type = types.str; })' error: stack overflow (possible infinite recursion) Those attr-sets are in fact rather common, one example is shown above, a `types.<type>`-declaration is such an example. By adding an optional `depthLimit`-argument, `toPretty` will stop evaluating as soon as the limit is reached: $ nix-instantiate --eval -E 'with import ./Projects/nixpkgs-update-int/lib; generators.toPretty { depthLimit = 2; } (mkOption { type = types.str; })' |xargs -0 echo -e "{ _type = \"option\"; type = { _type = \"option-type\"; check = <function>; deprecationMessage = null; description = \"string\"; emptyValue = { }; functor = { binOp = <unevaluated>; name = <unevaluated>; payload = <unevaluated>; type = <unevaluated>; wrapped = <unevaluated>; }; getSubModules = null; getSubOptions = <function>; merge = <function>; name = \"str\"; nestedTypes = { }; substSubModules = <function>; typeMerge = <function>; }; }" Optionally, it's also possible to let `toPretty` throw an error if the limit is exceeded. Maximilian Bosch2021-08-252-7/+35
* | lib.cleanSource: ignore sockets•••I'm working on a project that involves running a virtual machine monitor program, which creates a control socket in the project directory (because it doesn't make sense to put it anywhere else). This obviously isn't part of the source of my program, so I think cleanSource should filter it out. Alyssa Ross2021-09-171-1/+3
* | lib.generators.toINI: serialize derivations to string•••This is the common case when passing a derivation, we want to access the store path. zimbatm2021-09-121-0/+2
* | lib.generators.toGitINI: don't traverse derivations•••Consider a derivation a value to be serialized. nix-repl> lib.generators.toGitINI { hello = { drv = pkgs.hello; }; } error: evaluation aborted with the following error message: 'generators.mkValueStringDefault: attrsets not supported: <derivation /nix/store/533q15q67sl6dl0272dyi7m7w5pwkkjh-hello-2.10.drv>' Fixes #137390 zimbatm2021-09-121-1/+1
* | lib/systems: add minimal s390x-linux cross-compile support•••Tested basic functionality as: $ nix-build --arg crossSystem '{ config = "s390x-unknown-linux-gnu"; }' -A re2c $ file ./result/bin/re2c $ ./result/bin/re2c: ELF 64-bit MSB executable, IBM S/390, version 1 (SYSV), dynamically linked, interpreter ...-gnu-2.33-50/lib/ld64.so.1, for GNU/Linux 2.6.32, not stripped $ qemu-s390x ./result/bin/re2c --version re2c 2.2 Sergei Trofimovich2021-09-095-3/+10
* | lib/strings: fix infinite recursion on concatStringsSep fallback•••The current implementation of the concatStringsSep fallback references concatStrings whcih is just a partial application of concatStringsSep, forming a circular dependency. Although this will almost never be encountered as (assuming the user does not explicitly trigger it): 1. the or operator will short circuit both in lazy and strict evaluation 2. this can only occur in Nix versions prior to 1.10 which is not compatible with various nix operations as of 2.3.15 However it is still important if scopedImport is used or the builtins have been overwritten. lib.foldl' is used instead of builtins.foldl' as the foldl' primops was introduced in the same release as concatStringsSep. polykernel2021-08-261-1/+1
* | Merge pull request #135794 from shlevy/composeManyFlakeCompat•••lib.compose{Many,}Extensions: Make compatible with nix flake checkRobert Hensing2021-08-261-5/+5
|\ \
| * | lib.compose{Many,}Extensions: Make compatible with nix flake checkShea Levy2021-08-261-5/+5
| |/
* / replace dead linksPaul-Nicolas Madelaine2021-08-261-2/+2
|/
* lib: optimize setAttrByPath and cleaup imports•••- Remove inheritance of `lists.fold` as it isn't used anywhere. - Inherit `foldl'` for consistency as only `cartesianProductOfSets` explicitly reference lib. - Inline `foldr` to generate nested attrs instead of using `listToAttrs` and `tail`. polykernel2021-08-231-6/+9
* lib: export strings/escapeRegex•••I see no reason why I should be disallowed from using it. Harrison Houghton2021-08-221-1/+1
* Merge pull request #134763 from r-burns/fix-scaleway•••lib/systems: fix scaleway-c1 platformLuke Granger-Brown2021-08-211-1/+1
|\