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

[WIP] Add a compatibility shim for non-flake nix #3366

Closed
wants to merge 1 commit into from

Conversation

samueldr
Copy link
Member

This compatibility shim uses an extremely naïve parsing of flake.lock
to get the dependencies.

It then uses a naïve implementation of flakes to produce the build.


Intent

I am sharing the current state of the shim, half-expecting that there are things to fix.

With a flakes-free nix, this handles:

  • using nix build or nix-build to build.
  • using nix-shell.

It is my opinion that this, or another implementation of such a shim, should be present in the flakes branch, and then in the master branch, up until a full release cycle of nix has had flakes enabled by default.

Not doing so makes for a confusing experience for getting started in looking at the flakes branch, at first. Then, allowing this for one full release might not be as useful at that point, but will allow laggards to at least be able to use this repository with nix v"flakes-1".

I would recommend, once flakes get into master, assuming there is such a shim, that the warning documents that this is going to be dropped in nix v"next release", also linking to a proper location for upgrades instructions.

Implementation details

This implementation is probably wrong in some ways. It does work for nix, but I wouldn't assume it works for all flakes. Surely, it would be helpful to include such a shim in all "core" flakes around the NixOS organization, if it can be fixed to be good enough for all of our flakes.

I am open to critique, rework, everything to make this better for inclusion in nix. Tell me what I did wrong, I'll be glad to get it sorted out.

This compatibility shim uses an extremely naïve parsing of `flake.lock`
to get the dependencies.

It then uses a naïve implementation of flakes to produce the build.
@edolstra
Copy link
Member

Maybe this can be moved into a separate repo so it can be used by other projects? I.e. shell.nix would look something like

(import (fetchTarball https://github.com/NixOS/flake-compat-shim.git) {
  flake = ./flake.nix;
  lockFile = ./flake.lock;
}).devShell.${builtins.currentSystem}

@zimbatm
Copy link
Member

zimbatm commented Feb 21, 2020

Related to this topic, I also have this nix/sources.nix which can be used if you want to switch from niv to flakes.

edolstra added a commit that referenced this pull request Feb 25, 2020
@edolstra
Copy link
Member

I've added a default.nix and shell.nix that calls https://github.com/edolstra/flake-compat. It's similar to @zimbatm's sources.nix but uses the latest lock file format (which is simpler since it doesn't require parsing of flake URLs).

@edolstra edolstra closed this Feb 25, 2020
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.

None yet

3 participants