From 3b1bfaccb721247808767366dde90b1be0ae07af Mon Sep 17 00:00:00 2001 From: Parker TenBroeck <51721964+ParkerTenBroeck@users.noreply.github.com> Date: Tue, 26 May 2026 11:14:56 -0400 Subject: [PATCH] added work laptop config --- hosts/work.nix | 116 ++++++++++++++++++++++++++++++++++++++++++++- modules/cli.nix | 2 + modules/docker.nix | 4 ++ modules/nvidia.nix | 19 ++++++++ 4 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 modules/docker.nix create mode 100644 modules/nvidia.nix diff --git a/hosts/work.nix b/hosts/work.nix index 3efb7fc..e420a56 100644 --- a/hosts/work.nix +++ b/hosts/work.nix @@ -1,17 +1,129 @@ -{ +{ pkgs, lib, config, ... }: + +let + hyprOneLine = script: + "sh -c ${lib.escapeShellArg (lib.concatStringsSep "; " ( + builtins.filter (line: line != "") ( + map lib.trim (lib.splitString "\n" script) + ) + ))}"; + + chromiumX11 = pkgs.symlinkJoin { + name = "chromium"; + paths = [ + (pkgs.writeShellScriptBin "chromium" '' + exec ${pkgs.chromium}/bin/chromium --ozone-platform=x11 "$@" + '') + + (pkgs.makeDesktopItem { + name = "chromium"; + desktopName = "Chromium"; + genericName = "Web Browser"; + exec = "chromium %U"; + icon = "chromium"; + categories = [ "Network" "WebBrowser" ]; + mimeTypes = [ + "text/html" + "x-scheme-handler/http" + "x-scheme-handler/https" + ]; + }) + ]; + }; + + hyprRun = pkgs.writeShellScript "hypr-run-nvidia" '' + export XDG_CURRENT_DESKTOP=Hyprland + export XDG_SESSION_DESKTOP=Hyprland + export __GLX_VENDOR_LIBRARY_NAME=nvidia + export GBM_BACKEND=nvidia + export _JAVA_AWT_WM_NONREPARENTING=1 + export XCURSOR_SIZE=24 + export WLR_DRM_DEVICES=$HOME/.config/hypr/card + + export __NV_PRIME_RENDER_OFFLOAD=1 + export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 + export __VK_LAYER_NV_optimus=NVIDIA_only + + exec ${pkgs.hyprland}/bin/Hyprland + ''; +in { imports = [ ./common.nix + /home/may/Documents/GitHub/mywt/nixos-wt-httpd.nix ../modules/networking.nix ../modules/bluetooth.nix + ../modules/nvidia.nix ../modules/fonts.nix ../modules/packages.nix + ../modules/tex.nix + ../modules/docker.nix ../modules/hyprland ]; nixpkgs.config.allowUnfree = true; networking.hostName = "work"; + networking.firewall.allowedTCPPorts = [ 5900 8026 25565 42069 8000 8080 ]; + + programs.nix-ld.enable = true; + + services.wtLocal = { + enable = true; + root = "/home/may/Documents/GitHub/wt"; + user = "may"; + group = "users"; + }; + + home-manager.users.may.wayland.windowManager.hyprland.settings.exec-once = lib.mkAfter [ + (hyprOneLine '' + sleep 2 + + hyprctl dispatch exec "[workspace 1 silent] chromium --restore-last-session" + + hyprctl dispatch exec "[workspace 2 silent] code /home/may/Documents/GitHub/wt" + hyprctl dispatch exec "[workspace 2 silent] alacritty --working-directory /home/may/Documents/GitHub/wt" + + hyprctl dispatch exec "[workspace 2 silent] code /home/may/Documents/GitHub/mywt" + hyprctl dispatch exec "[workspace 2 silent] alacritty --working-directory /home/may/Documents/GitHub/mywt" + + hyprctl dispatch exec "[workspace 4 silent] firefox" + '') + ]; + + home-manager.users.may.home.packages = [ + chromiumX11 + ] ++ (with pkgs; [ + docker + killall + wayvnc + wlr-randr + ]); + + environment.sessionVariables = { + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + GBM_BACKEND = "nvidia"; + _JAVA_AWT_WM_NONREPARENTING = "1"; + XCURSOR_SIZE = "24"; + + __NV_PRIME_RENDER_OFFLOAD = "1"; + __NV_PRIME_RENDER_OFFLOAD_PROVIDER = "NVIDIA-G0"; + __VK_LAYER_NV_optimus = "NVIDIA_only"; + }; + + hardware.nvidia.prime = { + sync.enable = true; + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:0:0:0"; + }; + + + services.greetd = lib.mkIf (config.services.greetd.enable && config.programs.hyprland.enable) { + settings = { + initial_session.command = lib.mkForce "${hyprRun}"; + default_session.command = + lib.mkForce "${pkgs.tuigreet}/bin/tuigreet --time --remember --cmd ${hyprRun}"; + }; + }; - system.stateVersion = "23.11"; home-manager.users.may.home.stateVersion = "25.11"; } diff --git a/modules/cli.nix b/modules/cli.nix index 765ab69..690c3f6 100644 --- a/modules/cli.nix +++ b/modules/cli.nix @@ -12,5 +12,7 @@ screen ranger # file manager ripgrep + cloc + gdu ]; } \ No newline at end of file diff --git a/modules/docker.nix b/modules/docker.nix new file mode 100644 index 0000000..29d7dd8 --- /dev/null +++ b/modules/docker.nix @@ -0,0 +1,4 @@ +{ + virtualisation.docker.enable = true; + users.users.may.extraGroups = [ "docker" ]; +} diff --git a/modules/nvidia.nix b/modules/nvidia.nix new file mode 100644 index 0000000..d917ea2 --- /dev/null +++ b/modules/nvidia.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: { + + hardware.graphics.enable = true; + nixpkgs.config.nvidia.acceptLicense = true; + hardware.nvidia = { + modesetting.enable = true; + nvidiaSettings = true; + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + + services.xserver.videoDrivers = [ "nvidia" ]; + + home-manager.users.may.home.packages = with pkgs; [ + nvtopPackages.nvidia + ]; +}