summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/attrsets.nix8
-rw-r--r--lib/customisation.nix2
-rw-r--r--lib/debug.nix4
-rw-r--r--lib/default.nix173
-rw-r--r--lib/deprecated.nix9
-rw-r--r--lib/fetchers.nix1
-rw-r--r--lib/filesystem.nix1
-rw-r--r--lib/fixed-points.nix1
-rw-r--r--lib/generators.nix7
-rw-r--r--lib/licenses.nix15
-rw-r--r--lib/lists.nix4
-rw-r--r--lib/maintainers.nix22
-rw-r--r--lib/meta.nix3
-rw-r--r--lib/modules.nix16
-rw-r--r--lib/options.nix11
-rw-r--r--lib/sandbox.nix3
-rw-r--r--lib/sources.nix3
-rw-r--r--lib/strings-with-deps.nix7
-rw-r--r--lib/strings.nix4
-rw-r--r--lib/systems/default.nix13
-rw-r--r--lib/systems/doubles.nix9
-rw-r--r--lib/systems/examples.nix4
-rw-r--r--lib/systems/inspect.nix7
-rw-r--r--lib/systems/parse.nix11
-rw-r--r--lib/systems/platforms.nix1
-rw-r--r--lib/trivial.nix3
-rw-r--r--lib/types.nix25
27 files changed, 233 insertions, 134 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix
index d2946f6ca9c..19218cfe8ec 100644
--- a/lib/attrsets.nix
+++ b/lib/attrsets.nix
@@ -1,11 +1,11 @@
+{ lib }:
 # Operations on attribute sets.
 
 let
   inherit (builtins) head tail length;
