Closed thkoch2001 closed 8 months ago
How about
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
How can I configure the VM so that it gets built with a working reference to the nixpkgs channel that was also used to build the VM?
I use flakes but you can get a channel with the <nixpkgs>
syntax. So maybe try that in your MicroVM NixOS configuration:
nix.nixPath = builtins.storePath <nixpkgs>;
Thx for the hint, but unfortunately it gives:
error: 'builtins.storePath' is not allowed in pure evaluation mode
After reading way too much about nix path, nix profiles and the whole mess this seems to be, I'm not sure whether I want to dive into this topic right now.
Just for reference, these are the ideas I still have:
UPDATE
The following did the trick:
nix.nixPath = ["nixpkgs=${builtins.storePath <nixpkgs>}"];
together with running the flake with nix run --impure
.
Thank you for your investigation and write-up. I added that as an FAQ section.
Copied from this SO question, with addtions at the end: https://stackoverflow.com/questions/77728179/how-to-install-a-nix-channel-in-a-nixos-vm
I'm using microvm to create and run a NixOS vm (on a Debian system with the nix packet manager installed).
The NIX_PATH environment variable inside the VM is set to its default value:
The nixpkgs path referenced above however does not exist on the VM,
/nix/var/nix/profiles/per-user/
is empty.How can I configure the VM so that it gets built with a working reference to the nixpkgs channel that was also used to build the VM?
I need channels, because I want to use the nix integration of the Haskell tool "stack", which seems to rely on channels. When I use emacs' eglot on Haskell code inside the VM,
stack setup
gets called and fails with:My flake.nix to build the microvm: