From ed50e158fab0927e3724258a3b8949046c3b9f6a Mon Sep 17 00:00:00 2001 From: Christian Harke Date: Thu, 12 Jan 2023 08:42:08 +0100 Subject: [PATCH] Add nixGL wrapper lib function --- flake/per-system.nix | 21 +++++++++++++++++---- home/roles/desktop/alacritty/default.nix | 12 ++++-------- home/roles/web/nextcloud-client/default.nix | 8 +++++--- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/flake/per-system.nix b/flake/per-system.nix index 7844cec7..72d4fc9b 100644 --- a/flake/per-system.nix +++ b/flake/per-system.nix @@ -32,7 +32,7 @@ let overlays = [ (final: prev: { - inherit unstable nixgl nur; + inherit unstable nur; inherit (inputs.agenix-cli.packages."${system}") agenix-cli; inherit (inputs.kmonad.packages."${system}") kmonad; @@ -44,9 +44,22 @@ let inherit config overlays system; }; - customLib = inputs.flake-commons.lib { - inherit (inputs.nixpkgs) lib; - inherit pkgs rootPath; + customLib = inputs.flake-commons.lib + { + inherit (inputs.nixpkgs) lib; + inherit pkgs rootPath; + } // { + nixGLWrap = pkg: pkgs.runCommand "${pkg.name}-nixgl-wrapper" { } '' + mkdir $out + ln -s ${pkg}/* $out + rm $out/bin + mkdir $out/bin + for bin in ${pkg}/bin/*; do + wrapped_bin=$out/bin/$(basename $bin) + echo "exec ${pkgs.lib.getExe nixgl.nixgl.auto.nixGLDefault} $bin \"\$@\"" > $wrapped_bin + chmod +x $wrapped_bin + done + ''; }; machNix = inputs.mach-nix.lib."${system}"; diff --git a/home/roles/desktop/alacritty/default.nix b/home/roles/desktop/alacritty/default.nix index e19686e6..ea389e1c 100644 --- a/home/roles/desktop/alacritty/default.nix +++ b/home/roles/desktop/alacritty/default.nix @@ -41,6 +41,10 @@ in programs.alacritty = { enable = true; + package = + if config.custom.base.non-nixos.enable + then (hiPrio (config.lib.custom.nixGLWrap pkgs.alacritty)) + else pkgs.alacritty; settings = { env.TERM = "xterm-256color"; window = { @@ -99,13 +103,5 @@ in ]; }; }; - } // mkIf config.custom.base.non-nixos.enable { - custom.roles.desktop.alacritty.spawnCmd = "nixGL alacritty"; - - home = { - packages = with pkgs; [ - nixgl.nixgl.auto.nixGLDefault - ]; }; - }; } diff --git a/home/roles/web/nextcloud-client/default.nix b/home/roles/web/nextcloud-client/default.nix index 167779a3..4aff9ae6 100644 --- a/home/roles/web/nextcloud-client/default.nix +++ b/home/roles/web/nextcloud-client/default.nix @@ -5,6 +5,10 @@ with lib; let cfg = config.custom.roles.web.nextcloud-client; + pkg = + if config.custom.base.non-nixos.enable + then (config.lib.custom.nixGLWrap pkgs.nextcloud-client) + else pkgs.nextcloud-client; in @@ -16,9 +20,7 @@ in }; config = mkIf cfg.enable { - home.packages = [ - pkgs.nextcloud-client - ]; + home.packages = [ pkg ]; services.nextcloud-client = { enable = true;