From 39c1759d6a7dae0dd0c4236682c87fbc5822b7ef Mon Sep 17 00:00:00 2001 From: Kopatz <7265381+Kropatz@users.noreply.github.com> Date: Mon, 20 Nov 2023 08:56:54 +0100 Subject: [PATCH] configure laptop (thunderbolt, ip, sleep, wol) --- flake.nix | 10 +++++++++- modules/no-sleep-lid-closed.nix | 4 ++++ modules/rdp.nix | 8 ++++++-- {systems/server => modules}/static-ip.nix | 3 ++- modules/thunderbolt.nix | 7 +++++++ modules/wake-on-lan.nix | 2 +- systems/laptop/userdata.nix | 5 ++++- systems/server/configuration.nix | 1 - systems/server/userdata.nix | 2 ++ 9 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 modules/no-sleep-lid-closed.nix rename {systems/server => modules}/static-ip.nix (94%) create mode 100644 modules/thunderbolt.nix diff --git a/flake.nix b/flake.nix index dd362be..b35134c 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,7 @@ ({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable ]; }) ./systems/server/configuration.nix ### Modules ### + ./modules/static-ip.nix ./modules/hdd-spindown.nix ./modules/minecraft-server.nix ./modules/motd.nix @@ -83,7 +84,11 @@ ./laptop/configuration.nix ./modules/virt-manager.nix ./modules/ssh.nix - ./modules/wake-on-lan.nix + #./modules/static-ip.nix + #./modules/no-sleep-lid-closed.nix + #./modules/wake-on-lan.nix + ./modules/thunderbolt.nix + ./modules/rdp.nix nixos-hardware.nixosModules.dell-xps-15-7590-nvidia agenix.nixosModules.default home-manager.nixosModules.home-manager @@ -102,6 +107,9 @@ ./modules/virt-manager.nix ./modules/ssh.nix ./modules/wake-on-lan.nix + ./modules/static-ip.nix + ./modules/no-sleep-lid-closed.nix + ./modules/thunderbolt.nix nixos-hardware.nixosModules.dell-xps-15-7590 agenix.nixosModules.default home-manager.nixosModules.home-manager diff --git a/modules/no-sleep-lid-closed.nix b/modules/no-sleep-lid-closed.nix new file mode 100644 index 0000000..5baac73 --- /dev/null +++ b/modules/no-sleep-lid-closed.nix @@ -0,0 +1,4 @@ + +{ + services.logind.lidSwitchExternalPower = "ignore"; +} diff --git a/modules/rdp.nix b/modules/rdp.nix index fe75f13..95fbee3 100644 --- a/modules/rdp.nix +++ b/modules/rdp.nix @@ -1,5 +1,9 @@ +{ config, pkgs, lib, vars, ... }: +let + wm = vars.wm; +in { services.xrdp.enable = true; - services.xrdp.defaultWindowManager = "startplasma-x11"; + services.xrdp.defaultWindowManager = wm; services.xrdp.openFirewall = true; -} \ No newline at end of file +} diff --git a/systems/server/static-ip.nix b/modules/static-ip.nix similarity index 94% rename from systems/server/static-ip.nix rename to modules/static-ip.nix index 328f3c8..8a9f1cc 100644 --- a/systems/server/static-ip.nix +++ b/modules/static-ip.nix @@ -1,6 +1,7 @@ { config, vars, ...}: let ip = vars.ipv4; + dns = vars.dns; interface = vars.interface; in { @@ -12,7 +13,7 @@ in allowedUDPPorts = [ 5000 ]; }; nameservers = [ - "127.0.0.1" + dns "1.1.1.1" ]; interfaces = { diff --git a/modules/thunderbolt.nix b/modules/thunderbolt.nix new file mode 100644 index 0000000..4da7e02 --- /dev/null +++ b/modules/thunderbolt.nix @@ -0,0 +1,7 @@ +{ + services.udev.extraRules = '' + # Always authorize thunderbolt connections when they are plugged in. + # This is to make sure the USB hub of Thunderbolt is working. + ACTION=="add", SUBSYSTEM=="thunderbolt", ATTR{authorized}=="0", ATTR{authorized}="1" + ''; +} diff --git a/modules/wake-on-lan.nix b/modules/wake-on-lan.nix index a9d23e1..24f978c 100644 --- a/modules/wake-on-lan.nix +++ b/modules/wake-on-lan.nix @@ -3,5 +3,5 @@ let interface = vars.interface; in { - networking.interfaces.${interface}.wakeOnLan.enable; + networking.interfaces.${interface}.wakeOnLan.enable = true; } diff --git a/systems/laptop/userdata.nix b/systems/laptop/userdata.nix index 8fbd094..b07d4a5 100644 --- a/systems/laptop/userdata.nix +++ b/systems/laptop/userdata.nix @@ -1,4 +1,7 @@ { - interface = "enp0s31f6"; + interface = "enp10s0u1u2"; + ipv4 = "192.168.0.4"; + dns = "192.168.0.6"; + wm = "gnome-shell"; } diff --git a/systems/server/configuration.nix b/systems/server/configuration.nix index 523f86c..efc1fb1 100644 --- a/systems/server/configuration.nix +++ b/systems/server/configuration.nix @@ -12,7 +12,6 @@ in{ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ./static-ip.nix ]; # Bootloader. diff --git a/systems/server/userdata.nix b/systems/server/userdata.nix index 4d87e6f..6428769 100644 --- a/systems/server/userdata.nix +++ b/systems/server/userdata.nix @@ -1,5 +1,7 @@ { interface = "enp0s31f6"; ipv4 = "192.168.0.6"; + dns = "127.0.0.1"; wireguardIp = "192.168.2.1"; + wm = "startplasma-x11"; }