Commit Graph

29 Commits

Author SHA1 Message Date
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
Shea Levy
9ce7175cfe Fix tarball 2017-09-28 18:44:10 -04:00
Shea Levy
751d397ad4 Fix evaluation 2017-09-28 18:40:11 -04: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
John Ericson
87b4a91fc4 lib: Move fixed-point combinators out of trivial
Trivia != prelude. This is a better organized and less likely to
scare off new contributors.
2017-05-29 18:09:52 -04:00
John Ericson
f0b634c7e8 Merge pull request #24610 from Ericson2314/platform-normalization
Platform normalization
2017-04-17 17:28:01 -04:00
John Ericson
2227789392 lib: Collect system/platform related files
Previously, platforms was a random thing in top-level
2017-04-17 17:13:01 -04:00
Profpatsch
9b7b950832 /lib/default.nix: Add file docstring & unit test hint 2017-04-12 00:01:38 +02:00
Shea Levy
56e71f62dc Add locateDominatingFile lib function 2017-03-04 13:15:23 -05:00
Profpatsch
61311665cb lib: add ini configuration generator
Many configurations are INI-style files. Attribute sets can be mapped
rather painlessly to the INI format.
This adds a function toINI inside a new generators library section.
Also, unit tests for the default values are provided.
2016-11-17 19:46:41 +01:00
Profpatsch
61462c94e6 lib/fetchers.nix: factor out impure proxy vars (#18702)
Apparently everyone just copied those variables, instead of creating a
library constant for them. Some even removed the comment. -.-
2016-09-17 21:50:01 +02:00
Profpatsch
bd44207786 lib/default.nix: reorder imports for clarity
Group imports according to the kind of functions they contain, in a more
descriptive manner.
2016-09-15 01:21:42 +02:00
Jude Taylor
7039b24cdc cherry-pick lib.sandbox into master 2015-11-19 11:33:21 -08:00
Eelco Dolstra
0ae8b365b3 Rename misc.nix -> deprecated.nix 2015-07-23 18:31:54 +02:00
Eelco Dolstra
785eaf2cea Add some primops to lib 2013-11-12 13:48:30 +01:00
Eelco Dolstra
0e333688ce Big cleanup of the NixOS module system
The major changes are:

* The evaluation is now driven by the declared options.  In
  particular, this fixes the long-standing problem with lack of
  laziness of disabled option definitions.  Thus, a configuration like

    config = mkIf false {
      environment.systemPackages = throw "bla";
    };

  will now evaluate without throwing an error.  This also improves
  performance since we're not evaluating unused option definitions.

* The implementation of properties is greatly simplified.

* There is a new type constructor "submodule" that replaces
  "optionSet".  Unlike "optionSet", "submodule" gets its option
  declarations as an argument, making it more like "listOf" and other
  type constructors.  A typical use is:

    foo = mkOption {
      type = type.attrsOf (type.submodule (
        { config, ... }:
        { bar = mkOption { ... };
          xyzzy = mkOption { ... };
        }));
    };

  Existing uses of "optionSet" are automatically mapped to
  "submodule".

* Modules are now checked for unsupported attributes: you get an error
  if a module contains an attribute other than "config", "options" or
  "imports".

* The new implementation is faster and uses much less memory.
2013-10-28 22:45:55 +01:00
Eelco Dolstra
d49f141a79 Manual: When building from the channel, link to the exact Git revision 2013-10-24 02:03:10 +02:00
Eelco Dolstra
5fef92c4a0 Move pkgs/lib/ to lib/ 2013-10-10 13:28:21 +02:00