summary refs log tree commit diff
path: root/lib/default.nix
Commit message (Collapse)AuthorAge
* Merge pull request #78337 from Profpatsch/lib-improve-cli-moduleProfpatsch2020-01-24
|\ | | | | lib: improve cli module
| * lib/cli: unexport symbols & sort with generatorsProfpatsch2020-01-23
| | | | | | | | | | | | | | lib/cli is very similar to generators, so it should follow largely the same interface. Similar to how generators isn’t exported, we should also namespace cli by default (plus “cli” is only three characters to type).
* | nixos/version: fix case where .git is a symlinkFranz Pletz2020-01-20
|/ | | | | | | | | | | Before c9214c394b248e1f26e45dbe1be2bd82363af3a6 and 9d396d2e426b9a765de0b8999aa214f1259633e6 if .git is symlink the version would gracefully default to no git revision. With those changes an exception is thrown instead. This introduces a new function `pathIsGitRepo` that checks if `commitIdFromGitRepo` fails without error so we don't have to reimplement this logic again and can fail gracefully.
* Merge pull request #75539 from Gabriel439/gabriel/renderOptionsRobert Hensing2020-01-14
|\ | | | | Add `pkgs.lib.encodeGNUCommandLine`
| * Export toGNUCommandLine Gabriel Gonzalez2020-01-05
| | | | | | | | | | ... as suggested by @roberth Co-Authored-By: Robert Hensing <roberth@users.noreply.github.com>
| * Rename `renderOptions` to `encodeGNUCommandLine`Gabriel Gonzalez2019-12-13
| | | | | | | | ... as suggested by @edolstra
| * Add `pkgs.lib.renderOptions`Gabriel Gonzalez2019-12-11
| | | | | | | | | | | | This adds a new utility to intelligently convert Nix records to command line options to reduce boilerplate for simple use cases and to also reduce the likelihood of malformed command lines
* | lib.commitIdFromGitRepo: support git-worktreeelseym2020-01-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | lib.commitIdFromGitRepo now resolves the refs from the parent repository in case the supplied path is a file containing the path to said repository. this adds support for git-worktree and things alike. see gitrepository-layout(5). this also: - adds a new boolean function lib.pathIsRegularFile to check whether a path is a regular file - patches lib.revisionWithDefault and the revision and versionSuffix attributes in config.system.nixos in order to support git-worktrees
* | lib/modules: Recursive disabledModulesSilvan Mosberger2020-01-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this change, disabledModules applies recursively, meaning if you have a module "foo.nix" with imports = [ ./bar.nix ]; then setting disabledModules = [ "foo.nix" ]; will disable both "foo.nix" and "bar.nix", whereas previously only "foo.nix" would be disabled. This change along with https://github.com/NixOS/nixpkgs/pull/61570 allows modules to be fully disabled even when they have some `mkRenamedOption` imports.
* | lib/modules: Don't pack submodules speciallySilvan Mosberger2020-01-01
|/ | | | | This has the beneficial side effect of allowing paths to be used as modules in types.{submodule,submoduleWith}
* Merge remote-tracking branch 'upstream/master' into wrapper-pname-supportJohn Ericson2019-11-24
|\
| * lib/trivial: add `pipe` functionProfpatsch2019-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `pipe` is a useful operator for creating pipelines of functions. It works around the usual problem of e.g. string operations becoming deeply nested functions. In principle, there are four different ways this function could be written: pipe val [ f1 .. fn ] pipe val [ fn .. f1 ] compose [ f1 .. fn ] val compose [ fn .. f1 ] val The third and fourth form mirror composition of functions, they would be the same as e.g. `(f1 << f2 << f3 .. << fn) val`. However, it is not clear which direction the list should have (as one can see in the second form, which is the most absurd. In order not to confuse users, we decide for the most “intuitive” form, which mirrors the way unix pipes work (thus the name `pipe`). The flow of data goes from left to right. Co-Authored-By: Silvan Mosberger <infinisil@icloud.com>
| * lib/versions: expose splitVersionJoachim Fasting2019-09-26
| |
* | lib: Add getName to mirror getVersionJohn Ericson2019-11-24
|/
* and one more placedanbst2019-08-05
|
* lib: introduce `foreach` = flip mapdanbst2019-07-14
| | | | | | | | | | | | | | | | | | | | | | | | | 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)
* check-meta: use system tuple in platformsMatthew Bauer2019-04-30
| | | | Fixes #60345
* python: Make .isPyPy flag more accurate.Corbin2019-04-09
| | | | | nix-repl> map (s: s.isPyPy) [ python python3 pypy pypy3 ] [ false false true true ]
* lib: add `showWarnings`Jan Malakhovski2019-03-08
|
* lib/modules: Change mkAliasOptionModule to use the priority for the alias.(cdep)illabout2019-01-24
| | | | | | | | | | | | | | | 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
* Merge pull request #50561 from oxij/lib/setPrioMichael Raskin2019-01-18
|\ | | | | lib: implement `setPrio`
| * lib: implement `setPrio`Jan Malakhovski2018-11-22
| | | | | | | | For when `hiPrio` and `lowPrio` are not enough.
* | Merge pull request #53397 from cdepillabout/aliasoptionmodule-set-priorityNicolas B. Pierron2019-01-14
|\ \ | | | | | | lib/modules: Add function to create option alias that respects priority
| * | lib/modules: Add a function to create an option alias that respects the priority(cdep)illabout2019-01-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #53754 from danbst/lib-fake-hashesJörg Thalheim2019-01-10
|\ \ \ | | | | | | | | lib: add fake hashes
| * | | lib: add shortcuts for fake hashes (fakeSha256, fakeSha512)danbst2019-01-10
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge master into staging-nextFrederik Rietdijk2018-12-31
|\| |
| * | Remove composableDerivation, closes #18763Frederik Rietdijk2018-12-30
| | |
* | | Merge branch 'staging' into make-perl-pathdvolth2018-12-18
|\| |
| * | 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.makePerlPath -> perlPackages.makePerlPathvolth2018-12-15
|/
* lib: move assertMsg and assertOneOf to their own library fileProfpatsch2018-09-06
| | | | | Since the `assertOneOf` uses `lib.generators`, they are not really trivial anymore and should go into their own library file.
* lib/trivial: add assertOneOfProfpatsch2018-09-06
|
* lib/trivial: add assertMsgProfpatsch2018-09-06
|
* as requested:Aaron Andersen2018-08-21
| | | | | | | - 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)
* lib: bitAnd, bitOr, bitXor (bitsize-agnostic fallback function) (#41491)volth2018-06-10
| | | | | | | | | | | | * lib: bitAnd, bitOr, bitXor * lib: test for bitAnd, bitOr, bitXor * lib: bitsize-agnostic zipIntBits * lib: bitNot * lib: bitNot
* lib: add groupBy (#38612)volth2018-06-10
|
* Revert "lib: bitAnd, bitOr, bitXor"Profpatsch2018-06-05
|
* lib: bitAnd, bitOr, bitXorvolth2018-06-01
|
* lib: Add more configure flag helpersJohn Ericson2018-05-11
| | | | | Add with/without to match enable/disable, and add `--{enable,with}-key=value` versions of both.
* treewide: rename version attributesMaximilian Bosch2018-04-28
| | | | | | | | | | | | | | | 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`.
* lib/debug: remove the deprecated strict functionProfpatsch2018-04-27
| | | | The grace period was long enough.
* lib/debug: add traceValFn, traceValSeqFn, traceValSeqNFnProfpatsch2018-04-27
| | | | | Being able to modify the value on-the-fly before printing is very useful in practice.
* Merge pull request #38611 from volth/nat-sortJörg Thalheim2018-04-08
|\ | | | | lib: add naturalSort
| * lib: add naturalSortvolth2018-04-08
| |
* | lib: make extensibleSilvan Mosberger2018-04-07
|/ | | | | | | | | | | | | | | | | | | | | 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 = ...; }
* Merge pull request #34444 from obsidiansystems/meta-checkJohn Ericson2018-03-18
|\ | | | | lib: Fix #30902
| * lib, stdenv: Check `meta.platforms` against host platform and be open worldJohn Ericson2018-03-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | rename lib/maintainers-list.nix into maintainers/maintainer-list.nixJan Malakhovski2018-03-06
|/ | | | | | 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.
* Merge pull request #36168 from ryantm/majorminorJörg Thalheim2018-03-04
|\ | | | | a single version attribute for expressions previously using "majorVersion"