nix icon indicating copy to clipboard operation
nix copied to clipboard

Push source into `nix/` subdir to avoid annoying extra rebuilds

Open Ericson2314 opened this issue 4 years ago • 2 comments

Currently, flake.nix, docker.nix, etc. "pollute" the most of the nix build's derivations, even though these files are not need at build time. This makes end-to-end testing of builds rather annoying, too many edits are "mass rebuilds".

Rather than do lots of complicated filtering, we just moved Nix itself to be in a sub-directory, just like perl/ for the perl bindings. This means that we can take whole subdirs, which, after the usual git-based filtering, means we get what we want.

The churn of so many files being moved might raise some eyebrows, but I this this is the right approach. Git handles "pure" renames quite well (as opposed to file splits), so I don't expect this to negatively impact other developers.

Even more importantly, we want the Nix repo to be a good example for (potential) users of Nix of best practices. I think it's important people remember not thinking fancy filter is the best/only way to do things, and I also certainly don't want them to think that extra rebuilds are the inevitable cost of purity. This avoids making both negative impressions.

The one caveat is that without making officialRelease = true, versionSuffix will end up tainting everything with the commit hash anyways. I have just been setting officialRelease = true and remembering not to commit it, which works but we can do better. I am not sure what the right thing to do is, and am certainly open to suggestions.

Mostly fixes #5574

Ericson2314 avatar Nov 17 '21 23:11 Ericson2314

I don't think this is a good approach. Being forced to move almost the entire source tree into a subdirectory just to work around a Nix issue is not best practice and not something most projects would want to do. I mean, surely we don't want to tell users that adding a flake.nix requires reorganizing their entire repository.

edolstra avatar Nov 18 '21 10:11 edolstra

@edolstra this has nothing to do with flakes I now see. Proper use of Nix with or without flakes does require separation components into subdirectories to avoid silly rebuilds unless we want to write lots of fancy fitlerSource, and that is good practice anyways even without Nix to make logical boundaries clear.

Remember, this is not a single-package repo, for nix itself and the perl bindings are separate packages.

Ericson2314 avatar Nov 18 '21 17:11 Ericson2314

On pause until a decision is reached in https://github.com/NixOS/nix/issues/7876.

Ericson2314 avatar Feb 21 '23 17:02 Ericson2314