-  inherit (import ./trivial.nix) and or;
-  inherit (import ./default.nix) fold;
-  inherit (import ./strings.nix) concatStringsSep;
-  inherit (import ./lists.nix) concatMap concatLists all deepSeqList;
+  inherit (lib.trivial) and or;
+  inherit (lib.strings) concatStringsSep;
+  inherit (lib.lists) fold concatMap concatLists all deepSeqList;
 in
 
 rec {
diff --git a/lib/customisation.nix b/lib/customisation.nix
index 98a46ca6c61..483ef6fd486 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -1,6 +1,6 @@
+{ lib }:
 let
 
-  lib = import ./default.nix;
   inherit (builtins) attrNames isFunction;
 
 in
diff --git a/lib/debug.nix b/lib/debug.nix
index 925e0d405a7..646ef220ad0 100644
--- a/lib/debug.nix
+++ b/lib/debug.nix
@@ -1,4 +1,6 @@
-let lib = import ./default.nix;
+{ lib }:
+
+let
 
 inherit (builtins) trace attrNamesToStr isAttrs isFunction isList isInt
         isString isBool head substring attrNames;
diff --git a/lib/default.nix b/lib/default.nix
index 3893e349db3..3e30ec515fc 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -5,58 +5,127 @@
  */
 let
 
-  # often used, or depending on very little
-  trivial = import ./trivial.nix;
-  fixedPoints = import ./fixed-points.nix;
-
-  # datatypes
-  attrsets = import ./attrsets.nix;
-  lists = import ./lists.nix;
-  strings = import ./strings.nix;
-  stringsWithDeps = import ./strings-with-deps.nix;
-
-  # packaging
-  customisation = import ./customisation.nix;
-  maintainers = import ./maintainers.nix;
-  meta = import ./meta.nix;
-  sources = import ./sources.nix;
-
-  # module system
-  modules = import ./modules.nix;
-  options = import ./options.nix;
-  types = import ./types.nix;
-
-  # constants
-  licenses = import ./licenses.nix;
-  systems = import ./systems;
-
-  # misc
-  debug = import ./debug.nix;
-  generators = import ./generators.nix;
-  misc = import ./deprecated.nix;
-
-  # domain-specific
-  sandbox = import ./sandbox.nix;
-  fetchers = import ./fetchers.nix;
-
-  # Eval-time filesystem handling
-  filesystem = import ./filesystem.nix;
-
-in
-  { inherit trivial fixedPoints
-            attrsets lists strings stringsWithDeps
-            customisation maintainers meta sources
-            modules options types
-            licenses systems
-            debug generators misc
-            sandbox fetchers filesystem;
+  callLibs = file: import file { inherit lib; };
+
+  lib = rec {
+
+    # often used, or depending on very little
+    trivial = callLibs ./trivial.nix;
+    fixedPoints = callLibs ./fixed-points.nix;
+
+    # datatypes
+    attrsets = callLibs ./attrsets.nix;
+    lists = callLibs ./lists.nix;
+    strings = callLibs ./strings.nix;
+    stringsWithDeps = callLibs ./strings-with-deps.nix;
+
+    # packaging
+    customisation = callLibs ./customisation.nix;
+    maintainers = callLibs ./maintainers.nix;
+    meta = callLibs ./meta.nix;
+    sources = callLibs ./sources.nix;
+
+
+    # module system
+    modules = callLibs ./modules.nix;
+    options = callLibs ./options.nix;
+    types = callLibs ./types.nix;
+
+    # constants
+    licenses = callLibs ./licenses.nix;
+    systems = callLibs ./systems;
+
+    # misc
+    debug = callLibs ./debug.nix;
+
+    generators = callLibs ./generators.nix;
+    misc = callLibs ./deprecated.nix;
+    # domain-specific
+    sandbox = callLibs ./sandbox.nix;
+    fetchers = callLibs ./fetchers.nix;
+
+    # Eval-time filesystem handling
+    filesystem = callLibs ./filesystem.nix;
 
     # back-compat aliases
     platforms = systems.doubles;
-  }
-  # !!! don't include everything at top-level; perhaps only the most
-  # commonly used functions.
-  // trivial // fixedPoints
-  // lists // strings // stringsWithDeps // attrsets // sources
-  // options // types // meta // debug // misc // modules
-  // customisation
+
+    inherit (builtins) add addErrorContext attrNames
+      concatLists deepSeq elem elemAt filter genericClosure genList
+      getAttr hasAttr head isAttrs isBool isFunction isInt isList
+      isString length lessThan listToAttrs pathExists readFile
+      replaceStrings seq stringLength sub substring tail;
+    inherit (trivial) id const concat or and boolToString mergeAttrs
+      flip mapNullable inNixShell min max importJSON warn info
+      nixpkgsVersion mod;
+
+    inherit (fixedPoints) fix fix' extends composeExtensions
+      makeExtensible makeExtensibleWithCustomName;
+    inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
+      getAttrFromPath attrVals attrValues catAttrs filterAttrs
+      filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
+      mapAttrs' mapAttrsToList mapAttrsRecursive mapAttrsRecursiveCond
+      genAttrs isDerivation toDerivation optionalAttrs
+      zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
+      recursiveUpdate matchAttrs overrideExisting getOutput getBin
+      getLib getDev chooseDevOutputs zipWithNames zip;
+    inherit (lists) singleton foldr fold foldl foldl' imap0 imap1
+      concatMap flatten remove findSingle findFirst any all count
+      optional optionals toList range partition zipListsWith zipLists
+      reverseList listDfs toposort sort take drop sublist last init
+      crossLists unique intersectLists subtractLists
+      mutuallyExclusive;
+    inherit (strings) concatStrings concatMapStrings concatImapStrings
+      intersperse concatStringsSep concatMapStringsSep
+      concatImapStringsSep makeSearchPath makeSearchPathOutput
+      makeLibraryPath makeBinPath makePerlPath optionalString
+      hasPrefix hasSuffix stringToCharacters stringAsChars escape
+      escapeShellArg escapeShellArgs replaceChars lowerChars upperChars
+      toLower toUpper addContextFrom splitString removePrefix
+      removeSuffix versionOlder versionAtLeast getVersion nameFromURL
+      enableFeature fixedWidthString fixedWidthNumber isStorePath
+      toInt readPathsFromFile fileContents;
+    inherit (stringsWithDeps) textClosureList textClosureMap
+      noDepEntry fullDepEntry packEntry stringAfter;
+    inherit (customisation) overrideDerivation makeOverridable
+      callPackageWith callPackagesWith addPassthru hydraJob makeScope;
+    inherit (meta) addMetaAttrs dontDistribute setName updateName
+      appendToName mapDerivationAttrset lowPrio lowPrioSet hiPrio
+      hiPrioSet;
+    inherit (sources) pathType pathIsDirectory cleanSourceFilter
+      cleanSource sourceByRegex sourceFilesBySuffices
+      commitIdFromGitRepo;
+    inherit (modules) evalModules closeModules unifyModuleSyntax
+      applyIfFunction unpackSubmodule packSubmodule mergeModules
+      mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
+      pushDownProperties dischargeProperties filterOverrides
+      sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
+      mkOptionDefault mkDefault mkForce mkVMOverride mkStrict
+      mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
+      mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
+      mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
+      mkAliasOptionModule doRename filterModules;
+    inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions
+      mergeDefaultOption mergeOneOption mergeEqualOption getValues
+      getFiles optionAttrSetToDocList optionAttrSetToDocList'
+      scrubOptionValue literalExample showOption showFiles
+      unknownModule mkOption;
+    inherit (types) isType setType defaultTypeMerge defaultFunctor
+      isOptionType mkOptionType;
+    inherit (debug) addErrorContextToAttrs traceIf traceVal
+      traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
+      traceValSeqN traceShowVal traceShowValMarked
+      showVal traceCall traceCall2 traceCall3 traceValIfNot runTests
+      testAllTrue strict traceCallXml attrNamesToStr;
+    inherit (misc) maybeEnv defaultMergeArg defaultMerge foldArgs
+      defaultOverridableDelayableArgs composedArgsAndFun
+      maybeAttrNullable maybeAttr ifEnable checkFlag getValue
+      checkReqs uniqList uniqListExt condConcat lazyGenericClosure
+      innerModifySumArgs modifySumArgs innerClosePropagation
+      closePropagation mapAttrsFlatten nvs setAttr setAttrMerge
+      mergeAttrsWithFunc mergeAttrsConcatenateValues
+      mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
+      mergeAttrsByFuncDefaultsClean mergeAttrBy
+      prepareDerivationArgs nixType imap overridableDelayableArgs;
+  };
+in lib
diff --git a/lib/deprecated.nix b/lib/deprecated.nix
index 8cdfab381ba..2a0f5a55bf1 100644
--- a/lib/deprecated.nix
+++ b/lib/deprecated.nix
@@ -1,11 +1,12 @@
-let lib = import ./default.nix;
+{ lib }:
+let
     inherit (builtins) isFunction head tail isList isAttrs isInt attrNames;
 
 in
 
-with import ./lists.nix;
-with import ./attrsets.nix;
-with import ./strings.nix;
+with lib.lists;
+with lib.attrsets;
+with lib.strings;
 
 rec {
 
diff --git a/lib/fetchers.nix b/lib/fetchers.nix
index 21f28c32ef7..1107353b51d 100644
--- a/lib/fetchers.nix
+++ b/lib/fetchers.nix
@@ -1,4 +1,5 @@
 # snippets that can be shared by multiple fetchers (pkgs/build-support)
+{ lib }:
 {
 
   proxyImpureEnvVars = [
diff --git a/lib/filesystem.nix b/lib/filesystem.nix
index 3925beb2134..fc35a1a72c6 100644
--- a/lib/filesystem.nix
+++ b/lib/filesystem.nix
@@ -1,3 +1,4 @@
+{ lib }:
 { # haskellPathsInDir : Path -> Map String Path
   # A map of all haskell packages defined in the given path,
   # identified by having a cabal file with the same name as the
diff --git a/lib/fixed-points.nix b/lib/fixed-points.nix
index a11b5a6f4bd..13e053b5aa7 100644
--- a/lib/fixed-points.nix
+++ b/lib/fixed-points.nix
@@ -1,3 +1,4 @@
+{ ... }:
 rec {
   # Compute the fixed point of the given function `f`, which is usually an
   # attribute set that expects its final, non-recursive representation as an
diff --git a/lib/generators.nix b/lib/generators.nix
index 4419c3c8891..5f9da234f44 100644
--- a/lib/generators.nix
+++ b/lib/generators.nix
@@ -7,10 +7,11 @@
  * Tests can be found in ./tests.nix
  * Documentation in the manual, #sec-generators
  */
-with import ./trivial.nix;
+{ lib }:
+with (lib).trivial;
 let
-  libStr = import ./strings.nix;
-  libAttr = import ./attrsets.nix;
+  libStr = lib.strings;
+  libAttr = lib.attrsets;
 
   flipMapAttrs = flip libAttr.mapAttrs;
 in
diff --git a/lib/licenses.nix b/lib/licenses.nix
index 964c0966e43..1bb153ce4c3 100644
--- a/lib/licenses.nix
+++ b/lib/licenses.nix
@@ -1,7 +1,6 @@
+{ lib }:
 let
 
-  lib = import ./default.nix;
-
   spdx = lic: lic // {
     url = "http://spdx.org/licenses/${lic.spdxId}";
   };
@@ -282,6 +281,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
     url = https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception;
   };
 
+  hpnd = spdx {
+    spdxId = "HPND";
+    fullName = "Historic Permission Notice and Disclaimer";
+  };
+
   # Intel's license, seems free
   iasl = {
     fullName = "iASL";
@@ -293,9 +297,10 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
     fullName = "Independent JPEG Group License";
   };
 
-  inria = {
-    fullName  = "INRIA Non-Commercial License Agreement";
+  inria-compcert = {
+    fullName  = "INRIA Non-Commercial License Agreement for the CompCert verified compiler";
     url       = "http://compcert.inria.fr/doc/LICENSE";
+    free      = false;
   };
 
   ipa = spdx {
@@ -419,7 +424,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
     url = "https://raw.githubusercontent.com/raboof/notion/master/LICENSE";
     fullName = "Notion modified LGPL";
   };
-  
+
   ofl = spdx {
     spdxId = "OFL-1.1";
     fullName = "SIL Open Font License 1.1";
diff --git a/lib/lists.nix b/lib/lists.nix
index 6a8fd8a1840..8f67c6bb0ca 100644
--- a/lib/lists.nix
+++ b/lib/lists.nix
@@ -1,6 +1,6 @@
 # General list operations.
-
-with import ./trivial.nix;
+{ lib }:
+with lib.trivial;
 
 rec {
 
diff --git a/lib/maintainers.nix b/lib/maintainers.nix
index 2d4eaddc533..8d4b49be461 100644
--- a/lib/maintainers.nix
+++ b/lib/maintainers.nix
@@ -1,3 +1,4 @@
+{ ...}:
 /* List of NixOS maintainers. The format is:
 
     handle = "Real Name <address@example.org>";
@@ -106,6 +107,7 @@
   choochootrain = "Hurshal Patel <hurshal@imap.cc>";
   chris-martin = "Chris Martin <ch.martin@gmail.com>";
   chrisjefferson = "Christopher Jefferson <chris@bubblescope.net>";
+  chrisrosset = "Christopher Rosset <chris@rosset.org.uk>";
   christopherpoole = "Christopher Mark Poole <mail@christopherpoole.net>";
   ciil = "Simon Lackerbauer <simon@lackerbauer.com>";
   ckampka = "Christian Kampka <christian@kampka.net>";
@@ -185,17 +187,20 @@
   ellis = "Ellis Whitehead <nixos@ellisw.net>";
   eperuffo = "Emanuele Peruffo <info@emanueleperuffo.com>";
   epitrochoid = "Mabry Cervin <mpcervin@uncg.edu>";
+  eqyiel = "Ruben Maher <r@rkm.id.au>";
   ericbmerritt = "Eric Merritt <eric@afiniate.com>";
   ericsagnes = "Eric Sagnes <eric.sagnes@gmail.com>";
   erikryb = "Erik Rybakken <erik.rybakken@math.ntnu.no>";
   ertes = "Ertugrul Söylemez <esz@posteo.de>";
   ethercrow = "Dmitry Ivanov <ethercrow@gmail.com>";
+  etu = "Elis Hirwing <elis@hirwing.se>";
   exi = "Reno Reckling <nixos@reckling.org>";
   exlevan = "Alexey Levan <exlevan@gmail.com>";
   expipiplus1 = "Joe Hermaszewski <nix@monoid.al>";
   fadenb = "Tristan Helmich <tristan.helmich+nixos@gmail.com>";
-  fare = "Francois-Rene Rideau <fahree@gmail.com>";
   falsifian = "James Cook <james.cook@utoronto.ca>";
+  fare = "Francois-Rene Rideau <fahree@gmail.com>";
+  fgaz = "Francesco Gazzetta <francygazz@gmail.com>";
   florianjacob = "Florian Jacob <projects+nixos@florianjacob.de>";
   flosse = "Markus Kohlhase <mail@markus-kohlhase.de>";
   fluffynukeit = "Daniel Austin <dan@fluffynukeit.com>";
@@ -237,6 +242,7 @@
   guillaumekoenig = "Guillaume Koenig <guillaume.edward.koenig@gmail.com>";
   guyonvarch = "Joris Guyonvarch <joris@guyonvarch.me>";
   hakuch = "Jesse Haber-Kucharsky <hakuch@gmail.com>";
+  hamhut1066 = "Hamish Hutchings <github@hamhut1066.com>";
   havvy = "Ryan Scheel <ryan.havvy@gmail.com>";
   hbunke = "Hendrik Bunke <bunke.hendrik@gmail.com>";
   hce = "Hans-Christian Esperer <hc@hcesperer.org>";
@@ -286,12 +292,12 @@
   jonafato = "Jon Banafato <jon@jonafato.com>";
   jpierre03 = "Jean-Pierre PRUNARET <nix@prunetwork.fr>";
   jpotier = "Martin Potier <jpo.contributes.to.nixos@marvid.fr>";
-  jyp = "Jean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com>";
   jraygauthier = "Raymond Gauthier <jraygauthier@gmail.com>";
   jtojnar = "Jan Tojnar <jtojnar@gmail.com>";
   juliendehos = "Julien Dehos <dehos@lisic.univ-littoral.fr>";
   jwiegley = "John Wiegley <johnw@newartisans.com>";
   jwilberding = "Jordan Wilberding <jwilberding@afiniate.com>";
+  jyp = "Jean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com>";
   jzellner = "Jeff Zellner <jeffz@eml.cc>";
   kaiha = "Kai Harries <kai.harries@gmail.com>";
   kamilchm = "Kamil Chmielewski <kamil.chm@gmail.com>";
@@ -331,6 +337,7 @@
   lovek323 = "Jason O'Conal <jason@oconal.id.au>";
   lowfatcomputing = "Andreas Wagner <andreas.wagner@lowfatcomputing.org>";
   lsix = "Lancelot SIX <lsix@lancelotsix.com>";
+  ltavard = "Laure Tavard <laure.tavard@univ-grenoble-alpes.fr>";
   lucas8 = "Luc Chabassier <luc.linux@mailoo.org>";
   ludo = "Ludovic Courtès <ludo@gnu.org>";
   lufia = "Kyohei Kadota <lufia@lufia.org>";
@@ -366,6 +373,7 @@
   meditans = "Carlo Nucera <meditans@gmail.com>";
   meisternu = "Matt Miemiec <meister@krutt.org>";
   metabar = "Celine Mercier <softs@metabarcoding.org>";
+  mgdelacroix = "Miguel de la Cruz <mgdelacroix@gmail.com>";
   mguentner = "Maximilian Güntner <code@klandest.in>";
   mic92 = "Jörg Thalheim <joerg@thalheim.io>";
   michaelpj = "Michael Peyton Jones <michaelpj@gmail.com>";
@@ -493,6 +501,7 @@
   renzo = "Renzo Carbonara <renzocarbonara@gmail.com>";
   retrry = "Tadas Barzdžius <retrry@gmail.com>";
   rht = "rht <rhtbot@protonmail.com>";
+  richardipsum = "Richard Ipsum <richardipsum@fastmail.co.uk>";
   rick68 = "Wei-Ming Yang <rick68@gmail.com>";
   rickynils = "Rickard Nilsson <rickynils@gmail.com>";
   ris = "Robert Scott <code@humanleg.org.uk>";
@@ -502,6 +511,7 @@
   robberer = "Longrin Wischnewski <robberer@freakmail.de>";
   robbinch = "Robbin C. <robbinch33@gmail.com>";
   roberth = "Robert Hensing <nixpkgs@roberthensing.nl>";
+  robertodr = "Roberto Di Remigio <roberto.diremigio@gmail.com>";
   robgssp = "Rob Glossop <robgssp@gmail.com>";
   roblabla = "Robin Lambertz <robinlambertz+dev@gmail.com>";
   roconnor = "Russell O'Connor <roconnor@theorem.ca>";
@@ -567,6 +577,7 @@
   swarren83 = "Shawn Warren <shawn.w.warren@gmail.com>";
   swflint = "Samuel W. Flint <swflint@flintfam.org>";
   swistak35 = "Rafał Łasocha <me@swistak35.com>";
+  symphorien = "Guillaume Girol <symphorien_nixpkgs@xlumurb.eu>";
   szczyp = "Szczyp <qb@szczyp.com>";
   sztupi = "Attila Sztupak <attila.sztupak@gmail.com>";
   taeer = "Taeer Bar-Yam <taeer@necsi.edu>";
@@ -576,10 +587,9 @@
   taku0 = "Takuo Yonezawa <mxxouy6x3m_github@tatapa.org>";
   tari = "Peter Marheine <peter@taricorp.net>";
   tavyc = "Octavian Cerna <octavian.cerna@gmail.com>";
-  ltavard = "Laure Tavard <laure.tavard@univ-grenoble-alpes.fr>";
   teh = "Tom Hunger <tehunger@gmail.com>";
-  teto = "Matthieu Coudron <mcoudron@hotmail.com>";
   telotortium = "Robert Irelan <rirelan@gmail.com>";
+  teto = "Matthieu Coudron <mcoudron@hotmail.com>";
   thall = "Niclas Thall <niclas.thall@gmail.com>";
   thammers = "Tobias Hammerschmidt <jawr@gmx.de>";
   the-kenny = "Moritz Ulrich <moritz@tarn-vedra.de>";
@@ -608,6 +618,7 @@
   #urkud = "Yury G. Kudryashov <urkud+nix@ya.ru>"; inactive since 2012
   uwap = "uwap <me@uwap.name>";
   vaibhavsagar = "Vaibhav Sagar <vaibhavsagar@gmail.com>";
+  valeriangalliat = "Valérian Galliat <val@codejam.info>";
   vandenoever = "Jos van den Oever <jos@vandenoever.info>";
   vanschelven = "Klaas van Schelven <klaas@vanschelven.com>";
   vanzef = "Ivan Solyankin <vanzef@gmail.com>";
@@ -624,7 +635,6 @@
   vlstill = "Vladimír Štill <xstill@fi.muni.cz>";
   vmandela = "Venkateswara Rao Mandela <venkat.mandela@gmail.com>";
   vmchale = "Vanessa McHale <tmchale@wisc.edu>";
-  valeriangalliat = "Valérian Galliat <val@codejam.info>";
   volhovm = "Mikhail Volkhov <volhovm.cs@gmail.com>";
   volth = "Jaroslavas Pocepko <jaroslavas@volth.com>";
   vozz = "Oliver Hunt <oliver.huntuk@gmail.com>";
@@ -646,6 +656,7 @@
   xvapx = "Marti Serra <marti.serra.coscollano@gmail.com>";
   xwvvvvwx = "David Terry <davidterry@posteo.de>";
   yarr = "Dmitry V. <savraz@gmail.com>";
+  yegortimoshenko = "Yegor Timoshenko <yegortimoshenko@gmail.com>";
   yochai = "Yochai <yochai@titat.info>";
   yorickvp = "Yorick van Pelt <yorickvanpelt@gmail.com>";
   yuriaisaka = "Yuri Aisaka <yuri.aisaka+nix@gmail.com>";
@@ -662,4 +673,5 @@
   zoomulator = "Kim Simmons <zoomulator@gmail.com>";
   zraexy = "David Mell <zraexy@gmail.com>";
   zx2c4 = "Jason A. Donenfeld <Jason@zx2c4.com>";
+  zzamboni = "Diego Zamboni <diego@zzamboni.org>";
 }
diff --git a/lib/meta.nix b/lib/meta.nix
index 8f77bbe0148..07b1710fff7 100644
--- a/lib/meta.nix
+++ b/lib/meta.nix
@@ -1,8 +1,7 @@
 /* Some functions for manipulating meta attributes, as well as the
    name attribute. */
 
-let lib = import ./default.nix;
-in
+{ lib }:
 
 rec {
 
diff --git a/lib/modules.nix b/lib/modules.nix
index 3da689a6bdb..eb2f89684f3 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -1,10 +1,12 @@
-with import ./lists.nix;
-with import ./strings.nix;
-with import ./trivial.nix;
-with import ./attrsets.nix;
-with import ./options.nix;
-with import ./debug.nix;
-with import ./types.nix;
+{ lib }:
+
+with lib.lists;
+with lib.strings;
+with lib.trivial;
+with lib.attrsets;
+with lib.options;
+with lib.debug;
+with lib.types;
 
 rec {
 
diff --git a/lib/options.nix b/lib/options.nix
index 2092b65bbc3..769d3cc5572 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -1,11 +1,10 @@
 # Nixpkgs/NixOS option handling.
+{ lib }:
 
-let lib = import ./default.nix; in
-
-with import ./trivial.nix;
-with import ./lists.nix;
-with import ./attrsets.nix;
-with import ./strings.nix;
+with lib.trivial;
+with lib.lists;
+with lib.attrsets;
+with lib.strings;
 
 rec {
 
diff --git a/lib/sandbox.nix b/lib/sandbox.nix
index 414bf36f779..2cdeb40938a 100644
--- a/lib/sandbox.nix
+++ b/lib/sandbox.nix
@@ -1,4 +1,5 @@
-with import ./strings.nix;
+{ lib }:
+with lib.strings;
 
 /* Helpers for creating lisp S-exprs for the Apple sandbox
 
diff --git a/lib/sources.nix b/lib/sources.nix
index 63b3749d19e..0fd56d58ddd 100644
--- a/lib/sources.nix
+++ b/lib/sources.nix
@@ -1,6 +1,5 @@
 # Functions for copying sources to the Nix store.
-
-let lib = import ./default.nix; in
+{ lib }:
 
 rec {
 
diff --git a/lib/strings-with-deps.nix b/lib/strings-with-deps.nix
index a901940ac12..e3336983428 100644
--- a/lib/strings-with-deps.nix
+++ b/lib/strings-with-deps.nix
@@ -1,3 +1,4 @@
+{ lib }:
 /*
 Usage:
 
@@ -40,9 +41,9 @@ Usage:
   [1] maybe this behaviour should be removed to keep things simple (?)
 */
 
-with import ./lists.nix;
-with import ./attrsets.nix;
-with import ./strings.nix;
+with lib.lists;
+with lib.attrsets;
+with lib.strings;
 
 rec {
 
diff --git a/lib/strings.nix b/lib/strings.nix
index a03694d1b1d..aca9ef45e61 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -1,6 +1,6 @@
 /* String manipulation functions. */
-
-let lib = import ./default.nix;
+{ lib }:
+let
 
 inherit (builtins) length;
 
diff --git a/lib/systems/default.nix b/lib/systems/default.nix
index b5138a5ba71..b1036b80c4d 100644
--- a/lib/systems/default.nix
+++ b/lib/systems/default.nix
@@ -1,11 +1,12 @@
-let inherit (import ../attrsets.nix) mapAttrs; in
+{ lib }:
+  let inherit (lib.attrsets) mapAttrs; in
 
 rec {
-  doubles = import ./doubles.nix;
-  parse = import ./parse.nix;
-  inspect = import ./inspect.nix;
-  platforms = import ./platforms.nix;
-  examples = import ./examples.nix;
+  doubles = import ./doubles.nix { inherit lib; };
+  parse = import ./parse.nix { inherit lib; };
+  inspect = import ./inspect.nix { inherit lib; };
+  platforms = import ./platforms.nix { inherit lib; };
+  examples = import ./examples.nix { inherit lib; };
 
   # Elaborate a `localSystem` or `crossSystem` so that it contains everything
   # necessary.
diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix
index ac1a199d80c..0cae8ec56fd 100644
--- a/lib/systems/doubles.nix
+++ b/lib/systems/doubles.nix
@@ -1,8 +1,9 @@
+{ lib }:
 let
-  lists = import ../lists.nix;
-  parse = import ./parse.nix;
-  inherit (import ./inspect.nix) predicates;
-  inherit (import ../attrsets.nix) matchAttrs;
+  inherit (lib) lists;
+  parse = import ./parse.nix { inherit lib; };
+  inherit (import ./inspect.nix { inherit lib; }) predicates;
+  inherit (lib.attrsets) matchAttrs;
 
   all = [
     "aarch64-linux"
diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix
index e394f43831c..ff2273febcb 100644
--- a/lib/systems/examples.nix
+++ b/lib/systems/examples.nix
@@ -1,8 +1,8 @@
 # These can be passed to nixpkgs as either the `localSystem` or
 # `crossSystem`. They are put here for user convenience, but also used by cross
 # tests and linux cross stdenv building, so handle with care!
-
-let platforms = import ./platforms.nix; in
+{ lib }:
+let platforms = import ./platforms.nix { inherit lib; }; in
 
 rec {
   #
diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix
index 2d5353341f5..a4fa9af4e0a 100644
--- a/lib/systems/inspect.nix
+++ b/lib/systems/inspect.nix
@@ -1,6 +1,7 @@
-with import ./parse.nix;
-with import ../attrsets.nix;
-with import ../lists.nix;
+{ lib }:
+with import ./parse.nix { inherit lib; };
+with lib.attrsets;
+with lib.lists;
 
 rec {
   patterns = rec {
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index 438d83685db..d14ca04bfb9 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -4,14 +4,13 @@
 # http://llvm.org/docs/doxygen/html/Triple_8cpp_source.html especially
 # Triple::normalize. Parsing should essentially act as a more conservative
 # version of that last function.
-
-with import ../lists.nix;
-with import ../types.nix;
-with import ../attrsets.nix;
-with (import ./inspect.nix).predicates;
+{ lib }:
+with lib.lists;
+with lib.types;
+with lib.attrsets;
+with (import ./inspect.nix { inherit lib; }).predicates;
 
 let
-  lib = import ../default.nix;
   setTypesAssert = type: pred:
     mapAttrs (name: value:
       assert pred value;
diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix
index 54ed8f3c12c..7aeb4d88e51 100644
--- a/lib/systems/platforms.nix
+++ b/lib/systems/platforms.nix
@@ -1,3 +1,4 @@
+{ lib }:
 rec {
   pcBase = {
     name = "pc";
diff --git a/lib/trivial.nix b/lib/trivial.nix
index a57cf30d171..c452c7b65bc 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -1,3 +1,4 @@
+{ lib }:
 rec {
 
   /* The identity function
@@ -55,7 +56,7 @@ rec {
     isInt add sub lessThan
     seq deepSeq genericClosure;
 
-  inherit (import ./strings.nix) fileContents;
+  inherit (lib.strings) fileContents;
 
   # Return the Nixpkgs version number.
   nixpkgsVersion =
diff --git a/lib/types.nix b/lib/types.nix
index a7dcd3f1e1c..62c6a978af9 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -1,15 +1,16 @@
 # Definitions related to run-time type checking.  Used in particular
 # to type-check NixOS configurations.
-
-with import ./lists.nix;
-with import ./attrsets.nix;
-with import ./options.nix;
-with import ./trivial.nix;
-with import ./strings.nix;
-let inherit (import ./modules.nix) mergeDefinitions filterOverrides; in
-
+{ lib }:
+with lib.lists;
+with lib.attrsets;
+with lib.options;
+with lib.trivial;
+with lib.strings;
+let
+
+  inherit (lib.modules) mergeDefinitions filterOverrides;
+  outer_types =
 rec {
-
   isType = type: x: (x._type or "") == type;
 
   setType = typeName: value: value // {
@@ -95,7 +96,6 @@ rec {
   # When adding new types don't forget to document them in
   # nixos/doc/manual/development/option-types.xml!
   types = rec {
-
     unspecified = mkOptionType {
       name = "unspecified";
     };
@@ -291,7 +291,7 @@ rec {
     submodule = opts:
       let
         opts' = toList opts;
-        inherit (import ./modules.nix) evalModules;
+        inherit (lib.modules) evalModules;
       in
       mkOptionType rec {
         name = "submodule";
@@ -395,5 +395,6 @@ rec {
     addCheck = elemType: check: elemType // { check = x: elemType.check x && check x; };
 
   };
+};
 
-}
+in outer_types // outer_types.types