extra-container
extra-container copied to clipboard
Add complicated pinning feature (WIP)
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.
Companion to https://github.com/erikarvstedt/extra-container/issues/16
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.
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'
Solved by Flakes support.