Skip to content

Instantly share code, notes, and snippets.

View sorki's full-sized avatar
🦊
Tying the Knots

Sorki sorki

🦊
Tying the Knots
View GitHub Profile
@sorki
sorki / spi.dts
Last active April 19, 2025 17:31
pi2 spi.dts
#include <dt-bindings/pinctrl/bcm2835.h>
/dts-v1/;
/plugin/;
/ {
compatible = "raspberrypi,2-model-b";
fragment@0 {
target = <&spi>;
__overlay__ {
cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
@sorki
sorki / dns.nix
Last active April 2, 2025 15:06
NSD AdugardHome Unbound dns.nix example
{ config, pkgs, lib, ... }:
{
# 253 nsd
# 153 adguardhome
# 53 unbound
services.nsd =
let dns =
import ("${builtins.fetchTarball {
url = "https://github.com/nix-community/dns.nix/archive/refs/tags/v1.2.0.tar.gz";
@sorki
sorki / libvirt.nix
Created May 11, 2022 13:13
libvirt with statically configured bridge
# Module for configuring libvirt with static NixOS networking
# instead of using libvirt managed bridge.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.virtualisation.libvirtd.networking;
v6Enabled = cfg.ipv6.network != null;
v6PLen = toInt (elemAt (splitString "/" cfg.ipv6.network) 1);
boot.kernel.sysctl = {
"net.ipv4.conf.all.forwarding" = true;
"net.ipv6.conf.all.forwarding" = true;
};
@sorki
sorki / containers-nested.nix
Created February 22, 2021 10:47
nested NixOS containers
import <nixpkgs/nixos/tests/make-test-python.nix> ({pkgs, ...}: rec {
name = "nesting";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ sorki ];
};
machine = { lib, ... }:
let makeNested = subConf: {
boot.enableContainers = true;
@sorki
sorki / ircbride.nix
Created November 26, 2023 17:01
ircbridge example
services.ircbridge = {
enable = true;
instances = {
staging.irc = {
nick = "ircbridge";
host = "localhost";
port = 6666;
channels = [
"#bottest"
];
@sorki
sorki / rmq.nix
Created November 26, 2023 16:53
rabbit
services.rabbitmq = {
enable = true;
configItems = {
"heartbeat" = "6";
"tcp_listen_options.keepalive" = "true";
"tcp_listen_options.send_timeout" = "1500"; # default is 15000
"management.tcp.ip" = "127.0.0.1";
"management.tcp.port" = "15672";
};
plugins = [ "rabbitmq_management" ];
@sorki
sorki / callNode2nix.nix
Created January 8, 2021 13:35
callNode2nix.nix
{ pkgs ? import <nixpkgs> {}, ... }:
# experiment based on https://github.com/MatrixAI/TypeScript-Demo-Lib/pull/13
# needs `--option sandbox false` so not used for now
with pkgs;
let
callNode2nix = name: src: { nodeVersion ? builtins.elemAt (lib.versions.splitVersion nodejs.version) 0 }:
let
@sorki
sorki / displaced.hs
Created April 23, 2022 13:44
Displace implicit function
import Prelude
import Control.Applicative (pure)
import Graphics.Implicit
import Graphics.Implicit.Definitions
import Graphics.Implicit.Primitives
displaced
:: (Object obj vec)
=> (vec -> Double)
-> obj
@sorki
sorki / configuration.nix
Created August 25, 2020 14:13
rpi cross
{ config, lib, pkgs, ... }:
{
imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix>
];
nixpkgs = {
crossSystem.system = "armv7l-linux";
};