diff options
author | tv <tv@krebsco.de> | 2018-06-12 20:08:24 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2018-06-12 20:08:24 +0200 |
commit | 394590c4b35edbfbb5a503923fed0c8cbb382410 (patch) | |
tree | cff9ff9e975c64a5f390fdd7f1abfffdf1861434 /lib/default.nix |
import writers from stockholm 0bc2409
Diffstat (limited to 'lib/default.nix')
-rw-r--r-- | lib/default.nix | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..01d43f7 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,24 @@ +let { + body = lib; + + lib = nixpkgs.lib // builtins // (with lib; { + genAttrs' = names: f: listToAttrs (map f names); + getAttrs = names: set: + listToAttrs (map (name: nameValuePair name set.${name}) + (filter (flip hasAttr set) names)); + toC = x: let + type = typeOf x; + reject = throw "cannot convert ${type}"; + in { + list = "{ ${concatStringsSep ", " (map toC x)} }"; + null = "NULL"; + set = if isDerivation x then toJSON x else reject; + string = toJSON x; # close enough + }.${type} or reject; + test = re: x: isString x && testString re x; + testString = re: x: match re x != null; + types = nixpkgs.lib.types // import ./types.nix { lib = body; }; + }); + + nixpkgs.lib = import <nixpkgs/lib>; +} |