my over complex system configurations dotfiles.isabelroses.com/
nixos nix flake dotfiles linux
12
fork

Configure Feed

Select the types of activity you want to include in your feed.

nixos/hardware: cleanup monitors

+132 -91
+78 -55
home/isabel/gui/hyprland.nix
··· 14 14 concatLists 15 15 imap0 16 16 concatLines 17 + mod 18 + attrNames 19 + foldl' 20 + min 21 + id 17 22 ; 18 23 19 24 inherit (config.garden.programs) defaults; 20 25 inherit (osConfig.garden.device) monitors keyboard; 26 + 27 + mapMonitors = concatLines ( 28 + imap0 ( 29 + i: m: 30 + "monitor=${m.name},${toString m.width}x${toString m.height}@${toString m.refresh-rate},${toString (i * 1920)}x0,${toString m.scale}" 31 + ) monitors 32 + ); 33 + 34 + mapMonitorsToWs = 35 + let 36 + names = attrNames monitors; 37 + count = length names; 38 + splitBy = builtins.div 10 count; 39 + remainder = mod 10 count; 40 + firstSplitBy = splitBy + remainder; 41 + in 42 + concatLines 43 + (foldl' 44 + ( 45 + acc: i: 46 + let 47 + currentSplitBy = if acc.elem == 0 then firstSplitBy else splitBy; 48 + shouldIncrement = acc.usedFor >= currentSplitBy; 49 + newElem = min (if shouldIncrement then acc.elem + 1 else acc.elem) (count - 1); 50 + asStr = "workspace=${toString (i + 1)}, monitor:${elemAt names newElem}${ 51 + if i == 0 then ", default:true" else "" 52 + }"; 53 + in 54 + { 55 + usedFor = if shouldIncrement then 1 else acc.usedFor + 1; 56 + elem = newElem; 57 + out = acc.out ++ [ asStr ]; 58 + } 59 + ) 60 + { 61 + usedFor = 0; 62 + elem = 0; 63 + out = [ ]; 64 + } 65 + (genList id 10) 66 + ).out; 21 67 in 22 68 { 23 69 options.programs.hyprland.enable = lib.mkEnableOption "Enable Hyprland as the Wayland window manager"; ··· 281 327 ]; 282 328 }; 283 329 284 - extraConfig = 285 - let 286 - mapMonitors = concatLines ( 287 - imap0 ( 288 - i: monitor: 289 - ''monitor=${monitor},${ 290 - if monitor == "eDP-1" then "1920x1080@60" else "preferred" 291 - },${toString (i * 1920)}x0,1'' 292 - ) monitors 293 - ); 330 + extraConfig = '' 331 + ${mapMonitors} 332 + ${optionalString (length (attrNames monitors) != 1) "${mapMonitorsToWs}"} 294 333 295 - mapMonitorsToWs = concatLines ( 296 - genList (x: '' 297 - workspace = ${toString (x + 1)}, monitor:${ 298 - if (x + 1) <= 5 then 299 - "${elemAt monitors 0} ${if (x + 1) == 1 then ", default:true" else ""}" 300 - else 301 - "${elemAt monitors 1}" 302 - } 303 - '') 10 304 - ); 334 + # █▀▄▀█ █▀█ █░█ █▀▀ 335 + # █░▀░█ █▄█ ▀▄▀ ██▄ 336 + bind=SUPER, M, submap, move 337 + submap=move 305 338 306 - in 307 - '' 308 - ${mapMonitors} 309 - ${optionalString (length monitors != 1) "${mapMonitorsToWs}"} 339 + binde = , left, movewindow, l 340 + binde = , right, movewindow, r 341 + binde = , up, movewindow, u 342 + binde = , down, movewindow, d 343 + binde = , j, movewindow, l 344 + binde = , l, movewindow, r 345 + binde = , i, movewindow, u 346 + binde = , k, movewindow, d 310 347 311 - # █▀▄▀█ █▀█ █░█ █▀▀ 312 - # █░▀░█ █▄█ ▀▄▀ ██▄ 313 - bind=SUPER, M, submap, move 314 - submap=move 348 + bind=,escape,submap,reset 349 + submap=reset 315 350 316 - binde = , left, movewindow, l 317 - binde = , right, movewindow, r 318 - binde = , up, movewindow, u 319 - binde = , down, movewindow, d 320 - binde = , j, movewindow, l 321 - binde = , l, movewindow, r 322 - binde = , i, movewindow, u 323 - binde = , k, movewindow, d 351 + # █▀█ █▀▀ █▀ █ ▀█ █▀▀ 352 + # █▀▄ ██▄ ▄█ █ █▄ ██▄ 353 + bind=SUPER, R, submap, resize 354 + submap=resize 324 355 325 - bind=,escape,submap,reset 326 - submap=reset 356 + binde = , left, resizeactive, -20 0 357 + binde = , right, resizeactive, 20 0 358 + binde = , up, resizeactive, 0 -20 359 + binde = , down, resizeactive, 0 20 360 + binde = , h, resizeactive, -20 0 361 + binde = , j, resizeactive, 20 0 362 + binde = , i, resizeactive, 0 -20 363 + binde = , k, resizeactive, 0 20 327 364 328 - # █▀█ █▀▀ █▀ █ ▀█ █▀▀ 329 - # █▀▄ ██▄ ▄█ █ █▄ ██▄ 330 - bind=SUPER, R, submap, resize 331 - submap=resize 332 - 333 - binde = , left, resizeactive, -20 0 334 - binde = , right, resizeactive, 20 0 335 - binde = , up, resizeactive, 0 -20 336 - binde = , down, resizeactive, 0 20 337 - binde = , h, resizeactive, -20 0 338 - binde = , j, resizeactive, 20 0 339 - binde = , i, resizeactive, 0 -20 340 - binde = , k, resizeactive, 0 20 341 - 342 - bind=,escape,submap,reset 343 - submap=reset 344 - ''; 365 + bind=,escape,submap,reset 366 + submap=reset 367 + ''; 345 368 }; 346 369 }; 347 370 }
+1 -1
modules/flake/lib/default.nix
··· 16 16 # we have to rexport the functions we want to use, but don't want to refer to the whole lib 17 17 # "path". e.g. gardenLib.hardware.isx86Linux can be shortened to gardenLib.isx86Linux 18 18 # NOTE: never rexport templates 19 - inherit (final.hardware) isx86Linux primaryMonitor ldTernary; 19 + inherit (final.hardware) isx86Linux ldTernary; 20 20 inherit (final.helpers) 21 21 mkPubs 22 22 giturl
+1 -24
modules/flake/lib/hardware.nix
··· 51 51 d 52 52 else 53 53 throw "Unsupported system: ${pkgs.stdenv.system}"; 54 - 55 - /** 56 - assume the first monitor in the list of monitors is primary 57 - get its name from the list of monitors 58 - 59 - # Arguments 60 - 61 - - [config] the configuration that nixosConfigurations provides 62 - 63 - # Type 64 - 65 - ``` 66 - primaryMonitor :: AttrSet -> String 67 - ``` 68 - 69 - # Example 70 - 71 - ```nix 72 - primaryMonitor osConfig 73 - => "DP-1" 74 - ``` 75 - */ 76 - primaryMonitor = config: builtins.elemAt config.garden.device.monitors 0; 77 54 in 78 55 { 79 - inherit isx86Linux primaryMonitor ldTernary; 56 + inherit isx86Linux ldTernary; 80 57 }
+46 -5
modules/nixos/hardware/options.nix
··· 1 1 { lib, ... }: 2 2 let 3 - inherit (lib.options) mkOption; 4 - inherit (lib.types) listOf str enum; 3 + inherit (lib) mkOption types; 5 4 in 6 5 { 7 6 options.garden.device = { 8 7 monitors = mkOption { 9 - type = listOf str; 10 - default = [ ]; 8 + type = types.attrsOf ( 9 + types.submodule ( 10 + { name, ... }: 11 + { 12 + options = { 13 + name = mkOption { 14 + type = types.str; 15 + default = name; 16 + description = "the name of the monitor"; 17 + example = "HDMI-1"; 18 + }; 19 + 20 + width = mkOption { 21 + type = types.int; 22 + default = 1920; 23 + example = 1080; 24 + description = "the width of the monitor in pixels"; 25 + }; 26 + 27 + height = mkOption { 28 + type = types.int; 29 + default = 1080; 30 + example = 1024; 31 + description = "the height of the monitor in pixels"; 32 + }; 33 + 34 + refresh-rate = mkOption { 35 + type = types.int; 36 + default = 60; 37 + example = 120; 38 + description = "the refresh rate of the monitor in Hz"; 39 + }; 40 + 41 + scale = mkOption { 42 + type = types.float; 43 + default = 1.0; 44 + example = 1.5; 45 + description = "the scale factor for the monitor"; 46 + }; 47 + }; 48 + } 49 + ) 50 + ); 51 + 11 52 description = '' 12 53 this does not affect any drivers and such, it is only necessary for 13 54 declaring things like monitors in window manager configurations ··· 16 57 }; 17 58 18 59 keyboard = mkOption { 19 - type = enum [ 60 + type = types.enum [ 20 61 "us" 21 62 "gb" 22 63 ];
+4 -4
systems/amaterasu/default.nix
··· 13 13 device = { 14 14 cpu = "intel"; 15 15 gpu = "nvidia"; 16 - monitors = [ 17 - "DP-1" 18 - "DP-2" 19 - ]; 16 + monitors = { 17 + DP-1.refresh-rate = 144; 18 + DP-2 = { }; 19 + }; 20 20 capabilities = { 21 21 tpm = true; 22 22 bluetooth = true;
+2 -1
systems/athena/default.nix
··· 11 11 device = { 12 12 cpu = "intel"; 13 13 gpu = "intel"; 14 - monitors = [ "eDP-1" ]; 14 + monitors.eDP-1 = { }; 15 + keyboard = "us"; 15 16 capabilities = { 16 17 tpm = true; 17 18 bluetooth = true;
-1
systems/valkyrie/default.nix
··· 10 10 device = { 11 11 cpu = null; 12 12 gpu = null; 13 - monitors = [ ]; 14 13 capabilities = { 15 14 tpm = true; 16 15 bluetooth = false;