Last active
March 11, 2025 00:56
-
-
Save diamondburned/b9252476c1ce295e453dc815b888d974 to your computer and use it in GitHub Desktop.
Run gotk4 programs using the system's Nixpkgs because Nix Flakes sucks!!!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eo pipefail | |
NIX_EXPR=$(cat <<-'EOF' | |
{ | |
mainProgram, | |
}: | |
let | |
pkgs = import <nixpkgs> { }; | |
in | |
pkgs.stdenv.mkDerivation { | |
name = "${mainProgram}-wrapped"; | |
src = ./. + "/${mainProgram}"; | |
dontUnpack = true; | |
buildInputs = with pkgs; [ | |
gtk4 | |
glib | |
libadwaita | |
librsvg | |
gdk-pixbuf | |
gobject-introspection | |
hicolor-icon-theme | |
gtksourceview4 | |
gtksourceview5 | |
libspelling | |
gst_all_1.gstreamer | |
gst_all_1.gst-plugins-good | |
gst_all_1.gst-plugins-bad | |
gst_all_1.gst-plugins-ugly | |
]; | |
nativeBuildInputs = with pkgs; [ | |
wrapGAppsHook | |
autoPatchelfHook | |
]; | |
sourceRoot = "."; | |
buildPhase = '' | |
mkdir -p \ | |
$out/bin | |
install -Dm755 "$src" "$out/bin/${mainProgram}" | |
''; | |
} | |
EOF | |
) | |
if [[ "$1" == shell ]]; then | |
nix-shell -E "$NIX_EXPR" --argstr mainProgram "" --run bash | |
else | |
mainProgram="${1:-$(basename "$PWD")}" | |
out=$(nix-build -E "$NIX_EXPR" --argstr mainProgram "${mainProgram}" --no-out-link) | |
exec "${out}/bin/${mainProgram}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment