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

POC of overlays approach to customization #137

Closed
wants to merge 2 commits into from

Conversation

michaelpj
Copy link
Contributor

This is a draft implementation of the idea I put forward in #134.

Using this I was able to successfully:

  • Get nixpkgs from an alternate source
    • I removed nixpkgs sources.json and unset NIX_PATH
    • I added an overlay which set nixpkgs = ...
    • Other sources using e.g. type: "tarball" continued to work.
  • Add a new fetcher type
    • I added an overlay setting __fetchers = super.__fetchers // { fetchgit = (import self.nixpkgs {}).fetchgit; };
    • Other sources with type: "fetchgit" worked as expected.

Ideally I'd add tests for these usecases but I'm too lazy to do it for the POC.

Downsides:

  • The way of importing sources.nix changes.
  • The nixpkgs entry in sources is less special, so needs to be imported with builtin-tarball so that the "bootstrapping" works. Arguably this is an upside!
  • You actually need to add arguments to get the fetchgit example to work: this is solved in newer nixpkgs, and we can probably get rid of the arguments for the fetchzip and fetchurl calls too.
    • (Previously, makeOverridable didn't preserve function arguments, now it does. In 19.09 but not 19.03.)

I think the downsides are all fine with a tiny bit of documentation, since this is advanced usage anyway.

@michaelpj
Copy link
Contributor Author

I pushed my two examples in niv itself (obviously do not merge with those there!).

Some thoughts:

  • Maybe sources should go in the overlay as __sources or something.
    • This would allow changing the location of sources.json by simply setting it to something different.
    • It doesn't help with people who want to move sources.nix.
  • People can add fetchers this way but it's unclear how it will interact with updating.

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 this pull request may close these issues.

1 participant