Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. let
  2. inherit (import <nixpkgs> {}) lib stdenv;
  3.  
  4. # helper to make a really simply derivation
  5. deriv = { name, deps, buildDeps, ... }: stdenv.mkDerivation {
  6. inherit name;
  7. deps = deps (lib.mapAttrs (_: pkg: pkg.drvBuilder pkg) buildDeps);
  8. buildCommand = "cat $deps > $out";
  9. };
  10.  
  11. asDerivation = lib.mapAttrs (_: pkg: pkg.drvBuilder pkg);
  12.  
  13. close = super: set: let s = lib.mapAttrs (_: pkg: pkg s super) set; in s;
  14.  
  15. pkgs = {
  16. foo = self: super: {
  17. name = "foo";
  18. buildDeps = {};
  19. deps = ctx: [];
  20. drvBuilder = deriv;
  21. };
  22.  
  23. bar = self: super: {
  24. name = "bar";
  25. buildDeps = { inherit (self) foo; };
  26. deps = ctx: [ ctx.foo ];
  27. drvBuilder = deriv;
  28. };
  29.  
  30. qux = self: super: {
  31. name = "qux";
  32. buildDeps = { inherit (self) foo bar; };
  33. deps = ctx: [ ctx.foo ctx.bar ]; drvBuilder = deriv;
  34. };
  35. };
  36. in asDerivation (close {} pkgs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement