Skip to content

Instantly share code, notes, and snippets.

View CRTified's full-sized avatar
🤔

Carl Richard Theodor Schneider CRTified

🤔
View GitHub Profile
{
services.postgresql = {
enable = true;
ensureDatabases = [ "nextcloud" ];
ensureUsers = [
{ name = "nextcloud";
ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
}
];
};
@CRTified
CRTified / webcam.nix
Last active April 23, 2020 11:00
Webcam Setup with v4l-utils and udev
{
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
'';
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 March 24, 2024 18:03
VFIO Passthrough on NixOS

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: ASRock X570 Pro4
@CRTified
CRTified / libvirt.nix
Created June 25, 2019 23:13
VFIO Passthrough
{ 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 February 24, 2021 07:53
Automatic recompilation after xmonad or haskell libs update
[Trigger]
Operation=Install
Operation=Upgrade
Type=Package
Target=xmonad
Target=haskell-*
[Action]
Depends=xmonad
When=PostTransaction
@CRTified
CRTified / vpnwatch.service
Created June 25, 2018 11:29
Simple Openvpn Watchdog
[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
@CRTified
CRTified / shebang.c
Last active February 6, 2018 19:03
Shebangs
#!/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
@CRTified
CRTified / 42_iPXE
Created November 2, 2017 21:00
iPXE netboot
#!/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;
@CRTified
CRTified / xmonad.hs
Created October 1, 2017 18:15
ACPI logger
-- Define acpi power logger
acpi_power :: String -> [String] -> Logger
acpi_power dev attr =
io $ do
attrOut <- mapM (\x -> liftIO $ readFile $ sysFsPath ++ x) attr
return $ Just $ filter (/= '\n') (intercalate " " attrOut)
where
sysFsPath = "/sys/class/power_supply/" ++ dev ++ "/"
file_reader :: String -> Logger