Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔

Carl Richard Theodor CRTified

🤔
  • Germany
View GitHub Profile
View build.sh
nix-build \
--cores 0 \
'<nixos-unstable/nixos>' \
-I nixos-config=image.nix \
-A config.system.build.sdImage \
-o result-cross \
--show-trace
View nextcloud.nix
{
services.postgresql = {
enable = true;
ensureDatabases = [ "nextcloud" ];
ensureUsers = [
{ name = "nextcloud";
ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
}
];
};
@CRTified
CRTified / webcam.nix
Last active Apr 23, 2020
Webcam Setup with v4l-utils and udev
View webcam.nix
{
services.udev.extraRules = let
camSettings = pkgs.writeShellScript "setup-v4l2.sh" ''
${pkgs.v4l-utils}/bin/v4l2-ctl \
--device $1 \
--set-fmt-video=width=1920,height=1080,pixelformat=MJPG \ # Set to 1080p
-p 30 \ # Set to 30 FPS
--set-ctrl=power_line_frequency=1 \ # Set to 50Hz power line compensation
--set-ctrl=focus_auto=0 # Disable autofocus
'';
View bracketcall.hs
bracket
(do
sock <- socket AF_UNIX Stream 0
setSocketOption sock ReuseAddr 1
bind sock $ SockAddrUnix s
listen sock maxListenQueue
return sock
)
(\sock -> do
@CRTified
CRTified / README.md
Last active Aug 30, 2020
VFIO Passthrough on NixOS
View README.md

VFIO Setup on NixOS

Disclaimer: Nobody else tested my setup so far, so this is a "works on my machine" scenario. I am not responsible for anything you break on your machine (although I'd not expect much harm).

Hardware

My system has the following hardware:

  • Board: Asus ROG Strix Z270G
@CRTified
CRTified / libvirt.nix
Created Jun 25, 2019
VFIO Passthrough
View libvirt.nix
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.virtualisation.libvirtd;
boolToZeroOne = x: if x then "1" else "0";
aclString = with lib.strings;
concatMapStringsSep ",\n " escapeNixString cfg.deviceACL;
in {
@CRTified
CRTified / xmonad.hook
Last active Jun 29, 2018
Automatic recompilation after xmonad or haskell libs update
View xmonad.hook
[Trigger]
Operation=Install
Operation=Upgrade
Type=Package
Target=xmonad
Target=haskell-*
[Action]
Depends=xmonad
When=PostTransaction
@CRTified
CRTified / vpnwatch.service
Created Jun 25, 2018
Simple Openvpn Watchdog
View vpnwatch.service
[Unit]
Description=VPN watchdog
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'ping -I tun0 -c 1 8.8.8.8 > /dev/null || systemctl restart openvpn@configname.service'
[Install]
WantedBy=multi-user.target
View shebang.c
#!/usr/bin/env sh
#if 0
TMPFILE=$(mktemp);
tail -n +10 $0 | gcc -march=native -o $TMPFILE -x c -;
$TMPFILE "${@:1}";
RETVAL=$?
rm $TMPFILE;
exit $RETVAL;
#endif
View 42_iPXE
#!/bin/sh
BOOTUUID=`blkid -o value $(df /boot | grep "$MOUNTPOINT\$"| cut -f1 -d" ") | head -n 2 | tail -n1`;
ROOTUUID=`blkid -o value $(df / | grep "$MOUNTPOINT\$"| cut -f1 -d" ") | head -n 2 | tail -n1`;
PREFIX=""
if [ "$BOOTUUID" = "$ROOTUUID" ]; then
PREFIX="/boot"
fi;