@@ -23,14 +23,47 @@ in pkgs.lib.evalModules {
2323
2424 # Set the plan for modules/plan.nix
2525 plan.pkg-def = hackage: with builtins;
26+ # The desugar reason.
27+ #
28+ # it is quite combersome to write
29+ # (hackage: { packages.x.revision = hackage...;
30+ # packages.y.revision = import ./foo.nix; })
31+ # where we'd rather write:
32+ # (hackage: { x = hackage...; })
33+ # or
34+ # { y = ./foo.nix; }
35+ # As such the desugarer desugars this short hand syntax.
36+ let desugar = overlay:
37+ let
38+ isPath = x: builtins.typeOf x == "path";
39+ # rewrite
40+ # { ... }
41+ # into
42+ # { package = { ... }; }
43+ inject-packages = o: if o ? "packages" then o else { packages = o; };
44+ # rewrite
45+ # x = pkg;
46+ # into
47+ # x.revision = pkg;
48+ inject-revision = pkg: if pkg ? "revision" then pkg else { revision = pkg; };
49+ # rewrite
50+ # x.revision = ./some/path;
51+ # into
52+ # x.revision = import ./some/path;
53+ expand-paths = pkg: if !(isPath pkg.revision) then pkg else { revision = import pkg.revision; };
54+ # apply injection and expansion to the "packages" in overlay.
55+ in lib.mapAttrs (k: v: if k != "packages"
56+ then v
57+ else lib.mapAttrs (_: pkg: (expand-paths (inject-revision pkg))) v)
58+ (inject-packages overlay);
2659 # fold any potential `pkg-def-overlays`
2760 # onto the `pkg-def`.
2861 #
2962 # This means you can have a base definition (e.g. stackage)
3063 # and augment it with custom packages to your liking.
31− foldl' lib.recursiveUpdate
64+ in foldl' lib.recursiveUpdate
3265 (pkg-def hackage)
33− (map (p: p hackage) pkg-def-overlays)
66+ (map (p: desugar (if builtins.isFunction p then p hackage else p)) pkg-def-overlays)
3467 ;
3568
3669 })