Skip to content

Instantly share code, notes, and snippets.

Setting up qemu VM using nix flakes

Did you know that it is rather easy to setup a VM to test your NixOs configuration?

Create simple flake:

# flake.nix
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
wget http://dl-cdn.alpinelinux.org/alpine/v3.15/releases/armv7/alpine-uboot-3.15.0-armv7.tar.gz
wget http://dl-cdn.alpinelinux.org/alpine/v3.15/releases/armv7/alpine-minirootfs-3.15.0-armv7.tar.gz
qemu-img create -f raw sd.img 512M
sudo losetup /dev/loop0 sd.img
sudo kpartx -av /dev/loop0
lsblk
sudo mkfs.ext4 /dev/mapper/loop0p1
mount /dev/mapper/loop0p1 /mnt
@onny
onny / gist:b14fc9ef16d2a313f9e3e528a0f0aad6
Created May 15, 2016 11:15
signal-desktop debug log
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 Signal-Desktop/0.12.1
2016-05-14T13:15:46.678Z GET https://textsecure-service-ca.whispersystems.org:4433/v1/devices 200 Success
2016-05-14T13:15:46.680Z opening websocket
2016-05-14T13:15:47.055Z websocket open
2016-05-14T13:17:16.251Z websocket closed 1006
2016-05-14T13:17:16.255Z GET https://textsecure-service-ca.whispersystems.org:4433/v1/devices
2016-05-14T13:17:16.672Z GET https://textsecure-service-ca.whispersystems.org:4433/v1/devices 200 Success
2016-05-14T13:17:16.675Z opening websocket
2016-05-14T13:17:17.058Z websocket open
2016-05-14T13:18:46.253Z websocket closed 1006
@onny
onny / test.py
Created September 12, 2015 20:17
Bottlepy get parameters utf8
#!/usr/bin/python
from bottle import route, run, template, request
@route('/hello/<name>')
def index(name):
prename = request.query['prename']
return template('<b>Hello {{prename}} {{name}}</b>!', name=name, prename=prename)
run(host='localhost', port=8080)
@onny
onny / test.py
Created July 14, 2015 12:28
I2C Buspirate Python3
from I2C import *
import time
timestring = time.strftime("%Y-%m-%d %H:%M:%S")
i2caddr = 0x0B # Slave address of battery controller
def get_word(i2c, i2caddr, addr):
""" Reads two byte value (big-endian) from address addr """
i2c.send_start_bit();
stat = i2c.bulk_trans(2, [i2caddr<<1, addr]);