Skip to content

Instantly share code, notes, and snippets.

@samueldr
Created December 10, 2017 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueldr/899704735e1239472921ebc4231e0dac to your computer and use it in GitHub Desktop.
Save samueldr/899704735e1239472921ebc4231e0dac to your computer and use it in GitHub Desktop.
kimsufi nixos notes
Setup NixOS
===========
Install debian 9
> / for all space, ext4
> swap, 8GB
Boot into rescue
* * *
root@rescue:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
├─sda2 8:2 0 1.8T 0 part
├─sda3 8:3 0 8G 0 part
└─sda1 8:1 0 1004.5K 0 part
# Wat??
# Oh well
root@rescue:~# mount /dev/sda2 /mnt
root@rescue:~# ip addr
...
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 4c:72:b9:43:50:c9 brd ff:ff:ff:ff:ff:ff
inet 142.4.208.189/24 brd 142.4.208.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2607:5300:60:dbd::1/128 scope global
valid_lft forever preferred_lft forever
inet6 fe80::4e72:b9ff:fe43:50c9/64 scope link
valid_lft forever preferred_lft forever
...
umount /dev/sda2
`````
## QEMU / VNC installation
`````
# VNC stuff
root@rescue:~# apt-get -y install qemu kvm
# URL from nixos download page
root@rescue:~# wget https://d3_________mrk.cloudfront.net/nixos/17.03/nixos-17.03-___________.iso
# Boot that system
root@rescue:~#
qemu-system-x86_64 \
-net nic -net user,hostfwd=tcp::80-:80,hostfwd=tcp::443-:443 \
-m 4096M -localtime -enable-kvm -cpu kvm64,+nx -smp 2 -usbdevice tablet \
-k en-us -cdrom nixos-minimal-*.iso -hda /dev/sda -vnc 127.0.0.1:0 \
-boot d
`````
VNC access
`````
local $ ssh root@SERVER -L 5900:localhost:5900
`````
`````
local $ vncviewer localhost
`````
THEN, from that point on it's a classic nixos love story.
* cfdisk
* mkfs.ext4 -L nixos /dev/sda1
* mkswap -L swap /dev/sda2
```````
/dev/disk/by-label/nixos -> ../../sda1
/dev/disk/by-label/swap -> ../../sda2
```````
* swapon /dev/disk/by-label/swap
* mount /dev/disk/by-label/nixos /mnt
* nixos-generate-config --root /mnt
* vim /mnt/etc/nixos/configuration.nix
Ensure all you need is in there *for a minimal boot*
This means ssh, and keys.
* vim /mnt/etc/nixos/hardware-configuration.nix
-> ensure uuids seem good.
-> remove qemu-guest and replace with
````
[ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
];
````
Available kernel modules: ahci
kernelModules: "kvm-intel"
nix.maxJobs = 4
aaaaand it's done.
Booting the rescue disk, using qemu-kvm to *boot the whole disk*, forwarding the screen through ssh using vnc.
* * *
* Unfucking through qemu-kvm
* First, install qemu-kvm stuff
> TODO : Test without upgrading, as upgrading takes WAY TOO MUCH TIME.
* Download iso by wgetting link from https://nixos.org/nixos/download.html
* Update your system
apt-get -y update
apt-get -y --force-yes upgrade
* Install qemu + kvm
apt-get -y install qemu kvm
When all this is done, start the VM:
```
# Boots the iso
root@rescue:~# qemu-system-x86_64 -net nic -net user,hostfwd=tcp::80-:80,hostfwd=tcp::443-:443 -m 4096M \
-localtime -enable-kvm -cpu kvm64,+nx -smp 2 -usbdevice tablet -k en-us -cdrom nixos-minimal-*.iso \
-hda /dev/sda -vnc 127.0.0.1:0
# Boots the system
root@rescue:~# qemu-system-x86_64 -net nic -net user,hostfwd=tcp::80-:80,hostfwd=tcp::443-:443 -m 4096M \
-localtime -enable-kvm -cpu kvm64,+nx -smp 2 -usbdevice tablet -k fr-ca -cdrom nixos-minimal-*.iso \
-hda /dev/sda -vnc 127.0.0.1:0 -boot d
```
[local] ⬤ ssh root@SERVER -L 5900:localhost:5900
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment