it seems like every single question i have pertaining to nix is unanswerable for some reason

all i want is to somehow `nixos-rebuild build-vm` with the config somehow knowing this is a vm build so i can drop the hardware stuff in my config T,T

apparently `mkVMOverride` is what i was looking for the whole time and only after ranting on the internet and embarrassing myself do i get an answer why is life pain and


so apparently `mkVMOverride` wasn't quite what i was looking for to have certain options disabled in vm builds. it's actually used by `nixos/modules/virtualisation/qemu-vm.nix` to override things like the `filesystems` in your config when creating vm builds. thanks to someone replying on the nix discord, i ended up with:

isVMBuild = (lib.hasAttr "/tmp/xchg" config.fileSystems) && config.fileSystems."/tmp/xchg".fsType == "9p";

for context, i was just testing with my `snapper.nix` configuration[1] to see if i could have snapper disabled in vm builds.

i'm not sure if this or the solution i originally came with is less hacky, mine being to check if `/home` is defined in the build. this works because `qemu-vm.nix` does not have a `/home` mount either.

on the other hand, would what i originally have wanted be clean anyway? after all, the following might fall under flag-oriented programming?

mkIf isVMBuild {}



Β· Β· Web Β· 1 Β· 0 Β· 0

> nothing excites a functional programmer more than the ability to not do something

Sign in to participate in the conversation
Serenity Laboratories

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!