diff --git a/common/home/neovim/grammar.nix b/common/home/neovim/grammar.nix index 18adb057..9595b0d8 100644 --- a/common/home/neovim/grammar.nix +++ b/common/home/neovim/grammar.nix @@ -1,62 +1,63 @@ -{ stdenv -, nodejs -, tree-sitter -, lib +{ + stdenv, + nodejs, + tree-sitter, + lib, }: - # https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/parsing/tree-sitter/grammar.nix # Build a parser grammar and put the resulting shared object in `$out/parser` - { # language name - language -, version -, src -, location ? null -, generate ? false -, ... -}@args: - + language, + version, + src, + location ? null, + generate ? false, + ... +} @ args: stdenv.mkDerivation ({ - pname = "${language}-grammar"; + pname = "${language}-grammar"; - inherit src version; + inherit src version; - nativeBuildInputs = lib.optionals generate [ nodejs tree-sitter ]; + nativeBuildInputs = lib.optionals generate [nodejs tree-sitter]; - CFLAGS = [ "-Isrc" "-O2" ]; - CXXFLAGS = [ "-Isrc" "-O2" ]; + CFLAGS = ["-Isrc" "-O2"]; + CXXFLAGS = ["-Isrc" "-O2"]; - stripDebugList = [ "parser" ]; + stripDebugList = ["parser"]; - configurePhase = lib.optionalString (location != null) '' - cd ${location} - '' + lib.optionalString generate '' - tree-sitter generate - ''; + configurePhase = + lib.optionalString (location != null) '' + cd ${location} + '' + + lib.optionalString generate '' + tree-sitter generate + ''; - # When both scanner.{c,cc} exist, we should not link both since they may be the same but in - # different languages. Just randomly prefer C++ if that happens. - buildPhase = '' - runHook preBuild - if [[ -e src/scanner.cc ]]; then - $CXX -fPIC -c src/scanner.cc -o scanner.o $CXXFLAGS - elif [[ -e src/scanner.c ]]; then - $CC -fPIC -c src/scanner.c -o scanner.o $CFLAGS - fi - $CC -fPIC -c src/parser.c -o parser.o $CFLAGS - rm -rf parser - $CXX -shared -o parser *.o - runHook postBuild - ''; + # When both scanner.{c,cc} exist, we should not link both since they may be the same but in + # different languages. Just randomly prefer C++ if that happens. + buildPhase = '' + runHook preBuild + if [[ -e src/scanner.cc ]]; then + $CXX -fPIC -c src/scanner.cc -o scanner.o $CXXFLAGS + elif [[ -e src/scanner.c ]]; then + $CC -fPIC -c src/scanner.c -o scanner.o $CFLAGS + fi + $CC -fPIC -c src/parser.c -o parser.o $CFLAGS + rm -rf parser + $CXX -shared -o parser *.o + runHook postBuild + ''; - installPhase = '' - runHook preInstall - mkdir $out - mv parser $out/ - if [[ -d queries ]]; then - cp -r queries $out - fi - runHook postInstall - ''; -} // removeAttrs args [ "language" "location" "generate" ]) + installPhase = '' + runHook preInstall + mkdir $out + mv parser $out/ + if [[ -d queries ]]; then + cp -r queries $out + fi + runHook postInstall + ''; + } + // removeAttrs args ["language" "location" "generate"]) diff --git a/devices/binto/modules/nvidia.nix b/devices/binto/modules/nvidia.nix index f893f0c7..91126c57 100644 --- a/devices/binto/modules/nvidia.nix +++ b/devices/binto/modules/nvidia.nix @@ -1,4 +1,8 @@ -{config, pkgs, ...}: { +{ + config, + pkgs, + ... +}: { # Enable OpenGL hardware.opengl = { enable = true; diff --git a/devices/wim/modules/desktop.nix b/devices/wim/modules/desktop.nix index b44dcac2..e93f9202 100644 --- a/devices/wim/modules/desktop.nix +++ b/devices/wim/modules/desktop.nix @@ -2,7 +2,7 @@ pkgs, config, ... -}: let +}: let user = config.services.device-vars.username; hyprland = config.home-manager.users.${user}.wayland.windowManager.hyprland.finalPackage; in { diff --git a/home/hyprland/default.nix b/home/hyprland/default.nix index c94dd20d..e9f882df 100644 --- a/home/hyprland/default.nix +++ b/home/hyprland/default.nix @@ -28,7 +28,8 @@ in { wayland.windowManager.hyprland = { enable = true; enableNvidiaPatches = isNvidia; - package = lib.mkIf (!isNvidia) + package = + lib.mkIf (!isNvidia) hyprland.packages.x86_64-linux.default; plugins = @@ -47,7 +48,7 @@ in { "$XDG_DATA_DIRS" ]}" ] - ++ (optionals (isNvidia) [ + ++ (optionals isNvidia [ "LIBVA_DRIVER_NAME, nvidia" "XDG_SESSION_TYPE, wayland" "GBM_BACKEND, nvidia-drm" diff --git a/modules/greetd/default.nix b/modules/greetd/default.nix index 7fbce671..38d83853 100644 --- a/modules/greetd/default.nix +++ b/modules/greetd/default.nix @@ -4,42 +4,43 @@ config, ... }: let + optionals = lib.lists.optionals; + isNvidia = config.hardware.nvidia.modesetting.enable; user = config.services.device-vars.username; - hyprBin = "${config.home-manager.users.${user}.wayland.windowManager.hyprland.finalPackage}/bin"; - nvidia = - if config.hardware.nvidia.modesetting.enable - then { - env = '' - env = LIBVA_DRIVER_NAME,nvidia - env = XDG_SESSION_TYPE,wayland - env = GBM_BACKEND,nvidia-drm - env = __GLX_VENDOR_LIBRARY_NAME,nvidia - env = WLR_NO_HARDWARE_CURSORS,1 - ''; - } - else { - env = ""; - }; + hyprBin = "${config.home-manager.users.${user} + .wayland.windowManager.hyprland.finalPackage}/bin"; regreetBin = "${lib.getExe config.programs.regreet.package}"; - gset = pkgs.gsettings-desktop-schemas; - css = pkgs.writeText "style.css" ''${builtins.readFile ./style.css}''; + style = pkgs.writeText "style.css" ''${builtins.readFile ./style.css}''; - hyprConf = pkgs.writeText "greetd-hypr-config" '' - exec-once = swww init --no-cache && swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png + setupMonitors = pkgs.writeShellScriptBin "setupMonitors" '' + names=($(${hyprBin}/hyprctl -j monitors | ${pkgs.jq}/bin/jq -r '.[] .name')) - ${builtins.readFile ./hyprland.conf} - - ${nvidia.env} - - # FIXME: kb doesn't work - env = XDG_DATA_DIRS, ${gset}/share/gsettings-schemas/${gset.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS - exec-once = squeekboard - exec-once = gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true - - exec-once = ${regreetBin} -s ${css}; ${hyprBin}/hyprctl dispatch exit + for (( i=1; i<''${#names[@]}; i++ )); do + ${hyprBin}/hyprctl keyword monitor ''${names[$i]},preferred,auto,1,mirror,''${names[0]} + done ''; + + hyprConf = + pkgs.writeText "greetd-hypr-config" + (lib.strings.concatStrings ((optionals isNvidia [ + "env = LIBVA_DRIVER_NAME,nvidia\n" + "env = XDG_SESSION_TYPE,wayland\n" + "env = GBM_BACKEND,nvidia-drm\n" + "env = __GLX_VENDOR_LIBRARY_NAME,nvidia\n" + "env = WLR_NO_HARDWARE_CURSORS,1\n" + ]) + ++ [ + "exec-once = ${setupMonitors}/bin/setupMonitors &&" + " swww init --no-cache &&" + " swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png\n" + + "${builtins.readFile ./hyprland.conf}\n" + + "exec-once = ${regreetBin} -s ${style};" + " ${hyprBin}/hyprctl dispatch exit" + ])); in { users.users.greeter = { packages = with pkgs; [ @@ -48,7 +49,6 @@ in { swww gtk3 glib - squeekboard ]; };