Skip to content

Instantly share code, notes, and snippets.

@erikarvstedt
Created April 30, 2020 21:33
Show Gist options
  • Save erikarvstedt/db6410924ebde429841b7b8661181f12 to your computer and use it in GitHub Desktop.
Save erikarvstedt/db6410924ebde429841b7b8661181f12 to your computer and use it in GitHub Desktop.
vm=$(nix-build --no-out-link - <<'EOF'
(import <nixpkgs/nixos> {
configuration = { pkgs, lib, ... }: with lib; {
users.users.me.isNormalUser = true;
services.xserver = {
enable = true;
desktopManager.xterm.enable = true;
displayManager.lightdm = {
enable = true;
autoLogin.enable = true;
autoLogin.user = "me";
};
displayManager.sessionCommands = ''
keyboardId=$(
${pkgs.xorg.xinput}/bin/xinput |
sed -nE 's/.*?Virtual core keyboard.*?id=([0-9]+).*?master keyboard.*/\1/p'
)
if [[ $keyboardId ]]; then
${pkgs.xorg.setxkbmap}/bin/setxkbmap -device $keyboardId -option caps:swapescape
fi
'';
};
};
}).vm
EOF
)
export NIX_DISK_IMAGE=/tmp/vmimg; rm -f $NIX_DISK_IMAGE; QEMU_OPTS='-m 1024 -smp 3' $vm/bin/run-*-vm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment