nlewo / nix2container

An archive-less dockerTools.buildImage implementation
Apache License 2.0
501 stars 45 forks source link

Refactor nix files #99

Open deemp opened 10 months ago

deemp commented 10 months ago
deemp commented 10 months ago

@nlewo, please, check when you have time

nlewo commented 10 months ago

Hello @deemp and thanks for your contribution!

FYI, we actually had an overlay which has been removed for performance issues... See https://github.com/nlewo/nix2container/pull/3

Would we have the same issue with your proposition?

deemp commented 10 months ago

@nlewo, I want a mechanism to use nix2container with arbitrary pkgs without inputs.nix2container.nixpkgs.follows. Can I achieve that without an overlay? Yes, if the repo provides a function mkNix2container = {pkgs}: .... Does this mean the repo shouldn't provide an overlay? Not really.

I believe we will have no performance issues. In the article (link) linked in the issue #3, the author writes about performance issues when using two different versions of nixpkgs in flake inputs, not when using overlays.

Especially with the advent of Flakes, soon enough, we will end up with 1000 dependencies, each with its own instance of nixpkgs. Given that nixpkgs takes around 100MiB of RAM and a second to evaluate, that can quickly add up.

In a discussion, the author says it's okay to use overlays in certain cases (link).

That’s right. This is a limitation of how the flakes work; there is no mechanism to override flakes. For that use-case, each flake would also have to expose an overlay. Probably this should be part of a dedicated Flakes best practices article.

A commenter states that per-overlay overhead is minimal (link).

psionic-k commented 5 months ago
          pkgs = import nixpkgs {
            inherit system;
            overlays = [
              inputs.fenix.overlays.default
              inputs.nix2container.overlays.default
            ];
          };

This is the way.

Without this style, I see that my input is bringing along its own packages and wonder if they are from nixpkgs-22.05 or whatever. In general, proliferation of nixpkgs versions should only be used as a last resort, so overlay style of use, which presumes to be consumed with the user's version of nixpkgs, is the correct default usage pattern.

Btw

trace: warning: `vendorSha256` is deprecated. Use `vendorHash` instead

I'm just evaluating tools and saw this PR.

MaxDaten commented 5 months ago

trace: warning: vendorSha256 is deprecated. Use vendorHash instead

Which now fails in application:

https://github.com/cachix/devenv/issues/1083