mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -04:00
Add shared monitor configuration across window managers
- Define monitors option in hardware.nix with explicit dimensions - Pass monitors to home-manager via extraSpecialArgs - Update hyprland and sway to consume shared monitor config - Removes hardcoded monitor definitions from WM modules
This commit is contained in:
parent
2be7ed502c
commit
d1144e96d3
4 changed files with 111 additions and 73 deletions
|
|
@ -1,76 +1,100 @@
|
|||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
with lib;
|
||||
{
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
|
||||
boot = {
|
||||
initrd = {
|
||||
availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
|
||||
kernelModules = [ "dm-snapshot" ];
|
||||
};
|
||||
extraModulePackages = [ ];
|
||||
kernelPackages = pkgs.linuxPackages_zen;
|
||||
kernelParams = [ "intel_iommu=on" ];
|
||||
kernelModules = [ "kvm-intel" "virtio" "vfio-pci" "coretemp" ];
|
||||
options.monitors = mkOption {
|
||||
type = types.listOf (types.submodule {
|
||||
options = {
|
||||
name = mkOption { type = types.str; example = "HDMI-A-1"; };
|
||||
width = mkOption { type = types.int; };
|
||||
height = mkOption { type = types.int; };
|
||||
x = mkOption { type = types.int; };
|
||||
y = mkOption { type = types.int; };
|
||||
scale = mkOption { type = types.float; };
|
||||
refreshRate = mkOption { type = types.int; };
|
||||
};
|
||||
});
|
||||
default = [];
|
||||
description = "System monitor configuration";
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
linuxHeaders
|
||||
config = {
|
||||
monitors = [
|
||||
{ name = "HDMI-A-1"; width = 1920; height = 1080; x = 0; y = 0; scale = 1.0; refreshRate = 60; }
|
||||
{ name = "DP-1"; width = 1920; height = 1080; x = 1920; y = 0; scale = 1.0; refreshRate = 60; }
|
||||
];
|
||||
|
||||
vulkan-headers
|
||||
vulkan-loader
|
||||
vulkan-tools
|
||||
vulkan-extension-layer
|
||||
|
||||
mesa
|
||||
mesa-demos
|
||||
|
||||
cudaPackages.cudatoolkit
|
||||
cudaPackages.cudnn
|
||||
];
|
||||
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
device = "/dev/disk/by-uuid/495f5e7b-d9e4-4663-88c5-7021e7292535";
|
||||
fsType = "ext4";
|
||||
boot = {
|
||||
initrd = {
|
||||
availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
|
||||
kernelModules = [ "dm-snapshot" ];
|
||||
};
|
||||
extraModulePackages = [ ];
|
||||
kernelPackages = pkgs.linuxPackages_zen;
|
||||
kernelParams = [ "intel_iommu=on" ];
|
||||
kernelModules = [ "kvm-intel" "virtio" "vfio-pci" "coretemp" ];
|
||||
};
|
||||
|
||||
"/home" = {
|
||||
device = "/dev/disk/by-uuid/cd0e5c29-716d-47f2-92f4-46ee9fca5af3";
|
||||
fsType = "ext4";
|
||||
};
|
||||
environment.systemPackages = with pkgs; [
|
||||
linuxHeaders
|
||||
|
||||
"/boot" = {
|
||||
device = "/dev/disk/by-uuid/C061-EE77";
|
||||
fsType = "vfat";
|
||||
};
|
||||
};
|
||||
vulkan-headers
|
||||
vulkan-loader
|
||||
vulkan-tools
|
||||
vulkan-extension-layer
|
||||
|
||||
hardware = {
|
||||
cpu = {
|
||||
intel = {
|
||||
updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
mesa
|
||||
mesa-demos
|
||||
|
||||
cudaPackages.cudatoolkit
|
||||
cudaPackages.cudnn
|
||||
];
|
||||
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
device = "/dev/disk/by-uuid/495f5e7b-d9e4-4663-88c5-7021e7292535";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
"/home" = {
|
||||
device = "/dev/disk/by-uuid/cd0e5c29-716d-47f2-92f4-46ee9fca5af3";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
"/boot" = {
|
||||
device = "/dev/disk/by-uuid/C061-EE77";
|
||||
fsType = "vfat";
|
||||
};
|
||||
};
|
||||
nvidia = {
|
||||
open = true;
|
||||
modesetting.enable = true;
|
||||
nvidiaSettings = true;
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
|
||||
hardware = {
|
||||
cpu = {
|
||||
intel = {
|
||||
updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
};
|
||||
};
|
||||
nvidia = {
|
||||
open = true;
|
||||
modesetting.enable = true;
|
||||
nvidiaSettings = true;
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
};
|
||||
graphics = {
|
||||
enable = true;
|
||||
enable32Bit = true;
|
||||
};
|
||||
};
|
||||
graphics = {
|
||||
|
||||
virtualisation.libvirtd = {
|
||||
enable = true;
|
||||
enable32Bit = true;
|
||||
qemu = {
|
||||
runAsRoot = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
virtualisation.libvirtd = {
|
||||
enable = true;
|
||||
qemu = {
|
||||
runAsRoot = true;
|
||||
};
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
|
||||
};
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.extraSpecialArgs = {
|
||||
monitors = config.monitors;
|
||||
};
|
||||
home-manager.users.${config.user.name} = {
|
||||
imports = [ ../../../../../user ];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
{ pkgs, lib, config, monitors ? [], ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.modules.user.gui.wm.hyprland;
|
||||
|
||||
|
||||
wallpaper = builtins.fetchurl {
|
||||
url = "https://images6.alphacoders.com/117/1174033.png";
|
||||
sha256 = "1ph5m9s57076jx6042iipqx2ifzadmd5z4lf5l49wgq4jb92mp16";
|
||||
};
|
||||
|
||||
toHyprlandMonitor = m:
|
||||
"${m.name}, ${toString m.width}x${toString m.height}@${toString m.refreshRate}, ${toString m.x}x${toString m.y}, ${toString m.scale}";
|
||||
|
||||
in
|
||||
{ options.modules.user.gui.wm.hyprland = { enable = mkEnableOption "Enable Hyprland WM"; };
|
||||
config = mkIf cfg.enable {
|
||||
|
|
@ -21,10 +24,9 @@ in
|
|||
"$terminal" = "${pkgs.alacritty}/bin/alacritty";
|
||||
"$menu" = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'";
|
||||
|
||||
monitor = [
|
||||
"HDMI-A-1, 1920x1080, 0x0, 1"
|
||||
"DP-1, 1920x1080, 1920x0, 1"
|
||||
];
|
||||
monitor = if monitors != []
|
||||
then map toHyprlandMonitor monitors
|
||||
else [ ", preferred, auto, 1" ];
|
||||
|
||||
exec-once = [
|
||||
"waybar"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
{ pkgs, lib, config, monitors ? [], ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
|
|
@ -12,15 +12,30 @@ let
|
|||
|
||||
barStatus = pkgs.writeShellScript "status.sh" ''
|
||||
#!/usr/bin/env bash
|
||||
while :; do
|
||||
echo "$(ip -4 addr show eno1 | awk '/inet / {print $2}' | cut -d'/' -f1) | $(free -h | awk '/^Mem/ {print $3}') | $(date +'%I:%M:%S %p') | $(date +'%m-%d-%Y')"; sleep 1;
|
||||
while :; do
|
||||
echo "$(ip -4 addr show eno1 | awk '/inet / {print $2}' | cut -d'/' -f1) | $(free -h | awk '/^Mem/ {print $3}') | $(date +'%I:%M:%S %p') | $(date +'%m-%d-%Y')"; sleep 1;
|
||||
done
|
||||
'';
|
||||
|
||||
toSwayOutput = m: {
|
||||
"${m.name}" = {
|
||||
resolution = "${toString m.width}x${toString m.height}@${toString m.refreshRate}Hz";
|
||||
position = "${toString m.x} ${toString m.y}";
|
||||
scale = toString m.scale;
|
||||
bg = "${wallpaper} fill";
|
||||
};
|
||||
};
|
||||
|
||||
outputConfig = if monitors != []
|
||||
then lib.mkMerge (map toSwayOutput monitors)
|
||||
else {
|
||||
"*" = { bg = "${wallpaper} fill"; };
|
||||
};
|
||||
|
||||
in
|
||||
{ options.modules.user.gui.wm.sway = { enable = mkEnableOption "Enable Sway WM"; };
|
||||
config = mkIf cfg.enable {
|
||||
wayland.windowManager.sway = {
|
||||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
xwayland = true;
|
||||
wrapperFeatures.gtk = true;
|
||||
|
|
@ -37,13 +52,7 @@ in
|
|||
names = [ "Terminus" ];
|
||||
};
|
||||
|
||||
output = {
|
||||
DP-2 = {
|
||||
resolution = "3440x1440@59.973Hz";
|
||||
position = "0,0";
|
||||
bg = "${wallpaper} fill";
|
||||
};
|
||||
};
|
||||
output = outputConfig;
|
||||
modifier = "Mod1";
|
||||
menu = "rofi -show drun -show-icons -drun-icon-theme Qogir -font 'Noto Sans 14'";
|
||||
terminal = "${pkgs.alacritty}/bin/alacritty";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue