ghostty-flake/flake.nix

72 lines
2.4 KiB
Nix

{
description = "Ghostty AppImage";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
# actual versions
upstreamVersion = "1.2.0";
appimageVersion = "v1.2.0";
# tip is harder to get to, and looks like this:
# upstreamVersion = "1.1.4-main+b58a761";
# appimageVersion = "tip";
exename = "ghostty";
mkGhostty = system:
let
pkgs = import nixpkgs { inherit system; };
arch = if system == "x86_64-linux" then "x86_64" else "aarch64";
appimagename = "Ghostty-${upstreamVersion}-${arch}.AppImage";
in pkgs.stdenv.mkDerivation {
pname = "ghostty";
version = appimageVersion;
src = pkgs.fetchurl {
# temporary fix for nvidia proprietary drivers
# See https://github.com/pkgforge-dev/ghostty-appimage/pull/95
url = if system == "x86_64-linux" then
"https://git.lerch.org/api/packages/lobo/generic/ghostty-appimage/1.2.0/Ghostty-1.2.0-x86_64.AppImage"
else
"https://git.lerch.org/api/packages/lobo/generic/ghostty-appimage/1.2.0/Ghostty-1.2.0-aarch64.AppImage";
#url = "https://github.com/psadi/ghostty-appimage/releases/download/${appimageVersion}/${appimagename}";
hash = if system == "x86_64-linux" then
"sha256-E78tVBzSfoc+xZ2HKy0gAmmCwSxI+idIvZrg9wsJ4rc="
else
"sha256-3j7yGUCkvGErlYTS6njkuoSaqgKtFvNZ4/RWlx3B7Fc=";
};
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [ pkgs.appimage-run ];
dontUnpack = true;
installPhase = ''
mkdir -p $out/bin $out/share/applications
# We do this so that nix won't try to do it's wrapper stuff needed for nix os
cp $src $out/share/${exename}
chmod +x $out/share/${exename}
cat > $out/share/applications/Ghostty.desktop <<EOF
[Desktop Entry]
Name=Ghostty
Exec=$out/bin/${exename}
Type=Application
Categories=Utility;
Terminal=false;
EOF
ln -s "$out/share/${exename}" "$out/bin/${exename}"
'';
};
in {
packages = {
x86_64-linux.default = mkGhostty "x86_64-linux";
aarch64-linux.default = mkGhostty "aarch64-linux";
};
};
}