nix machine / user configurations

realtime-ish audio and discord proxy working

ptr.pet 8741a773 24ac226b

verified
Changed files
+362 -47
hosts
chernobog
dzwonek
modules
wolumonde
modules
modules
pkgs-set
users
modules
discord
rofi
sway
swayidle
tofi
+142 -2
flake.lock
···
{
"nodes": {
+
"chaotic": {
+
"inputs": {
+
"flake-schemas": "flake-schemas",
+
"home-manager": "home-manager",
+
"jovian": "jovian",
+
"nixpkgs": "nixpkgs",
+
"rust-overlay": "rust-overlay"
+
},
+
"locked": {
+
"lastModified": 1761548673,
+
"narHash": "sha256-/513FfwpfbeppPdGDbmLhgcctLqEHdx8Rs92jImKA3M=",
+
"owner": "chaotic-cx",
+
"repo": "nyx",
+
"rev": "25ef687b6a0a13e9d39c3949e7de05873f5571a9",
+
"type": "github"
+
},
+
"original": {
+
"owner": "chaotic-cx",
+
"ref": "nyxpkgs-unstable",
+
"repo": "nyx",
+
"type": "github"
+
}
+
},
+
"flake-schemas": {
+
"locked": {
+
"lastModified": 1721999734,
+
"narHash": "sha256-G5CxYeJVm4lcEtaO87LKzOsVnWeTcHGKbKxNamNWgOw=",
+
"rev": "0a5c42297d870156d9c57d8f99e476b738dcd982",
+
"revCount": 75,
+
"type": "tarball",
+
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.1.5/0190ef2f-61e0-794b-ba14-e82f225e55e6/source.tar.gz"
+
},
+
"original": {
+
"type": "tarball",
+
"url": "https://flakehub.com/f/DeterminateSystems/flake-schemas/%3D0.1.5.tar.gz"
+
}
+
},
+
"home-manager": {
+
"inputs": {
+
"nixpkgs": [
+
"chaotic",
+
"nixpkgs"
+
]
+
},
+
"locked": {
+
"lastModified": 1761513701,
+
"narHash": "sha256-w7qOcQb1FSMZASvWe01r99QqZ5LnHO0k3rgs5ryyig0=",
+
"owner": "nix-community",
+
"repo": "home-manager",
+
"rev": "255b6a0ef2f488a2fad051361699cc67db57338c",
+
"type": "github"
+
},
+
"original": {
+
"owner": "nix-community",
+
"repo": "home-manager",
+
"type": "github"
+
}
+
},
+
"jovian": {
+
"inputs": {
+
"nix-github-actions": "nix-github-actions",
+
"nixpkgs": [
+
"chaotic",
+
"nixpkgs"
+
]
+
},
+
"locked": {
+
"lastModified": 1761376732,
+
"narHash": "sha256-wavx9gROyuRZKSvPCCBh78gOur7o88ndRi545njNRrM=",
+
"owner": "Jovian-Experiments",
+
"repo": "Jovian-NixOS",
+
"rev": "8bef482d65425d0cff6b20c11a5f054f85569a38",
+
"type": "github"
+
},
+
"original": {
+
"owner": "Jovian-Experiments",
+
"repo": "Jovian-NixOS",
+
"type": "github"
+
}
+
},
+
"nix-github-actions": {
+
"inputs": {
+
"nixpkgs": [
+
"chaotic",
+
"jovian",
+
"nixpkgs"
+
]
+
},
+
"locked": {
+
"lastModified": 1729697500,
+
"narHash": "sha256-VFTWrbzDlZyFHHb1AlKRiD/qqCJIripXKiCSFS8fAOY=",
+
"owner": "zhaofengli",
+
"repo": "nix-github-actions",
+
"rev": "e418aeb728b6aa5ca8c5c71974e7159c2df1d8cf",
+
"type": "github"
+
},
+
"original": {
+
"owner": "zhaofengli",
+
"ref": "matrix-name",
+
"repo": "nix-github-actions",
+
"type": "github"
+
}
+
},
"nixpkgs": {
-
"flake": false,
+
"locked": {
+
"lastModified": 1761373498,
+
"narHash": "sha256-Q/uhWNvd7V7k1H1ZPMy/vkx3F8C13ZcdrKjO7Jv7v0c=",
+
"owner": "NixOS",
+
"repo": "nixpkgs",
+
"rev": "6a08e6bb4e46ff7fcbb53d409b253f6bad8a28ce",
+
"type": "github"
+
},
+
"original": {
+
"owner": "NixOS",
+
"ref": "nixos-unstable",
+
"repo": "nixpkgs",
+
"type": "github"
+
}
+
},
+
"nixpkgs_2": {
"locked": {
"lastModified": 1761512058,
"narHash": "sha256-FYDC/VM/Tu7bJ9uwxmZqIhkz7QblCcp65+LMb4StGTY=",
···
},
"root": {
"inputs": {
-
"nixpkgs": "nixpkgs"
+
"chaotic": "chaotic",
+
"nixpkgs": "nixpkgs_2"
+
}
+
},
+
"rust-overlay": {
+
"inputs": {
+
"nixpkgs": [
+
"chaotic",
+
"nixpkgs"
+
]
+
},
+
"locked": {
+
"lastModified": 1761446259,
+
"narHash": "sha256-JNNOtIIVIX+yBIsh1rq1Nxhc1LZq168vuQB5sqrZbCY=",
+
"owner": "oxalica",
+
"repo": "rust-overlay",
+
"rev": "95098bb4d55ebe167c082fc40705a73ef76b58e4",
+
"type": "github"
+
},
+
"original": {
+
"owner": "oxalica",
+
"repo": "rust-overlay",
+
"type": "github"
}
}
},
+2 -2
flake.nix
···
description = "config!!!";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/42060c40fd43c114af7010980168f8dcba734d3b";
-
inputs.nixpkgs.flake = false;
+
inputs.chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
outputs =
flakeInputs:
let
-
lib = import "${flakeInputs.nixpkgs}/lib";
+
lib = flakeInputs.nixpkgs.lib;
tlib = import ./lib lib;
l = lib;
-9
hosts/chernobog/default.nix
···
];
};
-
services.pipewire = {
-
enable = true;
-
audio.enable = true;
-
alsa.enable = true;
-
alsa.support32Bit = true;
-
pulse.enable = true;
-
jack.enable = true;
-
};
-
fonts = {
enableDefaultPackages = true;
packages = with pkgs; [
+8
hosts/chernobog/modules/ananicy.nix
···
+
{ pkgs, ... }:
+
{
+
services.ananicy = {
+
enable = true;
+
package = pkgs.ananicy-cpp;
+
rulesProvider = pkgs.ananicy-rules-cachyos_git;
+
};
+
}
+53
hosts/chernobog/modules/audio.nix
···
+
{ pkgs, ... }:
+
let
+
rate = 48000;
+
quant = 256;
+
quantRateMax = "${toString quant}/${toString rate}";
+
quantRateMin = "${toString (quant / 2)}/${toString rate}";
+
in
+
{
+
imports = [ ../../../modules/audio/desktop-audio.nix ];
+
+
environment.systemPackages = with pkgs; [
+
helvum
+
pwvucontrol
+
];
+
+
security.rtkit.enable = true;
+
services.pipewire = {
+
enable = true;
+
audio.enable = true;
+
alsa.enable = true;
+
alsa.support32Bit = true;
+
pulse.enable = true;
+
jack.enable = true;
+
};
+
+
services.pipewire.extraConfig.pipewire."92-low-latency" = {
+
"context.properties" = {
+
"default.clock.rate" = rate;
+
"default.clock.quantum" = quant;
+
"default.clock.min-quantum" = quant / 2;
+
"default.clock.max-quantum" = quant;
+
};
+
};
+
+
services.pipewire.extraConfig.pipewire-pulse."92-low-latency" = {
+
context.modules = [
+
{
+
name = "libpipewire-module-protocol-pulse";
+
args = {
+
pulse.min.req = quantRateMin;
+
pulse.default.req = quantRateMax;
+
pulse.max.req = quantRateMax;
+
pulse.min.quantum = quantRateMin;
+
pulse.max.quantum = quantRateMax;
+
};
+
}
+
];
+
stream.properties = {
+
node.latency = quantRateMax;
+
resample.quality = 1;
+
};
+
};
+
}
+4
hosts/chernobog/modules/kernel.nix
···
+
{ pkgs, ... }:
+
{
+
boot.kernelPackages = pkgs.linuxPackages_cachyos-lto;
+
}
+6 -1
hosts/default.nix
···
inherit lib;
system = null;
modules = [
+
# set.inputs.nixpkgs.nixosModules.readOnlyPkgs
{ networking.hostName = name; }
-
{ nixpkgs.pkgs = set.pkgs; }
+
{
+
nixpkgs.pkgs = set.pkgs;
+
chaotic.nyx.overlay.enable = false;
+
}
+
set.inputs.chaotic.nixosModules.default
(import (./. + "/${name}/default.nix"))
];
specialArgs = {
+5
hosts/dzwonek/modules/tailscale.nix
···
# age.secrets.tailscaleAuthKey.file = ../../../secrets/tailscaleAuthKey.age;
# services.tailscale.authKeyFile = config.age.secrets.tailscaleAuthKey.path;
+
+
services.tailscale = {
+
extraSetFlags = [ "--advertise-exit-node" ];
+
useRoutingFeatures = "both";
+
};
}
+4
hosts/wolumonde/modules/tailscale.nix
···
# age.secrets.tailscaleAuthKey.file = ../../../secrets/tailscaleAuthKey.age;
# services.tailscale.authKeyFile = config.age.secrets.tailscaleAuthKey.path;
+
services.tailscale = {
+
extraSetFlags = [ "--advertise-exit-node" ];
+
useRoutingFeatures = "both";
+
};
networking.firewall.public.tailscale.allowedUDPPorts = [
config.services.tailscale.port
+18
modules/audio/desktop-audio.nix
···
+
{
+
services.pipewire.extraConfig.pipewire = {
+
"10-virtual-sink" = {
+
"context.objects" = [
+
{
+
factory = "adapter";
+
args = {
+
"factory.name" = "support.null-audio-sink";
+
"node.name" = "virtual_sink";
+
"node.description" = "Virtual Sink for Recording";
+
"media.class" = "Audio/Sink";
+
"audio.position" = "FL,FR";
+
};
+
}
+
];
+
};
+
};
+
}
-2
modules/network/tailscale.nix
···
services.tailscale = {
enable = true;
port = 41641;
-
extraSetFlags = [ "--advertise-exit-node" ];
# extraUpFlags = [ "--ssh" ];
extraDaemonFlags = [ "--no-logs-no-support" ];
-
useRoutingFeatures = "both";
openFirewall = true;
};
+12 -13
pkgs-set/default.nix
···
;
};
inputs = (l.mapAttrs (_: inp: inp // { __toString = s: toString s.src; }) _inputs) // flakeInputs;
-
pkgs = _pkgs.appendOverlays (
-
l.flatten (
-
l.mapAttrsToList (
-
name: _:
-
if name != "disabled" then
-
let
-
o = import "${./overlays}/${name}";
-
in
-
if (l.functionArgs o) ? inputs then o { inherit inputs; } else o
-
else
-
[ ]
-
) (l.readDir ./overlays)
-
)
+
overlays = l.flatten (
+
l.mapAttrsToList (
+
name: _:
+
if name != "disabled" then
+
let
+
o = import "${./overlays}/${name}";
+
in
+
if (l.functionArgs o) ? inputs then o { inherit inputs; } else o
+
else
+
[ ]
+
) (l.readDir ./overlays)
);
+
pkgs = _pkgs.appendOverlays (overlays ++ [ flakeInputs.chaotic.overlays.cache-friendly ]);
terraPkgs = pkgs.lib.makeScope pkgs.newScope (
self:
l.genAttrs (l.map (l.removeSuffix ".nix") (l.attrNames (l.readDir ./pkgs))) (
+38 -4
users/modules/discord/default.nix
···
pkgs,
terra,
inputs,
+
lib,
...
}:
+
let
+
pkg = pkgs.discord.override {
+
withMoonlight = true;
+
inherit (terra) moonlight;
+
withOpenASAR = true;
+
withTTS = false;
+
};
+
in
{
# imports = ["${inputs.moonlight}/nix/home-manager.nix"];
home.packages = [
-
(pkgs.discord.override {
-
withMoonlight = true;
-
inherit (terra) moonlight;
-
withOpenASAR = true;
+
(pkgs.symlinkJoin {
+
name = "discord";
+
paths = [ pkg ];
+
buildInputs = [ pkgs.makeWrapper ];
+
postBuild = ''
+
wrapProgram $out/bin/discord \
+
--add-flags "--proxy-server=socks5://127.0.0.1:1337"
+
wrapProgram $out/bin/Discord \
+
--add-flags "--proxy-server=socks5://127.0.0.1:1337"
+
'';
})
];
+
+
systemd.user.services.discord-socks-proxy = {
+
Unit = {
+
Description = "SSH SOCKS5 proxy for Discord";
+
After = [ "network-online.target" ];
+
Wants = [ "network-online.target" ];
+
};
+
+
Service = {
+
Type = "simple";
+
ExecStart = "${pkgs.openssh}/bin/ssh -N -D 127.0.0.1:1337 root@wolumonde";
+
Restart = "on-failure";
+
RestartSec = "3s";
+
};
+
+
Install = {
+
WantedBy = [ "default.target" ];
+
};
+
};
}
-3
users/modules/rofi/default.nix
···
stylix.targets.rofi.enable = true;
programs.rofi = {
enable = true;
-
package = pkgs.rofi.overrideAttrs (old: rec {
-
buildInputs = builtins.filter (x: x.pname != "gdk-pixbuf") old.buildInputs;
-
});
};
}
+7 -11
users/modules/sway/default.nix
···
imports = [
../wayland
../swaylock
+
../swayidle
../wlsunset
../mako
-
../rofi
+
../tofi
# ./swayidle.nix
];
···
wayland.windowManager = {
sway =
let
-
mkRofiCmd =
-
args:
-
"${config.programs.rofi.package}/bin/rofi ${lib.concatStringsSep " " args} | ${pkgs.sway}/bin/swaymsg --";
inherit (tlib) pkgBin;
in
{
···
border = 0;
titlebar = false;
};
-
menu = mkRofiCmd [
-
"-show"
-
"drun"
-
];
+
menu = "${config.programs.tofi.package}/bin/tofi-drun";
modifier = "Mod4";
terminal = config.settings.terminal.binary;
startup = [
···
shotFile = config.home.homeDirectory + "/shots/shot_$(date '+%Y_%m_%d_%H_%M')";
shotDir = config.home.homeDirectory + "/shots";
in
-
{
+
lib.mkOptionDefault {
"${mod}+d" = "exec ${config.wayland.windowManager.sway.config.menu}";
"${mod}+Return" = "exec ${config.wayland.windowManager.sway.config.terminal}";
"${mod}+Escape" = "exec ${wlogout} -p layer-shell";
···
exec export SFILE="${shotFile}.png" && mkdir -p ${shotDir} && ${grim} -g "$(${slurp})" "$SFILE" && ${cat} "$SFILE" | ${wl-copy} -t image/png
'';
# record screen
-
"Mod1+r" = ''exec mkdir -p ${shotDir} && ${wf-recorder} -x yuv420p -f "${shotFile}.mp4"'';
+
"Mod1+r" =
+
''exec mkdir -p ${shotDir} && ${wf-recorder} --audio-backend=pipewire --audio=alsa_output.pci-0000_09_00.4.pro-output-0.monitor -f "${shotFile}.mp4"'';
# record an area
"Mod1+Shift+r" =
-
''exec mkdir -p ${shotDir} && ${wf-recorder} -x yuv420p -g "$(${slurp})" -f "${shotFile}.mp4"'';
+
''exec mkdir -p ${shotDir} && ${wf-recorder} --audio-backend=pipewire --audio=alsa_output.pci-0000_09_00.4.pro-output-0.monitor -g "$(${slurp})" -f "${shotFile}.mp4"'';
# stop recording
"Mod1+c" = "exec pkill -INT wf-recorder";
"XF86AudioRaiseVolume" = "exec ${pactl} set-sink-volume 0 +5%";
+45
users/modules/swayidle/default.nix
···
+
{ pkgs, ... }:
+
{
+
services.swayidle =
+
let
+
# Lock command
+
lock = "${pkgs.swaylock}/bin/swaylock --daemonize";
+
display = status: "swaymsg 'output * power ${status}'";
+
in
+
{
+
enable = true;
+
timeouts = [
+
{
+
timeout = 60;
+
command = display "off";
+
resumeCommand = display "on";
+
}
+
{
+
timeout = 60 * 5;
+
command = lock;
+
}
+
{
+
timeout = 60 * 10;
+
command = "${pkgs.systemd}/bin/systemctl suspend";
+
}
+
];
+
events = [
+
{
+
event = "before-sleep";
+
command = (display "off") + "; " + lock;
+
}
+
{
+
event = "after-resume";
+
command = display "on";
+
}
+
{
+
event = "lock";
+
command = (display "off") + "; " + lock;
+
}
+
{
+
event = "unlock";
+
command = display "on";
+
}
+
];
+
};
+
}
+18
users/modules/tofi/default.nix
···
+
{ lib, config, ... }:
+
{
+
stylix.targets.tofi.enable = true;
+
programs.tofi = {
+
enable = true;
+
settings = {
+
outline-width = 0;
+
border-width = 0;
+
width = "48%";
+
height = "20%";
+
num-results = 7;
+
font = lib.mkForce "${config.stylix.fonts.serif.package}/share/fonts/truetype/ComicRelief.ttf";
+
hint-font = false;
+
ascii-input = true;
+
drun-launch = true;
+
};
+
};
+
}