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 July 16, 2024 11:51
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
@walkermalling
walkermalling / luks-encrypted-root-on-nixos.org
Last active July 16, 2024 10:59
Nix Setup with LUKS encrypted root

Setting up NixOs with LUKS encrypted root

Here are my working notes on getting a system up and running.

WARNING: You can run into a hidden problem that will prevent a correct partition setup and /etc/nixos/configuration.nix from working: if you are setting up a UEFI system, then you need to make sure you boot into the NixOS installation from the UEFI partition of the bootable media. You may have to enter your BIOS boot selection menu to verify this. For example, if you setup a NixOS installer image on a flash drive, your BIOS menu may display several boot options from that flash drive: choose the one explicitly labeled with “UEFI”.

References

I used these resources:

@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)