organise stuff

This commit is contained in:
tristan 2023-12-30 01:31:26 +00:00
parent 3b63b8b52b
commit 52dff69cca
8 changed files with 149 additions and 124 deletions

View file

@ -1,9 +1,8 @@
{...}: { {...}: {
displays = { displays = {
enable = true; enable = true;
displays = [ displays = {
{ "hp" = {
name = "DP-1";
description = "HP Inc. HP 24x 1CR9500W9Q"; description = "HP Inc. HP 24x 1CR9500W9Q";
resolution = { resolution = {
x = 1920; x = 1920;
@ -12,10 +11,8 @@
}; };
position.x = 0; position.x = 0;
position.y = 0; position.y = 0;
wallpaper = ../images/demonslayer.png; };
} "asus" = {
{
name = "HDMI-A-1";
resolution = { resolution = {
x = 1920; x = 1920;
y = 1080; y = 1080;
@ -25,9 +22,8 @@
x = 1920; x = 1920;
y = 0; y = 0;
}; };
wallpaper = ../images/nier2.jpg;
rotation = 1; rotation = 1;
} };
]; };
}; };
} }

29
hardware/g920.nix Normal file
View file

@ -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;
}

View file

@ -9,6 +9,7 @@
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
./displays.nix ./displays.nix
./ddc.nix ./ddc.nix
(import ./g920.nix {inherit user pkgs;})
]; ];
boot.initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"]; boot.initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"];
@ -70,10 +71,6 @@
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
hardware.opengl = {
enable = true;
driSupport32Bit = true;
};
hardware.keyboard.zsa.enable = true; hardware.keyboard.zsa.enable = true;
@ -95,9 +92,9 @@
{ {
home.stateVersion = "22.05"; home.stateVersion = "22.05";
# TODO: put this in the displays module
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
extraConfig = '' extraConfig = ''
workspace = DP-1, 1
workspace = 1, monitor:DP-1 workspace = 1, monitor:DP-1
workspace = 2, monitor:DP-1 workspace = 2, monitor:DP-1
workspace = 3, monitor:DP-1 workspace = 3, monitor:DP-1
@ -105,9 +102,25 @@
workspace = 5, monitor:DP-1 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;
};
};
};
} }

View file

@ -2,7 +2,7 @@
user, user,
name, name,
work ? false, work ? false,
displays ? [], displays ? {},
userName, userName,
inputs, inputs,
... ...

View file

@ -69,12 +69,7 @@ with lib; let
}; };
}; };
resolutionType = types.submodule ({ resolutionType = types.submodule {
x,
y,
freq,
...
}: {
options = { options = {
x = mkOption { x = mkOption {
description = "x"; description = "x";
@ -92,45 +87,57 @@ with lib; let
default = 0; default = 0;
}; };
}; };
}); };
displayType =
types.submodule displayType = types.submodule {
({...}: { options = {
options = { name = mkOption {
name = mkOption { description = "name of the display";
description = "name of the display"; };
}; description = mkOption {
description = mkOption { description = "description of display from hyprctl monitors";
description = "description of display from hyprctl monitors"; default = "";
default = ""; };
}; scaling = mkOption {
scaling = mkOption { type = types.float;
type = types.float; default = 1.0;
default = 1.0; };
}; rotation = mkOption {
rotation = mkOption { type = types.int;
type = types.int; default = 0;
default = 0; };
}; resolution = mkOption {
resolution = mkOption { description = "res";
description = "res"; type = resolutionType;
type = resolutionType; default = {};
default = {}; };
}; position.x = mkOption {
position.x = mkOption { default = -1;
default = -1; type = types.int;
type = types.int; };
}; position.y = mkOption {
position.y = mkOption { default = -1;
default = -1; type = types.int;
type = types.int; };
}; wallpaper = mkOption {
wallpaper = mkOption { description = "path to wallpaper";
description = "path to wallpaper"; default = "";
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); resUnset = res: (res.x == 0 || res.y == 0 || res.freq == 0);
@ -138,26 +145,42 @@ with lib; let
if resUnset res if resUnset res
then "preferred" then "preferred"
else "${toString res.x}x${toString res.y}@${toString res.freq}"; 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 { in {
options.displays = { options.displays = {
enable = mkEnableOption "manage displays"; enable = mkEnableOption "manage displays";
displays = mkOption { displays = mkOption {
type = types.listOf displayType; type = types.attrsOf displayType;
default = []; default = {};
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.${user}.imports = [ home-manager.users.${user}.imports = [
{ {
wayland.windowManager.hyprland.settings.monitor = systemd.user.services.swaybg = swaybgJob (attrValues cfg.displays);
mkIf (cfg.displays != [])
(renderDisplaysForHyprland cfg.displays);
systemd.user.services.swaybg = swaybgJob cfg.displays; programs.waybar.settings.mainBar."hyprland/workspaces".persistent_workspaces = waybarWorkspaceConf (attrValues cfg.displays);
wayland.windowManager.sway.config.output =
mkIf (cfg.displays != []) wayland.windowManager = mkIf (cfg.displays != {}) {
(renderDisplaysForSway cfg.displays); hyprland.settings = {
monitor = renderDisplaysForHyprland (attrValues cfg.displays);
workspace = renderWorkspacesForHyprland (attrValues cfg.displays);
};
sway.config.output =
renderDisplaysForSway (attrValues cfg.displays);
};
} }
]; ];
}; };

View file

@ -14,38 +14,24 @@ with lib; {
nixpkgs.config.permittedInsecurePackages = [ nixpkgs.config.permittedInsecurePackages = [
"electron-25.9.0" "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-manager.users.${user}.imports = [
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
# Games
airshipper airshipper
minetest minetest
superTuxKart superTuxKart
xonotic xonotic
# Helpers
heroic heroic
BeatSaberModManager BeatSaberModManager
protontricks protontricks
protonup-qt protonup-qt
gamescope oversteer
# vr
monado monado
openxr-loader openxr-loader
opencomposite opencomposite
@ -55,7 +41,6 @@ with lib; {
desktopName = "X11 Steam Wrapper"; desktopName = "X11 Steam Wrapper";
exec = "QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11 ${steam}/bin/steam"; exec = "QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11 ${steam}/bin/steam";
}) })
oversteer
]; ];
} }
]; ];
@ -74,22 +59,5 @@ with lib; {
dedicatedServer.openFirewall = true; dedicatedServer.openFirewall = true;
}; };
programs.gamemode.enable = 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;
}; };
} }

View file

@ -17,12 +17,10 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
displays = mkIf cfg.displays { displays = mkIf cfg.displays {
enable = true; enable = true;
displays = [ displays.internal = {
{ name = "eDP-1";
name = "eDP-1"; scaling = 1.2;
scaling = 1.2; };
}
];
}; };
keyboard.dvorak.enable = true; keyboard.dvorak.enable = true;

View file

@ -10,17 +10,15 @@ with lib; {
}; };
config = mkIf config.roles.work.enable { config = mkIf config.roles.work.enable {
displays.displays = [ displays.displays.internal = {
{ name = "eDP-1";
name = "eDP-1"; description = "BOE 0x07D8";
description = "BOE 0x07D8"; position = {
position = { x = 0;
x = 0; y = 1080;
y = 1080; };
}; wallpaper = ../../images/nix-soft.png;
wallpaper = ../../images/nix-soft.png; };
}
];
roles.email = { roles.email = {
enable = true; enable = true;