diff --git a/hardware/displays.nix b/hardware/displays.nix index 383b6d5..8c11fa9 100644 --- a/hardware/displays.nix +++ b/hardware/displays.nix @@ -1,9 +1,8 @@ {...}: { displays = { enable = true; - displays = [ - { - name = "DP-1"; + displays = { + "hp" = { description = "HP Inc. HP 24x 1CR9500W9Q"; resolution = { x = 1920; @@ -12,10 +11,8 @@ }; position.x = 0; position.y = 0; - wallpaper = ../images/demonslayer.png; - } - { - name = "HDMI-A-1"; + }; + "asus" = { resolution = { x = 1920; y = 1080; @@ -25,9 +22,8 @@ x = 1920; y = 0; }; - wallpaper = ../images/nier2.jpg; rotation = 1; - } - ]; + }; + }; }; } diff --git a/hardware/g920.nix b/hardware/g920.nix new file mode 100644 index 0000000..b76a5a1 --- /dev/null +++ b/hardware/g920.nix @@ -0,0 +1,29 @@ +{ + pkgs, + user, +}: { + home-manager.users.${user}.imports = [ + { + home.packages = with pkgs; [ + oversteer + ]; + } + ]; + + environment.etc.logitechG920 = { + target = "usb_modeswitch.d/046d:c261"; + text = '' + DefaultVendor=046d + DefaultProduct=c261 + MessageEndpoint=01 + ResponseEndpoint=01 + TargetClass=0x03 + MessageContent="0f00010142" + ''; + }; + + services.udev.extraRules = '' + ATTR{idVendor}=="046d", ATTR{idProduct}=="c261", RUN+="${pkgs.usb-modeswitch}/bin/usb_modeswitch -c '/etc/usb_modeswitch.d/046d:c261'" + ''; + hardware.new-lg4ff.enable = true; +} diff --git a/hardware/zenix.nix b/hardware/zenix.nix index 92fd275..ada16ae 100644 --- a/hardware/zenix.nix +++ b/hardware/zenix.nix @@ -9,6 +9,7 @@ (modulesPath + "/installer/scan/not-detected.nix") ./displays.nix ./ddc.nix + (import ./g920.nix {inherit user pkgs;}) ]; boot.initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"]; @@ -70,10 +71,6 @@ nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - hardware.opengl = { - enable = true; - driSupport32Bit = true; - }; hardware.keyboard.zsa.enable = true; @@ -95,9 +92,9 @@ { home.stateVersion = "22.05"; + # TODO: put this in the displays module wayland.windowManager.hyprland = { extraConfig = '' - workspace = DP-1, 1 workspace = 1, monitor:DP-1 workspace = 2, monitor:DP-1 workspace = 3, monitor:DP-1 @@ -105,9 +102,25 @@ workspace = 5, monitor:DP-1 ''; }; - programs.waybar.settings.mainBar."hyprland/workspaces".persistent_workspaces = { - DP-1 = 5; - }; } ]; + + displays = { + displays."hp" = { + name = "DP-1"; + wallpaper = ../images/demonslayer.png; + workspaces = { + start = 1; + end = 5; + }; + }; + displays."asus" = { + name = "HDMI-A-1"; + wallpaper = ../images/nier2.jpg; + workspaces = { + start = 6; + end = 10; + }; + }; + }; } diff --git a/lib/home.nix b/lib/home.nix index 1389ac1..7b8e74a 100644 --- a/lib/home.nix +++ b/lib/home.nix @@ -2,7 +2,7 @@ user, name, work ? false, - displays ? [], + displays ? {}, userName, inputs, ... diff --git a/lib/modules/display.nix b/lib/modules/display.nix index feaeff9..40cb39a 100644 --- a/lib/modules/display.nix +++ b/lib/modules/display.nix @@ -69,12 +69,7 @@ with lib; let }; }; - resolutionType = types.submodule ({ - x, - y, - freq, - ... - }: { + resolutionType = types.submodule { options = { x = mkOption { description = "x"; @@ -92,45 +87,57 @@ with lib; let default = 0; }; }; - }); - displayType = - types.submodule - ({...}: { - options = { - name = mkOption { - description = "name of the display"; - }; - description = mkOption { - description = "description of display from hyprctl monitors"; - default = ""; - }; - scaling = mkOption { - type = types.float; - default = 1.0; - }; - rotation = mkOption { - type = types.int; - default = 0; - }; - resolution = mkOption { - description = "res"; - type = resolutionType; - default = {}; - }; - position.x = mkOption { - default = -1; - type = types.int; - }; - position.y = mkOption { - default = -1; - type = types.int; - }; - wallpaper = mkOption { - description = "path to wallpaper"; - default = ""; + }; + + displayType = types.submodule { + options = { + name = mkOption { + description = "name of the display"; + }; + description = mkOption { + description = "description of display from hyprctl monitors"; + default = ""; + }; + scaling = mkOption { + type = types.float; + default = 1.0; + }; + rotation = mkOption { + type = types.int; + default = 0; + }; + resolution = mkOption { + description = "res"; + type = resolutionType; + default = {}; + }; + position.x = mkOption { + default = -1; + type = types.int; + }; + position.y = mkOption { + default = -1; + type = types.int; + }; + wallpaper = mkOption { + description = "path to wallpaper"; + default = ""; + }; + workspaces = mkOption { + default = {}; + type = types.submodule { + options = { + start = mkOption { + type = types.int; + }; + end = mkOption { + type = types.int; + }; + }; }; }; - }); + }; + }; resUnset = res: (res.x == 0 || res.y == 0 || res.freq == 0); @@ -138,26 +145,42 @@ with lib; let if resUnset res then "preferred" else "${toString res.x}x${toString res.y}@${toString res.freq}"; + + waybarWorkspaceConf = monitors: (map (display: { + ${display.name} = display.workspaces.start; + }) + monitors); + + renderWorkspacesForHyprland = displays: (map hyprWorkspaceSetting displays); + hyprWorkspaceSetting = display: + specificDisplay display + + ", " + + toString display.workspaces.start; in { options.displays = { enable = mkEnableOption "manage displays"; displays = mkOption { - type = types.listOf displayType; - default = []; + type = types.attrsOf displayType; + default = {}; }; }; config = mkIf cfg.enable { home-manager.users.${user}.imports = [ { - wayland.windowManager.hyprland.settings.monitor = - mkIf (cfg.displays != []) - (renderDisplaysForHyprland cfg.displays); + systemd.user.services.swaybg = swaybgJob (attrValues cfg.displays); - systemd.user.services.swaybg = swaybgJob cfg.displays; - wayland.windowManager.sway.config.output = - mkIf (cfg.displays != []) - (renderDisplaysForSway cfg.displays); + programs.waybar.settings.mainBar."hyprland/workspaces".persistent_workspaces = waybarWorkspaceConf (attrValues cfg.displays); + + wayland.windowManager = mkIf (cfg.displays != {}) { + hyprland.settings = { + monitor = renderDisplaysForHyprland (attrValues cfg.displays); + workspace = renderWorkspacesForHyprland (attrValues cfg.displays); + }; + + sway.config.output = + renderDisplaysForSway (attrValues cfg.displays); + }; } ]; }; diff --git a/lib/modules/gamer.nix b/lib/modules/gamer.nix index c2d06d0..8a872ab 100644 --- a/lib/modules/gamer.nix +++ b/lib/modules/gamer.nix @@ -14,38 +14,24 @@ with lib; { nixpkgs.config.permittedInsecurePackages = [ "electron-25.9.0" ]; - nixpkgs.config.packageOverrides = pkgs: { - steam = pkgs.steam.override { - extraPkgs = pkgs: - with pkgs; [ - xorg.libXcursor - xorg.libXi - xorg.libXinerama - xorg.libXScrnSaver - libpng - libpulseaudio - libvorbis - stdenv.cc.cc.lib - libkrb5 - keyutils - ]; - }; - }; home-manager.users.${user}.imports = [ { home.packages = with pkgs; [ + # Games airshipper minetest superTuxKart xonotic + # Helpers heroic BeatSaberModManager protontricks protonup-qt - gamescope + oversteer + # vr monado openxr-loader opencomposite @@ -55,7 +41,6 @@ with lib; { desktopName = "X11 Steam Wrapper"; exec = "QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11 ${steam}/bin/steam"; }) - oversteer ]; } ]; @@ -74,22 +59,5 @@ with lib; { dedicatedServer.openFirewall = true; }; programs.gamemode.enable = true; - - hardware.steam-hardware.enable = true; - environment.etc.logitechG920 = { - target = "usb_modeswitch.d/046d:c261"; - text = '' - DefaultVendor=046d - DefaultProduct=c261 - MessageEndpoint=01 - ResponseEndpoint=01 - TargetClass=0x03 - MessageContent="0f00010142" - ''; - }; - services.udev.extraRules = '' - ATTR{idVendor}=="046d", ATTR{idProduct}=="c261", RUN+="${pkgs.usb-modeswitch}/bin/usb_modeswitch -c '/etc/usb_modeswitch.d/046d:c261'" - ''; - hardware.new-lg4ff.enable = true; }; } diff --git a/lib/modules/laptop.nix b/lib/modules/laptop.nix index 351bc7f..13e7c8e 100644 --- a/lib/modules/laptop.nix +++ b/lib/modules/laptop.nix @@ -17,12 +17,10 @@ in { config = mkIf cfg.enable { displays = mkIf cfg.displays { enable = true; - displays = [ - { - name = "eDP-1"; - scaling = 1.2; - } - ]; + displays.internal = { + name = "eDP-1"; + scaling = 1.2; + }; }; keyboard.dvorak.enable = true; diff --git a/lib/modules/work.nix b/lib/modules/work.nix index 2330e22..b5dd959 100644 --- a/lib/modules/work.nix +++ b/lib/modules/work.nix @@ -10,17 +10,15 @@ with lib; { }; config = mkIf config.roles.work.enable { - displays.displays = [ - { - name = "eDP-1"; - description = "BOE 0x07D8"; - position = { - x = 0; - y = 1080; - }; - wallpaper = ../../images/nix-soft.png; - } - ]; + displays.displays.internal = { + name = "eDP-1"; + description = "BOE 0x07D8"; + position = { + x = 0; + y = 1080; + }; + wallpaper = ../../images/nix-soft.png; + }; roles.email = { enable = true;