ghostty-flake/flake.nix
2025-01-31 16:57:34 -08:00

59 lines
1.8 KiB
Nix

{
description = "Ghostty AppImage";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
upstreamVersion = "1.1.0";
appimageVersion = "v1.1.0+1";
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 {
url = "https://github.com/psadi/ghostty-appimage/releases/download/${appimageVersion}/${appimagename}";
hash = if system == "x86_64-linux" then "sha256-B7YH8hfsPzpjdXcUTfo3dxj8xNFL8LZnHjEzinnf7M0=" else "sha256-Obn6PfQIsHQn6y4M20tqvWfw22TvoT4jEo181KGzEQs=";
};
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";
};
};
}