From 619b2dd88840ee21ce578646b3b1c8cbd10b1e58 Mon Sep 17 00:00:00 2001 From: Jonas Hahn Date: Thu, 18 Sep 2025 12:39:26 +0200 Subject: [PATCH] Changed layouts --- .sops.yaml | 5 +++ hosts/thinix-thinkpad/configuration.nix | 4 +- modules/essential.nix | 8 +--- modules/graphics/workstation.nix | 6 --- modules/hardware/boot.nix | 37 ++++++++-------- modules/hardware/nvidia.nix | 58 +++++++++++++++--------- modules/laptop/battery.nix | 59 ++++++++----------------- modules/services/printing.nix | 5 +++ modules/services/webdav.nix | 7 ++- secrets.yaml | 35 +++++++++------ user/packages.nix | 8 ---- 11 files changed, 112 insertions(+), 120 deletions(-) create mode 100644 modules/services/printing.nix diff --git a/.sops.yaml b/.sops.yaml index 6e0f693..122d76b 100644 --- a/.sops.yaml +++ b/.sops.yaml @@ -4,11 +4,15 @@ # Get the public host key with # nix-shell -p ssh-to-age --run 'cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age' +# Then run +# sops updatekeys secrets.yaml + # The user key should be in ~/.config/sops/age/keys.txt keys: - &jonas age1a2kpues0gayampkn9pn2czhk24r0yl4jnw84qg4gh5l72dflx95qkmyqzv - &minoxy age1qddfn6apphafe4muvvv3vguxewa03ay2jlgqkng3uwwzfjw204dsfpt0uu + - &thinix age1hvnmhkqgmxkgatw74se0vql6glxjtmdcv6zt52yuycpaavd4fulqfhx68a creation_rules: - path_regex: secrets.yaml @@ -16,4 +20,5 @@ creation_rules: - age: - *jonas - *minoxy + - *thinix diff --git a/hosts/thinix-thinkpad/configuration.nix b/hosts/thinix-thinkpad/configuration.nix index 450e533..c20dd2d 100644 --- a/hosts/thinix-thinkpad/configuration.nix +++ b/hosts/thinix-thinkpad/configuration.nix @@ -17,8 +17,8 @@ ./../../modules/laptop/powersave.nix ./../../modules/laptop/battery.nix - ./../../modules/services/webdav.nix.nix - ./../../modules/services/scanning.nix.nix + ./../../modules/services/webdav.nix + ./../../modules/services/scanning.nix ]; networking.hostName = "thinix"; diff --git a/modules/essential.nix b/modules/essential.nix index 75ab9a1..f1d0806 100644 --- a/modules/essential.nix +++ b/modules/essential.nix @@ -8,9 +8,9 @@ # Nix fun nixpkgs.config.allowUnfree = true; nix.settings.experimental-features = ["flakes" "nix-command"]; - time.timeZone = "Europe/Berlin"; - programs.nix-ld.enable = true; + time.timeZone = "Europe/Berlin"; + programs.nix-ld.enable = true; # Linking support environment = { systemPackages = with pkgs; [ @@ -19,9 +19,6 @@ zoxide rsync ]; - pathsToLink = [ - "/share/icons" - ]; }; networking = { @@ -45,7 +42,6 @@ "history-substring-search" "git" "zoxide" - "sudo" "vi-mode" "systemadmin" ]; diff --git a/modules/graphics/workstation.nix b/modules/graphics/workstation.nix index 190015c..abd486a 100644 --- a/modules/graphics/workstation.nix +++ b/modules/graphics/workstation.nix @@ -1,16 +1,10 @@ { pkgs, ... }: { - # Basic services - services.printing.enable = true; - environment = { sessionVariables = { NIXOS_OZONE_WL = "1"; - LD_LIBRARY_PATH = "${pkgs.libclang.lib}/lib"; - QTWEBENGINE_CHROMIUM_FLAGS="--blink-settings=darkModeEnabled=true"; QT_QPA_PLATFORMTHEME = "qt6ct"; - WLR_NO_HARDWARE_CURSORS= "1"; QT_STYLE_OVERRIDE = "kvantum"; QT_QPA_PLATFORM="xcb"; }; diff --git a/modules/hardware/boot.nix b/modules/hardware/boot.nix index 89787cb..c2c108d 100644 --- a/modules/hardware/boot.nix +++ b/modules/hardware/boot.nix @@ -1,26 +1,25 @@ { config, lib, ... }: -let - inherit (lib) mkOption types; +let inherit (lib) mkOption types; in { - options.bootMode = mkOption { - type = types.enum [ "uefi" "legacy" ]; - default = "uefi"; - }; + options.bootMode = mkOption { + type = types.enum [ "uefi" "legacy" ]; + default = "uefi"; + }; - config = { - boot.consoleLogLevel = 0; - boot.kernelParams = [ "quiet" "udev.log_level=3" ]; + config = { + boot.consoleLogLevel = 0; + boot.kernelParams = [ "quiet" "udev.log_level=3" ]; - boot.loader = if config.bootMode == "uefi" then { - efi.canTouchEfiVariables = true; - systemd-boot.enable = true; - timeout = 0; - } else { - grub.enable = true; - grub.device = "/dev/sda"; - timeout = 0; - }; - }; + boot.loader = { + timeout = 0; + } // (if config.bootMode == "uefi" then { + efi.canTouchEfiVariables = true; + systemd-boot.enable = true; + } else { + grub.enable = true; + grub.device = "/dev/sda"; + }); + }; } diff --git a/modules/hardware/nvidia.nix b/modules/hardware/nvidia.nix index 29ed959..bf5e7f8 100644 --- a/modules/hardware/nvidia.nix +++ b/modules/hardware/nvidia.nix @@ -1,26 +1,42 @@ -{ config, ... }: +{ config, lib, pkgs, ... }: -{ - hardware.graphics = { enable = true; }; - - services.xserver.videoDrivers = [ "nvidia" ]; - - hardware.nvidia = { - modesetting.enable = true; - powerManagement.enable = false; - open = false; - nvidiaSettings = true; - package = config.boot.kernelPackages.nvidiaPackages.stable; +let inherit (lib) mkOption types; +in { + options = { + enableCuda = mkOption { + type = types.bool; + default = false; + description = '' + Enable CUDA support for Blender and other packages. + Warning: This can cause very long build times. + ''; + }; + nvidiaOpen = mkOption { + type = types.bool; + default = false; + }; }; - # Cuda for blender long build times - #environment.systemPackages = with pkgs; [ - # (blender.override { - # cudaSupport = true; - # }) - #]; + config = { + hardware.graphics.enable = true; - # This causes very long build times - #nixpkgs.config.cudaSupport = true; - #hardware.enableAllFirmware = true; + services.xserver.videoDrivers = [ "nvidia" ]; + + hardware.nvidia = { + modesetting.enable = true; + powerManagement.enable = false; + open = config.nvidiaOpen; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + + # Apply CUDA-specific settings if enabled + nixpkgs.config.cudaSupport = config.enableCuda; + hardware.enableAllFirmware = config.enableCuda; + + environment.systemPackages = (if config.enableCuda then + [ (pkgs.blender.override { cudaSupport = true; }) ] + else + [ ]); + }; } diff --git a/modules/laptop/battery.nix b/modules/laptop/battery.nix index 2af4623..95e294c 100644 --- a/modules/laptop/battery.nix +++ b/modules/laptop/battery.nix @@ -1,8 +1,19 @@ { config, lib, ... }: -let inherit (lib) mkOption types; -in { +let + inherit (lib) mkOption types; + singleBat = { + START_CHARGE_THRESH_BAT0 = 65; + STOP_CHARGE_THRESH_BAT0 = 85; + }; + + doubleBat = singleBat // { + START_CHARGE_THRESH_BAT1 = 65; + STOP_CHARGE_THRESH_BAT1 = 85; + }; + +in { options.batMode = mkOption { type = types.enum [ "single" "double" ]; default = "single"; @@ -10,56 +21,22 @@ in { config = { powerManagement.powertop.enable = true; + services.upower = { enable = true; - # In accordance with the waybar battery colors + # In accordance with waybar battery colors percentageLow = 30; percentageCritical = 20; - percentageAction = 10; + percentageAction = 15; criticalPowerAction = "PowerOff"; # This can destroy work usePercentageForPolicy = true; }; - services.tlp = if config.batMode == "single" then { + services.tlp = { enable = true; - settings = { - START_CHARGE_THRESH_BAT0 = 65; - STOP_CHARGE_THRESH_BAT0 = 85; - - CPU_SCALING_GOVERNOR_ON_AC = "performance"; - CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; - - CPU_MIN_PERF_ON_AC = 0; - CPU_MAX_PERF_ON_AC = 100; - CPU_MIN_PERF_ON_BAT = 0; - CPU_MAX_PERF_ON_BAT = 65; - }; - } else { - enable = true; - settings = { - CPU_SCALING_GOVERNOR_ON_AC = "performance"; - CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; - - CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; - CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; - - CPU_MIN_PERF_ON_AC = 0; - CPU_MAX_PERF_ON_AC = 100; - CPU_MIN_PERF_ON_BAT = 0; - CPU_MAX_PERF_ON_BAT = 75; - - # 0 is first - START_CHARGE_THRESH_BAT0 = 60; - STOP_CHARGE_THRESH_BAT0 = 85; - - # 1 is second - START_CHARGE_THRESH_BAT1 = 60; - STOP_CHARGE_THRESH_BAT1 = 85; - }; + settings = if config.batMode == "single" then singleBat else doubleBat; }; - }; } - diff --git a/modules/services/printing.nix b/modules/services/printing.nix new file mode 100644 index 0000000..4610bde --- /dev/null +++ b/modules/services/printing.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + services.printing.enable = true; +} diff --git a/modules/services/webdav.nix b/modules/services/webdav.nix index ee7ce93..6f7d34f 100644 --- a/modules/services/webdav.nix +++ b/modules/services/webdav.nix @@ -19,16 +19,15 @@ after = [ "network-online.target" ]; wants = [ "network-online.target" ]; what = "https://dav.hahn1.one"; - where = "/home/jonas/webdav"; + where = "/webdav"; type = "davfs"; - options = "uid=1000,gid=1000,file_mode=0664,dir_mode=2775,_netdev"; # What is netdev? + options = "uid=1000,gid=1000,file_mode=0664,dir_mode=2775,_netdev"; mountConfig.TimeoutSec = "5s"; }]; - # Is this too much power drain? systemd.automounts = [{ description = "Webdav automount"; - where = "/home/jonas/webdav"; + where = "/webdav"; wantedBy = [ "multi-user.target" ]; automountConfig = { TimeoutIdleSec = "2m"; }; }]; diff --git a/secrets.yaml b/secrets.yaml index 4e7a623..ebe263e 100644 --- a/secrets.yaml +++ b/secrets.yaml @@ -1,25 +1,34 @@ -webdav_authstring: ENC[AES256_GCM,data:9Q9hEgwNjKs75/5KDok4DGQZ7EAJakcFYLLjehmVDzgdXJyv8D52oQ==,iv:dWGWgZXyw49zJqIbPdy4zpGzGk5H/m47DV08NB1w9go=,tag:PAVUDk8+6ZXlD8o8MHyD3Q==,type:str] +webdav_authstring: ENC[AES256_GCM,data:owtYoEX4uXHZFJa1TL2uxkCHatU8MiDT0a+a6NDt7+IVGwB4XsY=,iv:15Ms6v3rPujQxKs0hZULvZGX3K7TgmV1zrLLt3kQGPI=,tag:ULyWmrgoBmVLEdOc/4sMMw==,type:str] sops: age: - recipient: age1a2kpues0gayampkn9pn2czhk24r0yl4jnw84qg4gh5l72dflx95qkmyqzv enc: | -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBGV1BLWnpIWlVCMHRLRFJR - UXhBOGFNN2ZMd1JNVGhyOU12b1JaajNBYUh3CkZFNzR6NElhYldQbmtTTlpIK0sx - UUVZb3BqYWEwQUxiTklKeGJFYmxUaWcKLS0tIDExc1lqV3BITzA3ME9jM3FWU09V - Q2p1UHVBNW54UnIydU5yM25OK0llRkUKnr2SftBM+rBFfakhoHL1UyVm9BIgmW05 - ARXyD4DR2MF5pPRnE6s1avfocX4IObB0xNHeuOegXUYhKWlSkTztNw== + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBGSWc2SjdBNnRNbVZHVENE + ZXBCTWtqcXphdDdUU3lyYkxDYVlRVmtwYmtNClE5RnN1NGFNY1QxVmRjLzFTem5n + MHFVM3NFRUZzMTlDRjB2NVljRVcrbUkKLS0tIGZKQk1qZFJxS2t3VVhxekxyWEZO + NFc5MXFsNUFOS0RhRTZpaDUrblVOaHMKHyGT/1ZriydmzaifcQBhU82fa4vazxLG + vb3xBF9cTylbkqxgf3xjMv/44Gq/PQz5mFceWxCVIaU7MpKafX7HMg== -----END AGE ENCRYPTED FILE----- - recipient: age1qddfn6apphafe4muvvv3vguxewa03ay2jlgqkng3uwwzfjw204dsfpt0uu enc: | -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBhQUlLNm5wdHc1Q3VFZFZQ - eEN2VzkycStHQUlMK1MrdElrYTFJN0VCUFgwCjlsT1BpZVNWdzBmeDdSbXpTbEtB - MEhXVTJ1czRSLzdXQ0l2bzlLMU53ak0KLS0tIG5yUHVQSDk3eTJTenBDNXhGYXk2 - SnM5V2VDMmxiRExqeFZrcm01ME5FRlUKCq047F8LGPCAdcpLBr66O4FVAt9q7Ug6 - o5Dpn6Mo5c08tdF2m88Q1fXMSXIpfdTJCffIjk82WiU4M3Ni/8Mmaw== + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBFNmpsajNYT1VmUjlJRFdX + VkI4WVJCRW03M1dtNEpSaThvWnpWTjN1cnlrCnFTTC9FWTVxdUxKSnA5aTUvUDBy + SnRqSHh1aTNRSGs4Qlk1STZCbFc3ZjQKLS0tIHpXdE9xMjB3d3pXbE5zR0hGeENP + NmkzN0xBVkh4MDdRVGdLZk9ZUEVtYlkK6w4PBviii/sivrsk1dvgJ516zwG7T76G + I7e9f/IZ3OwxAF0KCjoOKbrHMwb9ZJhEy+DxXObK1XMJ4XcL11qDww== -----END AGE ENCRYPTED FILE----- - lastmodified: "2025-08-31T20:35:46Z" - mac: ENC[AES256_GCM,data:trZFOIIrxWXpj5+qL1fWGYWBKlnkU+SSqra+k1S7NW3LtSsmx1ZW/qRCSoiFIJeP+jWEQ32S95d53Kt2Fw0hta+7r/rMc9MOwmy4U/ML66p0bj7A57QZQ1sbi3fkEbCSRU3G0es215I8Db7zeyBXBSfqoukBekcs3GsESBDVhkQ=,iv:Z2CNOzLWB/DRPoekiwroU4aftEhm2hYzXx9Vzmz7EA0=,tag:0PsB6B2RHu6l0EZlaYkqKA==,type:str] + - recipient: age1hvnmhkqgmxkgatw74se0vql6glxjtmdcv6zt52yuycpaavd4fulqfhx68a + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA4WTdjZGZWM3owMGJTSXVG + NFF2eWo1VjdyNmlxVmxwQzJoVng5Zy9tbXlnCjRuakpCZGJhbXFMbndsMUJ4cVd3 + VEQxa01BcWRybHZOQTJNYk1LUnNpRjAKLS0tIEpnSnVpL3BvZ2dLZkVVUlVsU2R4 + MnlqbzM4TjhDMTBNSytpNDFqUWg2cDAKVsyC8b4u3ibxri4m8U3f45+/UqhP2zEX + 38jRSeEoI2QV97bk0J5in9tHYEIdkOErANgaw+da3JzLMAGN+F41dQ== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2025-09-02T17:49:36Z" + mac: ENC[AES256_GCM,data:wK7vtEBXE5/u+xqiiwa52ZnRouyAMG7x+T8xdoqb/NFEGIr6SPZRFxLVuKZN9iCbDyMCxb03GuKibcPbiIDkfvvKTpASP5t5F3yLwr1vS6/x6VM+rBJvppOu5s91rxGotkKjXBlnQM3pSKApLfbGEEu+jwFOA/I0UchD4VSjbq4=,iv:BskOSBnjcqp8hlGxe0RDDZipv0t9cDCLWwI/v7FiadQ=,tag:RiZ7rh45quEpTggx0mZawQ==,type:str] unencrypted_suffix: _unencrypted version: 3.10.2 diff --git a/user/packages.nix b/user/packages.nix index 2172693..cadf489 100644 --- a/user/packages.nix +++ b/user/packages.nix @@ -21,8 +21,6 @@ obsidian rclone - unstable.spotify-player - sops gimp audio-recorder @@ -105,12 +103,6 @@ trash-cli python3 - python313Packages.requests # For quick development for the university - python313Packages.pygame - python313Packages.scipy - python313Packages.pandas - python313Packages.matplotlib - python313Packages.numpy fd ttyper