about summary refs log tree commit diff
path: root/lib/default.nix
AgeCommit message (Collapse)AuthorFilesLines
2019-08-05and one more placedanbst1-1/+1
2019-07-14lib: introduce `foreach` = flip mapdanbst1-1/+1
The main purpose is to bring attention to `flip map`, which improves code readablity. It is useful when ad-hoc anonymous function grows two or more lines in `map` application: ``` map (lcfg: let port = lcfg.port; portStr = if port != defaultPort then ":${toString port}" else ""; scheme = if cfg.enableSSL then "https" else "http"; in "${scheme}://cfg.hostName${portStr}" ) (getListen cfg); ``` Compare this to `foreach`-style: ``` foreach (getListen cfg) (lcfg: let port = lcfg.port; portStr = if port != defaultPort then ":${toString port}" else ""; scheme = if cfg.enableSSL then "https" else "http"; in "${scheme}://cfg.hostName${portStr}" ); ``` This is similar to Haskell's `for` (http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Traversable.html#v:for)
2019-04-30check-meta: use system tuple in platformsMatthew Bauer1-1/+1
Fixes #60345
2019-04-09python: Make .isPyPy flag more accurate.Corbin1-1/+1
nix-repl> map (s: s.isPyPy) [ python python3 pypy pypy3 ] [ false false true true ]
2019-03-08lib: add `showWarnings`Jan Malakhovski1-1/+1
2019-01-24lib/modules: Change mkAliasOptionModule to use the priority for the alias.(cdep)illabout1-1/+1
This commit changes the `mkAliasOptionModule` function to make sure that the priority for the aliased option is propagated to the non-aliased option. This also affects the `mkRenamedOptionModule` function in a similar fashion. This also removes the `mkAliasOptionModuleWithPriority` function, since its functionality is now subsumed by `mkAliasOptionModule`. This change was recommended by @nbp: https://github.com/NixOS/nixpkgs/pull/53397#discussion_r245487432
2019-01-18Merge pull request #50561 from oxij/lib/setPrioMichael Raskin1-1/+1
lib: implement `setPrio`
2019-01-14Merge pull request #53397 from cdepillabout/aliasoptionmodule-set-priorityNicolas B. Pierron1-1/+1
lib/modules: Add function to create option alias that respects priority
2019-01-10Merge pull request #53754 from danbst/lib-fake-hashesJörg Thalheim1-0/+1
lib: add fake hashes
2019-01-10lib: add shortcuts for fake hashes (fakeSha256, fakeSha512)danbst1-0/+1
Fake hashes can be used as placeholders for all the places, where Nix expression requires a hash, but we don't yet have one. This should be more convenient than following: - echo|sha256sum, copy into clipboard, go to editor, paste into previously edited place - search nixpkgs for a random package, copy it's hash to cliboard, go to editor, paste into previously edited place Nix can add support for these fake hashes. In that case printed error should contain only 1 hash, so no more problem "which of two hashes from error should I use?" Idea by irc:Synthetica
2019-01-04lib/modules: Add a function to create an option alias that respects the priority(cdep)illabout1-1/+1
This commit adds a function `mkAliasOptionModuleWithPriority`. This function will make an alias to an existing option and copy over the priority. This functionality is needed for PRs like #53041. In that case `nixos-generate-config` added an option to `hardware-configuration.nix` with `mkDefault`. That option was then changed and an alias created for the old name. The end user should be able to set the non-alias option in their `configuration.nix` and have everything work correctly. Without this function, the priority for the option won't be copied over correctly and the end-user will get a message saying they have the same option set to two different values.
2018-12-31Merge master into staging-nextFrederik Rietdijk1-3/+2
2018-12-30Remove composableDerivation, closes #18763Frederik Rietdijk1-3/+2
2018-12-18Merge branch 'staging' into make-perl-pathdvolth1-2/+2
2018-12-15lib.makePerlPath -> perlPackages.makePerlPathvolth1-1/+1
2018-12-11bundlerEnv: ensure dependencies always includedAlyssa Ross1-2/+2
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.
2018-11-22lib: implement `setPrio`Jan Malakhovski1-1/+1
For when `hiPrio` and `lowPrio` are not enough.
2018-09-06lib: move assertMsg and assertOneOf to their own library fileProfpatsch1-4/+5
Since the `assertOneOf` uses `lib.generators`, they are not really trivial anymore and should go into their own library file.
2018-09-06lib/trivial: add assertOneOfProfpatsch1-1/+1
2018-09-06lib/trivial: add assertMsgProfpatsch1-1/+2
2018-08-21as requested:Aaron Andersen1-1/+1
- moved function into strings.nix - renamed function from makePerl5Lib - removed duplicates entries in the resulting value - rewrote the function from scratch after learning a few things (much cleaner now)
2018-06-10lib: bitAnd, bitOr, bitXor (bitsize-agnostic fallback function) (#41491)volth1-4/+4
* lib: bitAnd, bitOr, bitXor * lib: test for bitAnd, bitOr, bitXor * lib: bitsize-agnostic zipIntBits * lib: bitNot * lib: bitNot
2018-06-10lib: add groupBy (#38612)volth1-1/+1
2018-06-05Revert "lib: bitAnd, bitOr, bitXor"Profpatsch1-4/+4
2018-06-01lib: bitAnd, bitOr, bitXorvolth1-4/+4
2018-05-11lib: Add more configure flag helpersJohn Ericson1-19/+20
Add with/without to match enable/disable, and add `--{enable,with}-key=value` versions of both.
2018-04-28treewide: rename version attributesMaximilian Bosch1-1/+1
As suggested in https://github.com/NixOS/nixpkgs/pull/39416#discussion_r183845745 the versioning attributes in `lib` should be consistent to `nixos/version` which implicates the following changes: * `lib.trivial.version` -> `lib.trivial.release` * `lib.trivial.suffix` -> `lib.trivial.versionSuffix` * `lib.nixpkgsVersion` -> `lib.version` As `lib.nixpkgsVersion` is referenced several times in `NixOS/nixpkgs`, `NixOS/nix` and probably several user's setups. As the rename will cause a notable impact it's better to keep `lib.nixpkgsVersion` as alias with a warning yielded by `builtins.trace`.
2018-04-27lib/debug: remove the deprecated strict functionProfpatsch1-1/+1
The grace period was long enough.
2018-04-27lib/debug: add traceValFn, traceValSeqFn, traceValSeqNFnProfpatsch1-4/+5
Being able to modify the value on-the-fly before printing is very useful in practice.
2018-04-08Merge pull request #38611 from volth/nat-sortJörg Thalheim1-1/+1
lib: add naturalSort
2018-04-08lib: add naturalSortvolth1-1/+1
2018-04-07lib: make extensibleSilvan Mosberger1-3/+5
This allows the lib fixed point to be extended with myLib = lib.extend (self: super: { foo = "foo"; }) With this it's possible to have the new modified lib attrset available to all modules when using evalModules myLib.evalModules { modules = [ ({ lib, ... }: { options.bar = lib.mkOption { default = lib.foo; }; }) ]; } => { config = { bar = "foo"; ... }; options = ...; }
2018-03-18Merge pull request #34444 from obsidiansystems/meta-checkJohn Ericson1-1/+1
lib: Fix #30902
2018-03-15lib, stdenv: Check `meta.platforms` against host platform and be open worldJohn Ericson1-1/+1
First, we need check against the host platform, not the build platform. That's simple enough. Second, we move away from exahustive finite case analysis (i.e. exhaustively listing all platforms the package builds on). That only work in a closed-world setting, where we know all platforms we might build one. But with cross compilation, we may be building for arbitrary platforms, So we need fancier filters. This is the closed world to open world change. The solution is instead of having a list of systems (strings in the form "foo-bar"), we have a list of of systems or "patterns", i.e. attributes that partially match the output of the parsers in `lib.systems.parse`. The "check meta" logic treats the systems strings as an exact whitelist just as before, but treats the patterns as a fuzzy whitelist, intersecting the actual `hostPlatform` with the pattern and then checking for equality. (This is done using `matchAttrs`). The default convenience lists for `meta.platforms` are now changed to be lists of patterns (usually a single pattern) in `lib/systems/for-meta.nix` for maximum flexibility under this new system. Fixes #30902
2018-03-06rename lib/maintainers-list.nix into maintainers/maintainer-list.nixJan Malakhovski1-1/+1
Many commits unrelated to `lib` touch that file, this will make `git log ./lib` much saner. This is what I meant in https://github.com/NixOS/nixpkgs/pull/36119#issuecomment-370184101.
2018-03-04Merge pull request #36168 from ryantm/majorminorJörg Thalheim1-1/+1
a single version attribute for expressions previously using "majorVersion"
2018-03-04lib: add versions libraryRyan Mulligan1-1/+1
2018-03-04Revert "Revert "Convert maintainer file entries to attributes, add github ↵Graham Christensen1-1/+1
handles""
2018-03-03Revert "Convert maintainer file entries to attributes, add github handles"Graham Christensen1-1/+1
This reverts commit aa47bac04f06aeea993dc2e2cc6649fde4f31ed7.
2018-03-03Revert "lib/maintainers: rename file to maintainers-list.nix"Graham Christensen1-1/+1
This reverts commit 24684008df7b7c748eeca64de1270a0e6c460a61.
2018-03-04lib/maintainers: rename file to maintainers-list.nixProfpatsch1-1/+1
Based on a request by @oxij: “Can we also rename this file to `maintainers/maintainers-list.nix` while we at this? Motivation: much saner `git log ./lib`.”
2018-03-04Convert maintainer file entries to attributes, add github handlesProfpatsch1-1/+1
Based on https://github.com/NixOS/nixpkgs/pull/34842, the nix-instantiate output was pretty-printed and the validity of the github handles manually verified, by automatically checking whether the user handles exist on github (https://github.com/userhandle, status 200 or 404). Each handle under 5 characters was manually checked (because the collision probability with non-maintainer accounts is high), each missing entry was manually researched. The script used is kept in `maintainers/scripts` as an example of how to work with the mainainers list through nix’ JSON interface.
2018-03-03lib.addPassthru: removed as scheduledVladimír Čunát1-1/+1
2018-02-09lib: implement `compare`, `splitByAndCompare`, and `compareLists`Jan Malakhovski1-3/+4
2018-01-31Add setFunctionArgs lib function.Shea Levy1-2/+2
Among other things, this will allow *2nix tools to output plain data while still being composable with the traditional callPackage/.override interfaces.
2018-01-14Merge #33057: stdenv meta checks: make them lazyVladimír Čunát1-1/+2
Closes #22277 - it's superseded; I have some WIP on evaluation performance, but best do that in a separate PR/thread.
2018-01-11callCabal2nix: Fix calling with a path in the store.Shea Levy1-1/+1
2018-01-09Added `lib.cleanSourceWith` as composable version of `filterSource`Will Fancher1-1/+1
2018-01-03lib: generalize `addPassthru` to `extendDerivation`Jan Malakhovski1-1/+2
2017-12-23Revert "nixos: doc: implement related packages in the manual"Graham Christensen1-3/+3