mass reformat

This commit is contained in:
notgne2 2022-10-03 17:08:32 -07:00
parent ed1c53e94c
commit 9cb456ad60
No known key found for this signature in database
GPG key ID: 5CE0A245A2DAC84A
25 changed files with 1216 additions and 1043 deletions

View file

@ -1,6 +1,11 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.de2;
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.de2;
in {
options.de2.enable = mkEnableOption "Enable de2 system stuff";
@ -13,7 +18,7 @@ in {
i18n.inputMethod = {
enabled = "ibus";
ibus.engines = with pkgs.ibus-engines; [ typing-booster uniemoji ];
ibus.engines = with pkgs.ibus-engines; [typing-booster uniemoji];
};
services.xserver = {
@ -26,13 +31,17 @@ in {
services.power-profiles-daemon.enable = lib.mkDefault false;
# for KDE connect
networking.firewall.allowedTCPPortRanges = [{
from = 1714;
to = 1764;
}];
networking.firewall.allowedUDPPortRanges = [{
from = 1714;
to = 1764;
}];
networking.firewall.allowedTCPPortRanges = [
{
from = 1714;
to = 1764;
}
];
networking.firewall.allowedUDPPortRanges = [
{
from = 1714;
to = 1764;
}
];
};
}

View file

@ -1,13 +1,18 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.de3;
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.de3;
in {
options.de3.enable = mkEnableOption "Enable de3 system stuff";
config = mkIf cfg.enable {
i18n.inputMethod = {
enabled = "ibus";
ibus.engines = with pkgs.ibus-engines; [ typing-booster uniemoji ];
ibus.engines = with pkgs.ibus-engines; [typing-booster uniemoji];
};
xdg.portal.enable = lib.mkDefault true;
@ -27,13 +32,17 @@ in {
services.power-profiles-daemon.enable = lib.mkDefault false;
# for KDE connect
networking.firewall.allowedTCPPortRanges = [{
from = 1714;
to = 1764;
}];
networking.firewall.allowedUDPPortRanges = [{
from = 1714;
to = 1764;
}];
networking.firewall.allowedTCPPortRanges = [
{
from = 1714;
to = 1764;
}
];
networking.firewall.allowedUDPPortRanges = [
{
from = 1714;
to = 1764;
}
];
};
}

View file

@ -1,6 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}: {
imports = [
./ezwg.nix
./kiosk.nix

View file

@ -1,9 +1,15 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.ezpassthru;
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.ezpassthru;
in {
options.services.ezpassthru = {
enable = mkEnableOption
enable =
mkEnableOption
"Enable simple VM PCI passthrough config (NOTE: this is only for ppl with a primary AMD/Intel, and a non-primary NVidia)";
PCIs = mkOption {
@ -26,11 +32,11 @@ in {
"vfio"
];
boot.kernelParams = [ "intel_iommu=on" "amd_iommu=on" "pcie_aspm=off" ];
boot.kernelParams = ["intel_iommu=on" "amd_iommu=on" "pcie_aspm=off"];
boot.extraModprobeConfig = "options vfio-pci ids=${
builtins.concatStringsSep "," (builtins.attrNames cfg.PCIs)
}";
builtins.concatStringsSep "," (builtins.attrNames cfg.PCIs)
}";
boot.postBootCommands = ''
DEVS="${builtins.concatStringsSep " " (builtins.attrValues cfg.PCIs)}"

View file

@ -1,6 +1,11 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.ezpw;
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.ezpw;
in {
options.services.ezpw = {
enable = mkEnableOption "Enable pipewire";
@ -13,8 +18,7 @@ in {
usbSoundcard = mkOption {
type = types.bool;
description =
"Doubles the audio rate for alsa outputs in low latency mode";
description = "Doubles the audio rate for alsa outputs in low latency mode";
default = false;
};
@ -38,9 +42,10 @@ in {
};
};
config =
let qr = "${toString cfg.quantum}/${toString cfg.rate}";
in mkIf cfg.enable {
config = let
qr = "${toString cfg.quantum}/${toString cfg.rate}";
in
mkIf cfg.enable {
hardware.pulseaudio.enable = lib.mkDefault false;
sound.enable = lib.mkDefault false;
@ -71,26 +76,26 @@ in {
"rt.time.soft" = 200000;
"rt.time.hard" = 200000;
};
flags = [ "ifexists" "nofail" ];
flags = ["ifexists" "nofail"];
}
{ name = "libpipewire-module-protocol-native"; }
{ name = "libpipewire-module-profiler"; }
{ name = "libpipewire-module-metadata"; }
{ name = "libpipewire-module-spa-device-factory"; }
{ name = "libpipewire-module-spa-node-factory"; }
{ name = "libpipewire-module-client-node"; }
{ name = "libpipewire-module-client-device"; }
{name = "libpipewire-module-protocol-native";}
{name = "libpipewire-module-profiler";}
{name = "libpipewire-module-metadata";}
{name = "libpipewire-module-spa-device-factory";}
{name = "libpipewire-module-spa-node-factory";}
{name = "libpipewire-module-client-node";}
{name = "libpipewire-module-client-device";}
{
name = "libpipewire-module-portal";
flags = [ "ifexists" "nofail" ];
flags = ["ifexists" "nofail"];
}
{
name = "libpipewire-module-access";
args = { };
args = {};
}
{ name = "libpipewire-module-adapter"; }
{ name = "libpipewire-module-link-factory"; }
{ name = "libpipewire-module-session-manager"; }
{name = "libpipewire-module-adapter";}
{name = "libpipewire-module-link-factory";}
{name = "libpipewire-module-session-manager";}
];
};
@ -104,19 +109,19 @@ in {
"rt.time.soft" = 200000;
"rt.time.hard" = 200000;
};
flags = [ "ifexists" "nofail" ];
flags = ["ifexists" "nofail"];
}
{ name = "libpipewire-module-protocol-native"; }
{ name = "libpipewire-module-client-node"; }
{ name = "libpipewire-module-adapter"; }
{ name = "libpipewire-module-metadata"; }
{name = "libpipewire-module-protocol-native";}
{name = "libpipewire-module-client-node";}
{name = "libpipewire-module-adapter";}
{name = "libpipewire-module-metadata";}
{
name = "libpipewire-module-protocol-pulse";
args = {
"pulse.min.req" = qr;
"pulse.default.req" = qr;
"pulse.min.quantum" = qr;
"server.address" = [ "unix:native" ];
"server.address" = ["unix:native"];
};
}
];
@ -129,65 +134,75 @@ in {
};
media-session.config.alsa-monitor = mkIf cfg.lowLatency {
rules = [{
matches = [{ node.name = "alsa_output.*"; }];
actions = {
update-props = {
"audio.format" = "S32LE";
"audio.rate" = cfg.rate * (if cfg.usbSoundcard then 2 else 1);
"api.alsa.period-size" = cfg.periodSize;
rules = [
{
matches = [{node.name = "alsa_output.*";}];
actions = {
update-props = {
"audio.format" = "S32LE";
"audio.rate" =
cfg.rate
* (
if cfg.usbSoundcard
then 2
else 1
);
"api.alsa.period-size" = cfg.periodSize;
};
};
};
}];
}
];
};
media-session.config.bluez-monitor = {
properties = {
"bluez5.codecs" = [ "sbc" "aac" "ldac" "aptx" "aptx_hd" ];
"bluez5.codecs" = ["sbc" "aac" "ldac" "aptx" "aptx_hd"];
"bluez5.mdbc-support" = true;
};
rules = [
{
actions = {
update-props = {
"bluez5.auto-connect" = [ "hsp_hs" "hfp_hf" "a2dp_sink" ];
"bluez5.hw-volume" =
[ "hsp_ag" "hfp_ag" "a2dp_source" "a2dp_sink" ];
"bluez5.auto-connect" = ["hsp_hs" "hfp_hf" "a2dp_sink"];
"bluez5.hw-volume" = ["hsp_ag" "hfp_ag" "a2dp_source" "a2dp_sink"];
"bluez5.autoswitch-profile" = true;
};
};
matches = [{ "device.name" = "~bluez_card.*"; }];
matches = [{"device.name" = "~bluez_card.*";}];
}
{
actions = { update-props = { "node.pause-on-idle" = false; }; };
actions = {update-props = {"node.pause-on-idle" = false;};};
matches = [
{ "node.name" = "~bluez_input.*"; }
{ "node.name" = "~bluez_output.*"; }
{"node.name" = "~bluez_input.*";}
{"node.name" = "~bluez_output.*";}
];
}
];
};
};
environment.systemPackages = with pkgs;
[
# pactl is required for pipewire-pulse
pulseaudio
];
environment.systemPackages = with pkgs; [
# pactl is required for pipewire-pulse
pulseaudio
];
environment.etc."wireplumber/main.lua.d/51-alsa-config.lua" =
mkIf cfg.lowLatency {
text = ''
alsa_monitor.properties = {
["audio.rate"] = ${
toString (cfg.rate * (if cfg.usbSoundcard then 2 else 1))
},
["audio.format"] = "S32LE",
["api.alsa.headroom"] = 512,
["api.alsa.period-size"] = ${toString cfg.periodSize}
}
'';
};
environment.etc."wireplumber/main.lua.d/51-alsa-config.lua" = mkIf cfg.lowLatency {
text = ''
alsa_monitor.properties = {
["audio.rate"] = ${
toString (cfg.rate
* (
if cfg.usbSoundcard
then 2
else 1
))
},
["audio.format"] = "S32LE",
["api.alsa.headroom"] = 512,
["api.alsa.period-size"] = ${toString cfg.periodSize}
}
'';
};
environment.etc."wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = ''
bluez_monitor.properties = {

View file

@ -1,9 +1,13 @@
{ config, lib, pkgs, ... }:
with lib;
let
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.ezwg;
peerNameReplacement = lib.replaceChars [ "/" "-" " " "+" "=" ] [
peerNameReplacement = lib.replaceChars ["/" "-" " " "+" "="] [
"-"
"\\x2d"
"\\x20"
@ -11,35 +15,31 @@ let
"\\x3d"
];
ranges = serverIPs:
let
generateRangesScript =
builtins.toFile "exclusionary-wildcard-ranges-generator.py" ''
import ipaddress
serverNetworks = [${map (ip: "ip_network('${ip}/32')") serverIPs}]
ranges = [ipaddress.ip_network('0.0.0.0/0')]
for serverNetwork in serverNetworks:
ranges = map(lambda r: list(r.address_exclude(serverNetwork)), ranges)
print(':'.join(ranges))
'';
rangesOutput = pkgs.runCommand "exclusionary-wildcard-ranges" { } ''
${pkgs.python3}/bin/python3 ${generateRangesScript} > $out
'';
in
ranges = serverIPs: let
generateRangesScript = builtins.toFile "exclusionary-wildcard-ranges-generator.py" ''
import ipaddress
serverNetworks = [${map (ip: "ip_network('${ip}/32')") serverIPs}]
ranges = [ipaddress.ip_network('0.0.0.0/0')]
for serverNetwork in serverNetworks:
ranges = map(lambda r: list(r.address_exclude(serverNetwork)), ranges)
print(':'.join(ranges))
'';
rangesOutput = pkgs.runCommand "exclusionary-wildcard-ranges" {} ''
${pkgs.python3}/bin/python3 ${generateRangesScript} > $out
'';
in
lib.splitString ":" (builtins.readFile "${rangesOutput}");
subnet = vlanIP: vlanSize:
let
generateSubnetScript =
builtins.toFile "subnet-without-host-bits-generator.py" ''
import ipaddress
n1 = ipaddress.ip_network('${vlanIP}/${toString vlanSize}', False)
print(n1, end="")
'';
subnetOutput = pkgs.runCommand "subnet-without-host-bits" { } ''
${pkgs.python3}/bin/python3 ${generateSubnetScript} > $out
'';
in
subnet = vlanIP: vlanSize: let
generateSubnetScript = builtins.toFile "subnet-without-host-bits-generator.py" ''
import ipaddress
n1 = ipaddress.ip_network('${vlanIP}/${toString vlanSize}', False)
print(n1, end="")
'';
subnetOutput = pkgs.runCommand "subnet-without-host-bits" {} ''
${pkgs.python3}/bin/python3 ${generateSubnetScript} > $out
'';
in
builtins.readFile "${subnetOutput}";
serverOpts.options = {
@ -61,7 +61,7 @@ let
instanceOpts.options = {
servers = mkOption {
description = "Configuration of servers to connect to";
default = { };
default = {};
type = with types; listOf (submodule serverOpts);
};
autoStart = mkOption {
@ -88,13 +88,12 @@ let
description = "The IP to use on the wg VLAN";
};
};
in
{
in {
options.services.ezwg = {
enable = mkEnableOption "Enable simple Wireguard connection";
instances = mkOption {
description = "Configuration of instances of Wireguard";
default = { };
default = {};
type = with types; attrsOf (submodule instanceOpts);
};
};
@ -102,49 +101,59 @@ in
config = mkIf cfg.enable {
networking.firewall.checkReversePath = false;
systemd.paths = mapAttrs'
systemd.paths =
mapAttrs'
(instName: inst: {
name = "wireguard-${instName}";
value = if inst.autoStart then { } else { wantedBy = mkForce [ ]; };
value =
if inst.autoStart
then {}
else {wantedBy = mkForce [];};
})
cfg.instances;
systemd.services = lib.listToAttrs (flatten (mapAttrsToList
(instName: inst:
[{
name = "wireguard-${instName}";
value = if inst.autoStart then { } else { wantedBy = mkForce [ ]; };
}] ++ map
(server: {
name =
"wireguard-${instName}-peer${peerNameReplacement server.publicKey}";
value = if inst.autoStart then { } else { wantedBy = mkForce [ ]; };
})
inst.servers)
[
{
name = "wireguard-${instName}";
value =
if inst.autoStart
then {}
else {wantedBy = mkForce [];};
}
]
++ map
(server: {
name = "wireguard-${instName}-peer${peerNameReplacement server.publicKey}";
value =
if inst.autoStart
then {}
else {wantedBy = mkForce [];};
})
inst.servers)
cfg.instances));
networking.wireguard.interfaces = mapAttrs
(instName: inst:
let
allowedIPs =
if inst.proxy then
ranges (map (s: s.ip) inst.servers)
else
[ (subnet inst.vlanIP inst.vlanSize) ];
in
{
ips = [ "${inst.vlanIP}/${toString inst.vlanSize}" ];
privateKeyFile = inst.privateKeyFile;
peers = map
(server: {
inherit allowedIPs;
publicKey = server.publicKey;
endpoint = "${server.ip}:${toString server.port}";
persistentKeepalive = 25;
})
inst.servers;
})
networking.wireguard.interfaces =
mapAttrs
(instName: inst: let
allowedIPs =
if inst.proxy
then ranges (map (s: s.ip) inst.servers)
else [(subnet inst.vlanIP inst.vlanSize)];
in {
ips = ["${inst.vlanIP}/${toString inst.vlanSize}"];
privateKeyFile = inst.privateKeyFile;
peers =
map
(server: {
inherit allowedIPs;
publicKey = server.publicKey;
endpoint = "${server.ip}:${toString server.port}";
persistentKeepalive = 25;
})
inst.servers;
})
cfg.instances;
};
}

View file

@ -1,17 +1,23 @@
{ config, lib, pkgs, ... }:
with lib;
let
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.fuckingprint;
fixPlatforms = p:
p.overrideAttrs (super:
super // {
meta = super.meta // {
platforms = super.meta.platforms ++ [ "x86_64-linux" ];
};
super
// {
meta =
super.meta
// {
platforms = super.meta.platforms ++ ["x86_64-linux"];
};
});
in
{
in {
options.fuckingprint.enable = mkEnableOption "Make my fucking printer work";
config = mkIf cfg.enable {
@ -101,6 +107,6 @@ in
hplipWithPlugin
];
};
services.udev.packages = [ pkgs.utsushi ];
services.udev.packages = [pkgs.utsushi];
};
}

View file

@ -1,6 +1,11 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.kiosk;
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.kiosk;
in {
options.services.kiosk = {
enable = mkEnableOption "Enable simple kiosk display";
@ -60,21 +65,26 @@ in {
};
};
displayManager.xserverArgs = if cfg.cursor then [ ] else [ "-nocursor" ];
displayManager.xserverArgs =
if cfg.cursor
then []
else ["-nocursor"];
displayManager.defaultSession = "kiosk+ratpoison";
desktopManager.session = [{
name = "kiosk";
start = ''
# dont blank the screen after 5min
xset dpms force on
xset -dpms
xset s noblank
xset s off
desktopManager.session = [
{
name = "kiosk";
start = ''
# dont blank the screen after 5min
xset dpms force on
xset -dpms
xset s noblank
xset s off
${cfg.session}
'';
}];
${cfg.session}
'';
}
];
};
};
}

View file

@ -1,6 +1,11 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.workstation;
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.workstation;
in {
options.workstation = {
enable = mkEnableOption "make my computer work";
@ -105,7 +110,7 @@ in {
# Optimizes running games
programs.gamemode = {
enable = lib.mkDefault true;
settings = { general.renice = 10; };
settings = {general.renice = 10;};
};
# Allows realtime stuff, useful for games, audio etc
@ -175,14 +180,18 @@ in {
"lp"
];
subUidRanges = [{
startUid = 100000;
count = 65536;
}];
subGidRanges = [{
startGid = 100000;
count = 65536;
}];
subUidRanges = [
{
startUid = 100000;
count = 65536;
}
];
subGidRanges = [
{
startGid = 100000;
count = 65536;
}
];
};
# brightness
@ -258,7 +267,7 @@ in {
# Shit breaks without this lol
programs.dconf.enable = lib.mkDefault true;
services.dbus.packages = with pkgs; [ dconf ];
services.dbus.packages = with pkgs; [dconf];
boot.kernel.sysctl = {
# better default swap