astro / microvm.nix

NixOS MicroVMs
https://astro.github.io/microvm.nix/
MIT License
1.24k stars 93 forks source link

Allow overriding nixpkgs for VM #218

Closed bouk closed 5 months ago

bouk commented 5 months ago

This allows settings pkgs = null in the microvm config so it instantiates a new package set. This way you can configure nixpkgs inside the NixOS configuration.

Also add a 'nixpkgs' config option to allow overriding the nixpkgs path.

astro commented 5 months ago

What is the difference to setting config.nixpkgs.pkgs?

bouk commented 5 months ago

I was trying to set some nixpkgs options inside the VM configuration but then I get this error:

Failed assertions:
- Your system configures nixpkgs with an externally created instance. `nixpkgs.config` options should be passed when creating the instance instead.

Because the pkgs option is passed to eval-config.nix. So, I want to override pkgs to be null so doesn't set this pkgs: https://github.com/NixOS/nixpkgs/blob/8c7a594e40bd450af9f029ff43525714831bd045/nixos/lib/eval-config.nix#L58-L61

And then I need to get a nixpkgs reference somewhere to call eval-config so I had to add the nixpkgs argument for it.

astro commented 5 months ago

Thank you!