extra-container icon indicating copy to clipboard operation
extra-container copied to clipboard

Add complicated pinning feature (WIP)

Open deliciouslytyped opened this issue 4 years ago • 3 comments

This adds pinning functionality, by having extra-container/eval-config re-call itself when it detects extra.overrideArgs is set. This allows, for example, to pin nixpkgs with niv, by overriding the nixosPath argument with an expression such as

 {
  ...
  extra = {
    overrideArgs = { nixosPath = (import ./sources.nix {}).nixpkgs + "/nixos"; };
    };
  ...
}

Note that extra-container technically allows specifiying multiple containers in a file, however the pinning functionality cannot currently handle this. The settings in the first (by nix attrset ordering) container are used.

Changes: I changed the function signature of eval-config to take an attrset. This lets us pass on the args alias. I added an option to extraModule. There is still some ad-hoc debugging with tracing, which is imported from lib and so depends on <>/nixos being in a nixpkgs checkout, so that lib can be imported. If stage1.config.containers..extra.overrideArgs is set, a detour is taken through the stage2 function which does the actual overriding.

deliciouslytyped avatar Jan 31 '21 13:01 deliciouslytyped

Companion to https://github.com/erikarvstedt/extra-container/issues/16

deliciouslytyped avatar Jan 31 '21 13:01 deliciouslytyped

If stage1.config.containers..extra.overrideArgs is set, a detour is taken through the stage2 function which does the actual overriding.

Note that stage1 is evaluated twice, once with the host NIX_PATH, to get the pinning attrs, and once with the pinned nixpkgs one.

deliciouslytyped avatar Jan 31 '21 13:01 deliciouslytyped

To work around this myself after hitting #23, I ended up using nix-shell to set the NIX_PATH to make this work automatically:

https://github.com/nycresistor/golden-nix/blob/0bdd76ce1c0a63b0175362536d804a4a9827e7a6/shell.nix https://github.com/nycresistor/golden-nix/blob/0bdd76ce1c0a63b0175362536d804a4a9827e7a6/extra-container

Then to update containers is just ./extra-container create -r -s . which is a really nice workflow.

Not the best, but easier than the following command line:

extra-container build . --nixpkgs-path '(import ./nix/sources.nix).nixpkgs'

georgyo avatar Aug 12 '21 01:08 georgyo

Solved by Flakes support.

erikarvstedt avatar Oct 22 '22 14:10 erikarvstedt