Make network settings more reproducible
This commit is contained in:
parent
ed238dd127
commit
ccff876b9d
@ -6,6 +6,8 @@ in {
|
|||||||
networking.hostName = "local";
|
networking.hostName = "local";
|
||||||
networking.nameservers = [ "1.1.1.1" ];
|
networking.nameservers = [ "1.1.1.1" ];
|
||||||
|
|
||||||
|
networking.usePredictableInterfaceNames = false;
|
||||||
|
|
||||||
networking.wireless.enable = true;
|
networking.wireless.enable = true;
|
||||||
imports = [ ./wireless-networks.nix ];
|
imports = [ ./wireless-networks.nix ];
|
||||||
|
|
||||||
@ -59,29 +61,31 @@ in {
|
|||||||
|
|
||||||
systemd = {
|
systemd = {
|
||||||
services = {
|
services = {
|
||||||
"macchanger" = {
|
"macchanger-wlan0" = {
|
||||||
description = "Changes MAC of all interfaces for privacy reasons";
|
description = "Changes MAC of wlan0 for privacy reasons";
|
||||||
wants = [ "network-pre.target" ];
|
wants = [ "network-pre.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
before = [ "network-pre.target" ];
|
before = [ "network-pre.target" ];
|
||||||
bindsTo = [ "sys-subsystem-net-devices-wlp0s20f3.device" ];
|
bindsTo = [ "sys-subsystem-net-devices-wlan0.device" ];
|
||||||
after = [ "sys-subsystem-net-devices-wlp0s20f3.device" ];
|
after = [ "sys-subsystem-net-devices-wlan0.device" ];
|
||||||
# we always return true to avoid errors while 'nixos-rebuild switch'
|
script = "${pkgs.macchanger}/bin/macchanger -e wlan0 || true";
|
||||||
# because it does not stop interfaces
|
serviceConfig.Type = "oneshot";
|
||||||
# TODO it must be changed to work only when system starts
|
};
|
||||||
script = ''
|
"macchanger-eth0" = {
|
||||||
${pkgs.macchanger}/bin/macchanger -e wlp0s20f3 || true
|
description = "Changes MAC of eth0 for privacy reasons";
|
||||||
${pkgs.macchanger}/bin/macchanger -e enp0s31f6 || true
|
wants = [ "network-pre.target" ];
|
||||||
'';
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
before = [ "network-pre.target" ];
|
||||||
|
bindsTo = [ "sys-subsystem-net-devices-eth0.device" ];
|
||||||
|
after = [ "sys-subsystem-net-devices-eth0.device" ];
|
||||||
|
script = "${pkgs.macchanger}/bin/macchanger -e eth0 || true";
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig.Type = "oneshot";
|
||||||
};
|
};
|
||||||
"openvpn-restart-after-suspend" = {
|
"openvpn-restart-after-suspend" = {
|
||||||
description = "Restart OpenVPN after suspend";
|
description = "Restart OpenVPN after suspend";
|
||||||
after = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ];
|
after = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ];
|
||||||
wantedBy = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ];
|
wantedBy = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ];
|
||||||
script = ''
|
script = "${pkgs.systemd}/bin/systemctl try-restart openvpn-vpn.service";
|
||||||
${pkgs.systemd}/bin/systemctl try-restart openvpn-vpn.service
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user