Move auto-cpufreq/firewall for wireguard to modules.
This commit is contained in:
parent
74c1b18ce2
commit
e3dbd06b82
@ -89,38 +89,6 @@
|
||||
# Enable zram swap device
|
||||
zramSwap.enable = true;
|
||||
|
||||
# Setup auto-cpufreq
|
||||
programs.auto-cpufreq = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
battery = {
|
||||
governor = "powersave";
|
||||
turbo = "never";
|
||||
};
|
||||
|
||||
charger = {
|
||||
governor = "performance";
|
||||
turbo = "auto";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Allow for wireguard traffic
|
||||
networking.firewall = {
|
||||
# if packets are still dropped, they will show up in dmesg
|
||||
logReversePathDrops = true;
|
||||
# wireguard trips rpfilter up
|
||||
extraCommands = ''
|
||||
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN
|
||||
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN
|
||||
'';
|
||||
extraStopCommands = ''
|
||||
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN || true
|
||||
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN || true
|
||||
'';
|
||||
};
|
||||
|
||||
# DO NOT CHANGE
|
||||
system.stateVersion = "24.11";
|
||||
}
|
||||
|
28
modules/nixos/auto-cpufreq.nix
Normal file
28
modules/nixos/auto-cpufreq.nix
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
options = {
|
||||
crony.auto-cpufreq.enable = lib.mkEnableOption "Enable auto-cpufreq and set it up for my laptop.";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.crony.auto-cpufreq.enable {
|
||||
# Setup auto-cpufreq
|
||||
programs.auto-cpufreq = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
battery = {
|
||||
governor = "powersave";
|
||||
turbo = "never";
|
||||
};
|
||||
|
||||
charger = {
|
||||
governor = "performance";
|
||||
turbo = "auto";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
@ -12,6 +12,8 @@
|
||||
./qemu.nix
|
||||
./amdgpu.nix
|
||||
./nfs-share.nix
|
||||
./auto-cpufreq.nix
|
||||
./wireguard.nix
|
||||
];
|
||||
|
||||
crony.bluetooth.enable = lib.mkDefault true;
|
||||
@ -26,4 +28,6 @@
|
||||
crony.qemu.enable = lib.mkDefault true;
|
||||
crony.amdgpu.enable = lib.mkDefault true;
|
||||
crony.nfs-share.enable = lib.mkDefault true;
|
||||
crony.auto-cpufreq.enable = lib.mkDefault true;
|
||||
crony.wireguard.enable = lib.mkDefault true;
|
||||
}
|
||||
|
26
modules/nixos/wireguard.nix
Normal file
26
modules/nixos/wireguard.nix
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
options = {
|
||||
crony.wireguard.enable = lib.mkEnableOption "Open ports in firewall for wireguard to work.";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.crony.wireguard.enable {
|
||||
# Allow for wireguard traffic
|
||||
networking.firewall = {
|
||||
# if packets are still dropped, they will show up in dmesg
|
||||
logReversePathDrops = true;
|
||||
# wireguard trips rpfilter up
|
||||
extraCommands = ''
|
||||
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN
|
||||
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN
|
||||
'';
|
||||
extraStopCommands = ''
|
||||
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN || true
|
||||
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN || true
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user