NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.94k stars 1.53k forks source link

Nix needs a way to preprocess Nix expressions #868

Closed philip-wernersbach closed 5 years ago

philip-wernersbach commented 8 years ago

We're using Nix, NixOS, and NixOps at work for development and testing of our software applications. The issue with this is that our use case requires that the Nix expressions for our applications always use our git HEAD as a source base. It is infeasible to expect our developers to update our Nix expressions by hand every time they update HEAD, and Nix has no way to preprocess and insert our HEAD revision into the Nix expressions on-the-fly.

We've had to settle for using Make as a preprocessor for our Nix expressions. So our developers run make, which will update our Nix expressions to the HEAD revision, and then they can install the Nix expression using the standard Nix utilities. This feels like a huge hack: Nix is a great and full featured language, but we have to fall back to using a different language for actually preparing Nix. It also pulls in a dependency on make that we could otherwise avoid.

philip-wernersbach commented 8 years ago

I'll also add that this leads to awkward/political questions like "if Nix is so great, why are we still using Make?" It's hard to explain this while still convincing them that Nix is the way to go.

vcunat commented 8 years ago

There's the following option, although perhaps not very bandwidth-efficient:

NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz

(or you can pass it via -I nixpkgs=...)

joelmo commented 8 years ago

Can you override the derivations you need? The src attribute accepts a path, you can also override mkDerivation to suit your needs.

Ericson2314 commented 8 years ago

Sounds like you should also be using hydra? There is also https://github.com/shlevy/nix-exec, which does some fairly clever cached fetching, @shlevy can explain more.

shlevy commented 8 years ago

Yes, this kind of thing was one of the main use cases motivating nix-exec. In addition to built-in git fetching as a primitive action, it is overall designed so that nix-exec is the only tool you should need installed to accomplish whatever build/deployment setup you're aiming for.

edolstra commented 5 years ago

Closing, this particular use case is addressed by flakes.

Ericson2314 commented 5 years ago

I don't think we should be closing issues addressed by flakes until flakes are merged? Better to make the commit "closing #..." on that branch so they are closed automatically on merge.