feat(greetd): mirror regreet on all monitors

This commit is contained in:
matt1432 2023-11-25 17:13:46 -05:00
parent 5d59e27097
commit 3a3c8457da
5 changed files with 89 additions and 83 deletions

View file

@ -1,62 +1,63 @@
{ stdenv {
, nodejs stdenv,
, tree-sitter nodejs,
, lib tree-sitter,
lib,
}: }:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/parsing/tree-sitter/grammar.nix # 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` # Build a parser grammar and put the resulting shared object in `$out/parser`
{ {
# language name # language name
language language,
, version version,
, src src,
, location ? null location ? null,
, generate ? false generate ? false,
, ... ...
}@args: } @ args:
stdenv.mkDerivation ({ 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" ]; CFLAGS = ["-Isrc" "-O2"];
CXXFLAGS = [ "-Isrc" "-O2" ]; CXXFLAGS = ["-Isrc" "-O2"];
stripDebugList = [ "parser" ]; stripDebugList = ["parser"];
configurePhase = lib.optionalString (location != null) '' configurePhase =
cd ${location} lib.optionalString (location != null) ''
'' + lib.optionalString generate '' cd ${location}
tree-sitter generate ''
''; + 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 # 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. # different languages. Just randomly prefer C++ if that happens.
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
if [[ -e src/scanner.cc ]]; then if [[ -e src/scanner.cc ]]; then
$CXX -fPIC -c src/scanner.cc -o scanner.o $CXXFLAGS $CXX -fPIC -c src/scanner.cc -o scanner.o $CXXFLAGS
elif [[ -e src/scanner.c ]]; then elif [[ -e src/scanner.c ]]; then
$CC -fPIC -c src/scanner.c -o scanner.o $CFLAGS $CC -fPIC -c src/scanner.c -o scanner.o $CFLAGS
fi fi
$CC -fPIC -c src/parser.c -o parser.o $CFLAGS $CC -fPIC -c src/parser.c -o parser.o $CFLAGS
rm -rf parser rm -rf parser
$CXX -shared -o parser *.o $CXX -shared -o parser *.o
runHook postBuild runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir $out mkdir $out
mv parser $out/ mv parser $out/
if [[ -d queries ]]; then if [[ -d queries ]]; then
cp -r queries $out cp -r queries $out
fi fi
runHook postInstall runHook postInstall
''; '';
} // removeAttrs args [ "language" "location" "generate" ]) }
// removeAttrs args ["language" "location" "generate"])

View file

@ -1,4 +1,8 @@
{config, pkgs, ...}: { {
config,
pkgs,
...
}: {
# Enable OpenGL # Enable OpenGL
hardware.opengl = { hardware.opengl = {
enable = true; enable = true;

View file

@ -2,7 +2,7 @@
pkgs, pkgs,
config, config,
... ...
}: let }: let
user = config.services.device-vars.username; user = config.services.device-vars.username;
hyprland = config.home-manager.users.${user}.wayland.windowManager.hyprland.finalPackage; hyprland = config.home-manager.users.${user}.wayland.windowManager.hyprland.finalPackage;
in { in {

View file

@ -28,7 +28,8 @@ in {
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
enable = true; enable = true;
enableNvidiaPatches = isNvidia; enableNvidiaPatches = isNvidia;
package = lib.mkIf (!isNvidia) package =
lib.mkIf (!isNvidia)
hyprland.packages.x86_64-linux.default; hyprland.packages.x86_64-linux.default;
plugins = plugins =
@ -47,7 +48,7 @@ in {
"$XDG_DATA_DIRS" "$XDG_DATA_DIRS"
]}" ]}"
] ]
++ (optionals (isNvidia) [ ++ (optionals isNvidia [
"LIBVA_DRIVER_NAME, nvidia" "LIBVA_DRIVER_NAME, nvidia"
"XDG_SESSION_TYPE, wayland" "XDG_SESSION_TYPE, wayland"
"GBM_BACKEND, nvidia-drm" "GBM_BACKEND, nvidia-drm"

View file

@ -4,42 +4,43 @@
config, config,
... ...
}: let }: let
optionals = lib.lists.optionals;
isNvidia = config.hardware.nvidia.modesetting.enable;
user = config.services.device-vars.username; user = config.services.device-vars.username;
hyprBin = "${config.home-manager.users.${user}.wayland.windowManager.hyprland.finalPackage}/bin";
nvidia = hyprBin = "${config.home-manager.users.${user}
if config.hardware.nvidia.modesetting.enable .wayland.windowManager.hyprland.finalPackage}/bin";
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 = "";
};
regreetBin = "${lib.getExe config.programs.regreet.package}"; 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" '' setupMonitors = pkgs.writeShellScriptBin "setupMonitors" ''
exec-once = swww init --no-cache && swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png names=($(${hyprBin}/hyprctl -j monitors | ${pkgs.jq}/bin/jq -r '.[] .name'))
${builtins.readFile ./hyprland.conf} for (( i=1; i<''${#names[@]}; i++ )); do
${hyprBin}/hyprctl keyword monitor ''${names[$i]},preferred,auto,1,mirror,''${names[0]}
${nvidia.env} done
# 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
''; '';
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 { in {
users.users.greeter = { users.users.greeter = {
packages = with pkgs; [ packages = with pkgs; [
@ -48,7 +49,6 @@ in {
swww swww
gtk3 gtk3
glib glib
squeekboard
]; ];
}; };