3
0
Fork 0
forked from mirrors/nixpkgs
Commit graph

39 commits

Author SHA1 Message Date
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
Silvan Mosberger c7104d97c8
lib.overrideExisting: Better example 2018-09-17 23:28:47 +02:00
Silvan Mosberger 5cfdec6e94
lib: Improve overrideExisting implementation 2018-09-07 21:00:14 +02:00
Silvan Mosberger 9113696051
Merge pull request #45038 from symphorien/optopt
module system: rework module merging
2018-08-30 20:08:45 +02:00
Symphorien Gibol 526d604670 module system: rework module merging
The asymptotic complexity is now much lower.
2018-08-27 17:11:58 +02:00
Mathijs Kwik b63ec64521 lib/recursiveUpdateUntil: fix code to match documentation
$ 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
}
2018-08-15 17:16:56 +02:00
volth 6d2857a311 [bot] treewide: remove unused 'inherit' in let blocks 2018-07-20 19:38:19 +00:00
volth e9a6c7cebb lib.concatMap and lib.mapAttrs to be builtins 2018-07-05 03:08:00 +00:00
Graham Christensen 152c63c9ff
Convert libs to a fixed-point
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
  )
2017-09-16 21:36:43 -04:00
Tom Saeger 5989515b94 lib: trivial spelling fixes 2017-04-19 19:37:55 -05:00
John Ericson fffcee35f9 lib: Fix matchAttrs 2017-04-17 17:13:01 -04:00
John Ericson 4c0d7da183 Get rid of all with { inherit... } and just used let inherit...
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.
2017-03-30 03:05:05 -04:00
Franz Pletz 67332d4e4c
lib: fix typo 2016-12-04 01:39:51 +01:00
Eelco Dolstra 1c043e0749 toDerivation: Provide "out" and "outputName" attributes 2016-09-19 20:02:07 +02:00
Tuomas Tynkkynen e0b5eef4e7 lib.chooseDevOutputs: Use lib.getDev
Reduces duplication, plus is actually needed for Go packages (at least
go-repo-root).
2016-09-12 00:18:18 +03:00
Tuomas Tynkkynen 5326e85f3d stdenv.mkDerivation: Use chooseDevOutputs 2016-08-29 14:49:51 +03:00
Eelco Dolstra 532211c68d Really remove library functions
Throwing a message like "removed 2016-02-29 because unused and broken"
is unhelpful because it doesn't show what function was removed.
2016-07-11 16:34:46 +02:00
Nikolay Amiantov 5ff40ddedf add get* helper functions and mass-replace manual outputs search with them 2016-04-25 13:24:39 +03:00
Nikolay Amiantov 7d3e75827b getOutput function: init 2016-04-25 13:22:41 +03:00
Nikolay Amiantov 5f3987f44f Revert "tryAttrs: init function"
This reverts commit 338340f993.
2016-04-25 13:22:41 +03:00
Nikolay Amiantov 338340f993 tryAttrs: init function 2016-04-13 22:05:45 +03:00
zimbatm 523e328318 lib/attrsets: document all the functions 2016-03-09 19:59:57 +00:00
zimbatm a086858ef5 Remove lib.deepSeqList and lib.deepSeqAttrs
Both functions are broken and unused in the repo.
2016-03-09 19:59:57 +00:00
Vladimír Čunát 889351af8b Revert "Merge #12357: nixos docs: show references to packages"
The PR wasn't good enough yet.
This reverts commit b2a37ceeea, reversing
changes made to 7fa9a1abce.
2016-02-03 12:16:33 +01:00
Vladimír Čunát b9f6dfe8c5 nixos manuals: allow displaying package references
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.
2016-01-13 12:03:18 +01:00
Christian Zagrodnick ce96057588 add helper to lib/attrsets: hasAttrByPath 2015-12-07 11:04:14 +01:00
Eelco Dolstra 45c7dd7d98 Add stdenv bootstrap tools generation to release.nix 2015-10-23 13:05:36 +02:00
Jaka Hudoklin 341ac85644 Add lib.filterAttrsRecursive function 2015-09-19 00:33:44 +02:00
Eelco Dolstra 214d4fb73c Allow options with type "package" to be store paths
For example, this allows writing

  nix.package = /nix/store/786mlvhd17xvcp2r4jmmay6jj4wj6b7f-nix-1.10pre4206_896428c;

Also, document types.package in the manual.
2015-08-07 03:09:57 +02:00
Eelco Dolstra 0ae8b365b3 Rename misc.nix -> deprecated.nix 2015-07-23 18:31:54 +02:00
Eelco Dolstra 3cd5fd8bb3 More efficient version of filterAttrs 2015-07-23 16:49:13 +02:00
Benjamin Staffin 4dd93dbf25 lib: Fix matchAttrs by importing builtins.length
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
2014-12-30 15:07:29 -08:00
Eelco Dolstra 97220c973f Replace hasAttr/getAttr calls with the ? and . operators
For NixOS evaluation, this gives a ~21% reduction in the number of
values allocated and a ~4% speedup. It's also more readable.
2014-10-05 01:11:06 +02:00
Eelco Dolstra 0e120dc68f Use new primops 2014-10-05 01:10:52 +02:00
Eelco Dolstra a8b693fef7 Remove backward-compatible implementations of some primops
Nixpkgs requires at least Nix 1.2 anyway, so these are now useless.
2013-11-12 13:50:45 +01:00
Eelco Dolstra 785eaf2cea Add some primops to lib 2013-11-12 13:48:30 +01:00
Eelco Dolstra b479dac8df Inline some functions on the critical path 2013-10-28 22:45:55 +01:00
Eelco Dolstra 40913958a2 Keep position information for option declarations and definitions
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.
2013-10-28 22:45:55 +01:00
Eelco Dolstra 5fef92c4a0 Move pkgs/lib/ to lib/ 2013-10-10 13:28:21 +02:00
Renamed from pkgs/lib/attrsets.nix (Browse further)