From 49b0d48a66f66c2d53cf32f948900f33dec15e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikodem=20Rabuli=C5=84ski?= Date: Mon, 2 Oct 2023 20:02:08 +0200 Subject: [PATCH] Initial legion desktop --- flake.lock | 107 +++++++++++++++++++++++++++++++++++++++ flake.nix | 4 ++ hosts/default.nix | 1 + hosts/legion/default.nix | 1 + hosts/legion/desktop.nix | 102 +++++++++++++++++++++++++++++++++++++ 5 files changed, 215 insertions(+) create mode 100644 hosts/legion/desktop.nix diff --git a/flake.lock b/flake.lock index d9f3746..1411a48 100644 --- a/flake.lock +++ b/flake.lock @@ -172,6 +172,22 @@ "type": "github" } }, + "fl-config": { + "locked": { + "lastModified": 1653159448, + "narHash": "sha256-PvB9ha0r4w6p412MBPP71kS/ZTBnOjxL0brlmyucPBA=", + "owner": "flakelib", + "repo": "fl", + "rev": "fcefb9738d5995308a24cda018a083ccb6b0f460", + "type": "github" + }, + "original": { + "owner": "flakelib", + "ref": "config", + "repo": "fl", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -242,6 +258,25 @@ "type": "github" } }, + "flakelib": { + "inputs": { + "fl-config": "fl-config", + "std": "std" + }, + "locked": { + "lastModified": 1683326042, + "narHash": "sha256-PRjFKmEzzoE0BeDM8zRdwMcUkMq4Ue340O4jv71PzBw=", + "owner": "flakelib", + "repo": "fl", + "rev": "d4be0a0007aeae09b8faced2e297b1062dc05b1e", + "type": "github" + }, + "original": { + "owner": "flakelib", + "repo": "fl", + "type": "github" + } + }, "haskell-flake": { "locked": { "lastModified": 1684780604, @@ -406,6 +441,21 @@ "type": "github" } }, + "nix-std": { + "locked": { + "lastModified": 1671170529, + "narHash": "sha256-015C6x3tZMEd83Vd2rpfLC86PSRJrbUca1U3Rysranw=", + "owner": "chessai", + "repo": "nix-std", + "rev": "3b307d64ef7d7e8769d36b8c8bf33983efd1415a", + "type": "github" + }, + "original": { + "owner": "chessai", + "repo": "nix-std", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1689444953, @@ -529,6 +579,44 @@ "type": "github" } }, + "nvidia-patch": { + "inputs": { + "flakelib": "flakelib", + "nixpkgs": [ + "nixpkgs" + ], + "nvidia-patch-src": "nvidia-patch-src" + }, + "locked": { + "lastModified": 1698914831, + "narHash": "sha256-7mCMio2bIzBZoiofOfrq6C/hYAAodtiDlYn7VVqb0pc=", + "owner": "arcnmx", + "repo": "nvidia-patch.nix", + "rev": "9b853953f3a134c17a43bc4261f3f3e3e833afb0", + "type": "github" + }, + "original": { + "owner": "arcnmx", + "repo": "nvidia-patch.nix", + "type": "github" + } + }, + "nvidia-patch-src": { + "flake": false, + "locked": { + "lastModified": 1698896513, + "narHash": "sha256-HqY8JrVRdCzG872SESJO5OyiBmr09vCN8j5aPz4Ba+U=", + "owner": "keylase", + "repo": "nvidia-patch", + "rev": "1d856fbab568f261859741b0c408b718a4e0d9b8", + "type": "github" + }, + "original": { + "owner": "keylase", + "repo": "nvidia-patch", + "type": "github" + } + }, "racket": { "inputs": { "nixpkgs": [ @@ -564,6 +652,7 @@ "nh": "nh", "niko-nur": "niko-nur", "nixpkgs": "nixpkgs_6", + "nvidia-patch": "nvidia-patch", "racket": "racket", "wrapper-manager": "wrapper-manager", "wrapper-manager-hm-compat": "wrapper-manager-hm-compat" @@ -613,6 +702,24 @@ "type": "github" } }, + "std": { + "inputs": { + "nix-std": "nix-std" + }, + "locked": { + "lastModified": 1671225084, + "narHash": "sha256-EzqxFHRifPyjUXQY4B8GJH75fTmWqFnQdj10Q984bR8=", + "owner": "flakelib", + "repo": "std", + "rev": "8546115941a5498ddb03a239aacdba151d433f09", + "type": "github" + }, + "original": { + "owner": "flakelib", + "repo": "std", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 67b88fb..cbc706d 100644 --- a/flake.nix +++ b/flake.nix @@ -108,6 +108,10 @@ conduit = { url = "gitlab:famedly/conduit?ref=next"; }; + nvidia-patch = { + url = "github:arcnmx/nvidia-patch.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; nixConfig = { diff --git a/hosts/default.nix b/hosts/default.nix index 2e7b9c4..17921d2 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -59,6 +59,7 @@ inputs.mailserver.nixosModules.default inputs.home-manager.nixosModules.home-manager inputs.hercules-ci-agent.nixosModules.agent-service + # inputs.nvidia-patch.nixosModules.nvidia-patch self.nixosModules.settei self.nixosModules.common sharedOptions diff --git a/hosts/legion/default.nix b/hosts/legion/default.nix index d643316..603b48b 100644 --- a/hosts/legion/default.nix +++ b/hosts/legion/default.nix @@ -9,6 +9,7 @@ ./hardware.nix # ./disks.nix ./msmtp.nix + ./desktop.nix ]; nixpkgs.hostPlatform = "x86_64-linux"; diff --git a/hosts/legion/desktop.nix b/hosts/legion/desktop.nix new file mode 100644 index 0000000..750b71d --- /dev/null +++ b/hosts/legion/desktop.nix @@ -0,0 +1,102 @@ +# TODO: Proper desktop module +{ + config, + pkgs, + lib, + username, + ... +}: { + # Needed for nvidia and steam + nixpkgs.config.allowUnfree = true; + + settei.user.config = {pkgs, ...}: { + home.packages = with pkgs; [alacritty brightnessctl dmenu]; + + xsession.windowManager.i3 = { + enable = true; + config = { + terminal = "alacritty"; + modifier = "Mod4"; + }; + }; + + home.file.".xinitrc".source = pkgs.writeShellScript "xinitrc" '' + xrandr --setprovideroutputsource modesetting NVIDIA-0 + xrandr --auto + exec dbus-run-session i3 + ''; + }; + + programs.steam = { + enable = true; + remotePlay.openFirewall = true; + dedicatedServer.openFirewall = true; + gamescopeSession = {}; + }; + + hardware.steam-hardware.enable = true; + + services.logind = + lib.genAttrs + ["lidSwitch" "lidSwitchDocked" "lidSwitchExternalPower"] + (_: "ignore"); + + services.pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + }; + + programs.dconf.enable = true; + services.dbus.enable = true; + + users.users.${username}.extraGroups = ["video" "input"]; + + # NVIDIA stuff + services.xserver = { + enable = true; + excludePackages = [pkgs.xterm]; + videoDrivers = ["nvidia"]; + layout = "pl"; + displayManager.startx.enable = true; + config = lib.mkForce '' + Section "OutputClass" + Identifier "intel" + MatchDriver "i915" + Driver "modesetting" + EndSection + + Section "OutputClass" + Identifier "nvidia" + MatchDriver "nvidia-drm" + Driver "nvidia" + Option "AllowEmptyInitialConfiguration" + Option "PrimaryGPU" "yes" + ModulePath "${config.hardware.nvidia.package.bin}/lib/xorg/modules" + ModulePath "${pkgs.xorg.xorgserver}/lib/xorg/modules" + EndSection + + Section "InputClass" + Identifier "touchpad" + Driver "libinput" + MatchIsTouchpad "on" + Option "Tapping" "on" + Option "TappingButtonMap" "lrm" + Option "NaturalScrolling" "true" + EndSection + ''; + exportConfiguration = true; + libinput.enable = true; + }; + + hardware.nvidia = { + # TODO: Makes the build spiral out of control? + # patch.enable = true; + modesetting.enable = true; + }; + + hardware.opengl = { + enable = true; + driSupport32Bit = true; + }; +}