Closed onny closed 9 months ago
Hey, I have this flake.nix to launch nixos-shell:
flake.nix
{ description = "Spawns lightweight nixos vm in a shell"; inputs = { nixpkgs.url = "nixpkgs/nixos-23.11"; nixos-shell.url = "github:Mic92/nixos-shell"; }; outputs = { self, nixpkgs, nixos-shell }: let pkgs = nixpkgs.legacyPackages.x86_64-linux; start = pkgs.writeShellScriptBin "start" '' set -e export QEMU_NET_OPTS="hostfwd=tcp::8080-:80,hostfwd=tcp::1433-:143,hostfwd=tcp::5877-:587" ${pkgs.nixos-shell}/bin/nixos-shell --flake . ''; in { nixosConfigurations.vm = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ (import ./vm-nextcloud.nix) nixos-shell.nixosModules.nixos-shell ]; }; packages = { inherit start; }; defaultPackage.x86_64-linux = start; }; }
This is great because now the VM itself is pinned to the version of nixpkgs.url defined in this flake.nix.
Inside vm-nextcloud,nix I have this part:
vm-nextcloud,nix
nixos-shell.mounts.extraMounts = { "/var/lib/nextcloud/cleanup" = { target = ./cleanup; cache = "none"; }; };
But this fails because /var/lib/nextcloud/cleanup is a local path of the host and the Flake cannot access it. I tried to use the --impure flag on nixos-shell but that didn't work.
/var/lib/nextcloud/cleanup
--impure
nixos-shell
Best regards Jonas
I think with flakes you would need absolute paths. I think we are already relying on --impure to get some other environment variables into nixos-shell
Thank you, this was my fault. It's working now like you said :)
Hey, I have this
flake.nix
to launch nixos-shell:This is great because now the VM itself is pinned to the version of nixpkgs.url defined in this
flake.nix
.Inside
vm-nextcloud,nix
I have this part:But this fails because
/var/lib/nextcloud/cleanup
is a local path of the host and the Flake cannot access it. I tried to use the--impure
flag onnixos-shell
but that didn't work.Best regards Jonas