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";
@Eriner
Eriner / custom.css
Last active January 17, 2023 20:06
Bring back the Mastodon toots
.compose-form__publish-button-wrapper .button--block {
font-size: 0px;
}
.compose-form__publish-button-wrapper .button--block::after {
content: "Toot!";
font-size: 15px;
vertical-align: middle;
color: #fff;
}
@SCOTT-HAMILTON
SCOTT-HAMILTON / get-command-nix-deps.sh
Last active July 12, 2022 18:49
Get nix executable dependencies required to run a shell command for a certain a time
#! /usr/bin/env nix-shell
#! nix-shell -i sh -p coreutils findutils gnused ripgrep strace
# Usage ./get-command-nix-deps.sh ./script.sh 10s
timeout "$2" strace -qqfe execve sh -c "$1" 2>&1 >/dev/null | \
rg '(/nix/store|/run/current-system/sw/bin)' | \
sed -E 's=.*execve\("(\/.*)", \[.*=\1=g' | \
xargs readlink -f | sort -u | \
sed -E 's=/nix/store/[0-9a-z]*-(.*)-(.*)/.*/.*=\1 (\2)=g' | sort -u
@nitred
nitred / optimal_mtu.md
Last active April 16, 2024 06:57
Wireguard Optimal MTU

About

  • I faced bandwidth issues between a WG Peer and a WG server. Download bandwidth when downloading from WG Server to WG peer was reduced significantly and upload bandwidth was practically non existent.
  • I found a few reddit posts that said that we need to choose the right MTU. So I wrote a script to find an optimal MTU.
  • Ideally I would have liked to have run all possible MTU configurations for both WG Server and WG Peer but for simplicity I choose to fix the WG Server to the original 1420 MTU and tried all MTUs from 1280 to 1500 for the WG Peer.

Testing

  • On WG server, I started an iperf3 server
  • On WG peer, I wrote a script that does the following:
    • wg-quick down wg0
  • Edit MTU in the /etc/wireguard/wg0.conf file
@TheSirC
TheSirC / v4l2.nix
Last active March 27, 2023 19:30
My Nix module to work with v4l2loopback
{ lib, config, pkgs, ... }:
with lib;
{
options.v4l2 = mkEnableOption "Enable the confguration to use the reflex as a webcam";
config = mkIf config.v4l2 {
# 20.03: v4l2loopback 0.12.5 is required for kernel >= 5.5
# https://github.com/umlaeute/v4l2loopback/issues/257
@Xe
Xe / README.md
Created March 12, 2020 09:35
docker-containers example for NixOS/NixOps

NixOps Deployment of a Docker Container

Install NixOps

If using NixOS:

$ nix-env -iA nixos.nixops
@MCJack123
MCJack123 / ipsw_keys.py
Last active December 1, 2023 22:46
Extract iOS firmware keys using on-device AES engine
#!/usr/bin/env python
from sys import argv, stdout
from os import system, remove, path
from urlparse import urlparse
import re
import dfu
import ssl
import math
import json
import getopt
@edrex
edrex / README.md
Last active April 23, 2024 18:23
Streaming screen capture under Wayland

Recipes

kmsgrab capture with ffmpeg

sudo LIBVA_DRIVER_NAME=iHD ffmpeg -crtc_id 69  -framerate 60 -f kmsgrab -i - -vaapi_device /dev/dri/renderD128 -filter:v hwmap,scale_vaapi=w=1920:h=1200:format=nv12 -c:v h264_vaapi -profile:v constrained_baseline -level:v 3.1 -b:v 20000k test.mp4

LIBVA_DRIVER_NAME=iHD ffmpeg -device /dev/dri/card0 -f kmsgrab -i - -vf 'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12' -c:v h264_vaapi -vstats output.mp4

#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
PORT_NUMBER = 31337
class myHandler(BaseHTTPRequestHandler):
#Handler for the GET requests
def do_GET(self):
self.send_response(200)
@danbst
danbst / iphone.nix
Created September 8, 2018 20:05
iPhone pairing for NixOS
# First add this module to your /etc/nixos/configuration.nix
# ...
# imports = [ /path/to/iphone.nix ];
# iphone.enable = true;
# iphone.user = "yourusername";
# ...
# Then rebuild system. Attach iPhone via cable, open terminal and run command `iphone`
# It will fail, but there will occure a dialog on your iPhone to "trust this computer"
# Press OK there and run `iphone` again. If it succeeds it will open a freshly mounted folder