3
0
Fork 0
forked from mirrors/nixpkgs
Commit graph

67 commits

Author SHA1 Message Date
Michael Raskin 4d0e1b792f
Merge pull request #50561 from oxij/lib/setPrio
lib: implement `setPrio`
2019-01-18 08:23:31 +00:00
Nicolas B. Pierron a3beabf327
Merge pull request #53397 from cdepillabout/aliasoptionmodule-set-priority
lib/modules: Add function to create option alias that respects priority
2019-01-14 20:28:28 +01:00
Jörg Thalheim b75aff7202
Merge pull request #53754 from danbst/lib-fake-hashes
lib: add fake hashes
2019-01-10 17:56:09 +00:00
danbst 68a6b47b8c lib: add shortcuts for fake hashes (fakeSha256, fakeSha512)
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-10 19:27:35 +02:00
(cdep)illabout b81b3ad1b0
lib/modules: Add a function to create an option alias that respects the priority
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.
2019-01-04 18:35:10 +09:00
Frederik Rietdijk 070290bda7 Merge master into staging-next 2018-12-31 12:00:36 +01:00
Frederik Rietdijk c6e043d57c Remove composableDerivation, closes #18763 2018-12-30 12:33:45 +00:00
volth fed7914539
Merge branch 'staging' into make-perl-pathd 2018-12-18 17:13:27 +00:00
volth bb9557eb7c lib.makePerlPath -> perlPackages.makePerlPath 2018-12-15 03:50:31 +00:00
Alyssa Ross 67b1265fb3
bundlerEnv: ensure dependencies always included
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-12-11 21:26:07 +00:00
Jan Malakhovski 1b3629ef34 lib: implement setPrio
For when `hiPrio` and `lowPrio` are not enough.
2018-11-22 08:59:48 +00:00
Profpatsch efdf618330 lib: move assertMsg and assertOneOf to their own library file
Since the `assertOneOf` uses `lib.generators`, they are not really trivial
anymore and should go into their own library file.
2018-09-06 18:14:27 +02:00
Profpatsch 320cdecd16 lib/trivial: add assertOneOf 2018-09-06 18:14:27 +02:00
Profpatsch 0e2aa97f3a lib/trivial: add assertMsg 2018-09-06 18:14:27 +02:00
Aaron Andersen 74d446176e as requested:
- 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-08-21 20:11:28 +02:00
volth 3c2bbe217c lib: bitAnd, bitOr, bitXor (bitsize-agnostic fallback function) (#41491)
* lib: bitAnd, bitOr, bitXor

* lib: test for bitAnd, bitOr, bitXor

* lib: bitsize-agnostic zipIntBits

* lib: bitNot

* lib: bitNot
2018-06-10 21:25:48 +02:00
volth 4e85c4ff27 lib: add groupBy (#38612) 2018-06-10 19:31:09 +02:00
Profpatsch f98272d6e2 Revert "lib: bitAnd, bitOr, bitXor" 2018-06-05 18:45:20 +02:00
volth 0addac3b0a lib: bitAnd, bitOr, bitXor 2018-06-01 21:36:31 +00:00
John Ericson 9e9cdd7027 lib: Add more configure flag helpers
Add with/without to match enable/disable, and add
`--{enable,with}-key=value` versions of both.
2018-05-11 17:43:35 +02:00
Maximilian Bosch 9274ea3903
treewide: rename version attributes
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-28 14:23:53 +02:00
Profpatsch a455637d28 lib/debug: remove the deprecated strict function
The grace period was long enough.
2018-04-27 18:59:39 +02:00
Profpatsch a5f6cdfd7e lib/debug: add traceValFn, traceValSeqFn, traceValSeqNFn
Being able to modify the value on-the-fly before printing is very useful in
practice.
2018-04-27 18:59:39 +02:00
Jörg Thalheim 0fe11dbedd
Merge pull request #38611 from volth/nat-sort
lib: add naturalSort
2018-04-08 22:44:15 +01:00
volth 25c2fd80b1 lib: add naturalSort 2018-04-08 13:18:13 +00:00
Silvan Mosberger e1dee4efcb lib: make extensible
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-04-07 13:21:49 -04:00
John Ericson 2fa2197a96
Merge pull request #34444 from obsidiansystems/meta-check
lib: Fix #30902
2018-03-18 13:51:03 -04:00
John Ericson c26252af3e lib, stdenv: Check meta.platforms against host platform and be open world
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-15 00:44:34 -04:00
Jan Malakhovski 610b5b8045 rename lib/maintainers-list.nix into maintainers/maintainer-list.nix
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-06 14:15:21 +00:00
Jörg Thalheim 73774ef8f9
Merge pull request #36168 from ryantm/majorminor
a single version attribute for expressions previously using "majorVersion"
2018-03-04 20:06:48 +00:00
Ryan Mulligan a9d0778cd4 lib: add versions library 2018-03-04 06:28:34 -08:00
Graham Christensen f7da7fa0c3 Revert "Revert "Convert maintainer file entries to attributes, add github handles"" 2018-03-04 05:13:19 +01:00
Graham Christensen b9f1a76f30 Revert "Convert maintainer file entries to attributes, add github handles"
This reverts commit aa47bac04f.
2018-03-03 22:34:17 -05:00
Graham Christensen 3e55c5d1f7 Revert "lib/maintainers: rename file to maintainers-list.nix"
This reverts commit 24684008df.
2018-03-03 22:34:17 -05:00
Profpatsch 24684008df lib/maintainers: rename file to maintainers-list.nix
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-04 03:26:44 +01:00
Profpatsch aa47bac04f Convert maintainer file entries to attributes, add github handles
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-04 03:26:44 +01:00
Vladimír Čunát 7b2cf5b12e
lib.addPassthru: removed as scheduled 2018-03-03 17:57:38 +01:00
Jan Malakhovski ee3220440d lib: implement compare, splitByAndCompare, and compareLists 2018-02-09 19:51:05 +00:00
Shea Levy 943592f698
Add setFunctionArgs lib function.
Among other things, this will allow *2nix tools to output plain data
while still being composable with the traditional
callPackage/.override interfaces.
2018-01-31 14:02:19 -05:00
Vladimír Čunát 67e8392383
Merge #33057: stdenv meta checks: make them lazy
Closes #22277 - it's superseded;  I have some WIP on evaluation
performance, but best do that in a separate PR/thread.
2018-01-14 21:41:31 +01:00
Shea Levy 4e78aeb441
callCabal2nix: Fix calling with a path in the store. 2018-01-11 10:17:56 -05:00
Will Fancher 7e5f37d73b Added lib.cleanSourceWith as composable version of filterSource 2018-01-09 18:59:03 -05:00
Jan Malakhovski b1ca8517ee lib: generalize addPassthru to extendDerivation 2018-01-03 12:20:24 +00:00
Graham Christensen b5a61f2c59
Revert "nixos: doc: implement related packages in the manual" 2017-12-23 07:19:45 -05:00
Jan Malakhovski bccab965b9 lib: implement compare, splitByAndCompare, and compareLists 2017-12-07 21:26:30 +00:00
Orivej Desh 3c81b7639a lib: delete reference to lib/sandbox.nix
after it was deleted in 0fe7bde3d8
2017-11-19 10:19:21 +00:00
Shea Levy 8f33315f8f Revert "Fix evaluation"
Reverting #27319

This reverts commit 751d397ad4.
2017-09-29 09:10:48 -04:00
Shea Levy ca535da1fb Revert "Fix tarball"
Reverting #27319

This reverts commit 9ce7175cfe.
2017-09-29 09:10:30 -04:00
Shea Levy d96da5af87 Revert "Avoid polluting lib namespace unncessarily"
Reverting #27319

This reverts commit 01a3f0b8aa.
2017-09-29 09:09:53 -04:00
Shea Levy 01a3f0b8aa Avoid polluting lib namespace unncessarily 2017-09-28 18:51:20 -04:00