Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: Output is not composable #175

Closed
clacke opened this issue Aug 19, 2018 · 1 comment · Fixed by #196
Closed

Problem: Output is not composable #175

clacke opened this issue Aug 19, 2018 · 1 comment · Fixed by #196

Comments

@clacke
Copy link
Member

clacke commented Aug 19, 2018

Every time we run racket2nix we get a self-contained nix expression, and the user can't do much with it, or rather to it.

#17 would make it output an attribute set instead, which is better, but still not good enough -- you can't override one package and have other packages depend on your override.

Solution: Support outputting an overlay.

I'm not even talking about just outputting a recursive function, and wrapping it in lib.makeExtensible. That's great, and we want that for the base catalog. No, I'm talking about the next layer of abstraction.

We can output a thin Nix expression and do zero lookup in package catalogs. No definition of mkRacketDerivation, no knowledge of where "rackunit-lib" or "pict-lib" is going to come from, just output a self: super: { "my-package" = self.mkRacketDerivation { pname = "my-package"; src = blah; racketBuildInputs = [ self."base" self."rackunit-lib" self."pict-lib" ]; }; } and that's the whole expression. You can do this from the info.rkt alone and rely on Someone Else to provide the greater package universe.

With #176 you could even have a {buildRacketOverlay}: buildRacketOverlay [ ./my-package ] be the whole Nix expression and not even bother with an info.rkt.

Benefits:

  • No catalog generation in fractals
  • Overridability everywhere
  • Quicker buildRacket
  • Allows us to not even generate a catalog.rktd, just need a nix expression full of self.mkRacketDerivation.

This supersedes #17 and #123.
This requires solving #24 and probably #158 (which in turn hopefully solves #78).

It'll be glorious. Biting into this in September. It may not even be much work, mostly the prerequisite issues have some unknowns.

@clacke
Copy link
Member Author

clacke commented Aug 19, 2018

When generating the catalog, we will have to take care of circular dependencies. For people creating their own derivations, just tell them not do do circular.

clacke added a commit to clacke/racket2nix-clacke that referenced this issue Sep 3, 2018
Solution: Use makeExtensible.

Closes fractalide#175

 - Wrap all the dependencies in an attribute set.
 - Export that attribute set as an attribute of the package.
 - Wrap the attribute set in a function called with makeExtensible.
 - Move our functions into a sub-attribute 'lib', minimize collision.
 - Take the chance to rename attributes to names without a '_' prefix.

Example:

    $ nix-build -A racket-packages.racket2nix
    error: attribute 'racket2nix' in selection path 'racket-packages.racket2nix' not found
    $ nix-build -A racket-packages.nix
    /nix/store/l5dnla8gjg04v7v4q8pzkqaxqgp0l8cd-racket-minimal-7.0-nix
    $ nix-build -E 'with import ./. {}; (racket-packages.extend (self: super: { racket2nix = self.nix.overrideRacketDerivation (oldAttrs: { pname = "racket2nix-stage1"; }); })).racket2nix'
    /nix/store/zqlpq7iqcbia8wqiv03v9nlfdl637wvf-racket-minimal-7.0-racket2nix-stage1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant