nix-helpers: 3a219999d4852d0583b68a0dec10a4f6f02935d7

     1: { nixpkgs-lib ? import ./nixpkgs-lib { }
     2: , nixpkgs ? (import ./pinnedNixpkgs { inherit nixpkgs-lib; }).nixpkgsLatest }:
     3: 
     4: with rec {
     5:   inherit (builtins) attrNames getAttr isAttrs;
     6:   inherit (nixpkgs-lib) fold mapAttrs;
     7: 
     8:   callPackage = nixpkgs.newScope nix-helpers;
     9: 
    10:   # Bootstrap this function so we can use it to load all of our subdirs
    11:   nixDirsIn = import ./nixDirsIn { };
    12: 
    13:   # Accumulate the results of 'addFile' for all files matching 'filename'
    14:   allFiles = filename:
    15:     with rec {
    16:       # Import './name/filename' , appending the results to 'previous'
    17:       addFile = name: previous:
    18:         previous // {
    19:           # Using 'callPackage' ensures derivations get appropriate 'override' attrs
    20:           "${name}" = callPackage (getAttr name found) { };
    21:         };
    22: 
    23:       # Look for files with name 'filename' (e.g. "default.nix") in our
    24:       # subdirectories. Returns a map from subdir name to path, e.g.
    25:       # { foo = ./foo/default.nix;, ... }
    26:       found = nixDirsIn {
    27:         inherit filename;
    28:         dir = ./.;
    29:       };
    30:     };
    31:     fold addFile { } (attrNames found);
    32: 
    33:   # Load definitions from 'default.nix' and tests from 'tests.nix'.
    34:   defs = allFiles "default.nix";
    35:   tests = allFiles "tests.nix";
    36: 
    37:   # Combine everything and tie the knot
    38:   pinnedNixpkgs = import ./pinnedNixpkgs { inherit nixpkgs-lib; };
    39: 
    40:   nix-helpers = pinnedNixpkgs // defs // {
    41:     inherit nix-helpers nixpkgs nixpkgs-lib;
    42:     nix-helpers-tests = {
    43:       recurseForDerivations = true;
    44:     } // mapAttrs
    45:       (_: x: if isAttrs x then { recurseForDerivations = true; } // x else x)
    46:       tests;
    47:   };
    48: };
    49: nix-helpers

Generated by git2html.