mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-31 20:59:02 +00:00
This commit represents the majority of the work necessary to upgrade Ghostty to use Zig 0.16.0. Key parts: * In addition to its previous responsibilities, the global state now houses state for global I/O implementations and the process environment. It is now also utilized in the main application along with the C library. Where necessary, global state is isolated from key parts of the implementation (e.g., in libghostty subsystems), and it's expected that this list will grow. * We currently manage our own C translation layer where necessary. In these cases, cImport has been removed in favor of the new external translate-c package. Due to fixes that have needed be made to properly translate the dependencies that were swapped out, as mentioned, we have had to backport fixes from the current translate-c package (and the upstream Arocc dependency). We will host this ourselves until Zig 0.17.0 is released with these fixes. * Where necessary (only a small number of cases), some stdlib code from 0.15.2 (and even from 0.17.0) has been taken, adopted, and vendored in lib/compat. Co-authored-by: Leah Amelia Chen <hi@pluie.me>
198 lines
6.6 KiB
Nix
198 lines
6.6 KiB
Nix
{
|
|
description = "👻";
|
|
|
|
inputs = {
|
|
# We want to stay as up to date as possible but need to be careful that the
|
|
# glibc versions used by our dependencies from Nix are compatible with the
|
|
# system glibc that the user is building for.
|
|
#
|
|
# We are currently on nixpkgs-unstable to get Zig 0.15 for our package.nix and
|
|
# Gnome 49/Gtk 4.20.
|
|
#
|
|
nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
|
|
|
|
# Used for shell.nix
|
|
flake-compat = {
|
|
url = "github:edolstra/flake-compat";
|
|
flake = false;
|
|
};
|
|
|
|
systems = {
|
|
url = "github:nix-systems/default";
|
|
flake = false;
|
|
};
|
|
|
|
zig = {
|
|
url = "github:mitchellh/zig-overlay";
|
|
inputs = {
|
|
nixpkgs.follows = "nixpkgs";
|
|
flake-compat.follows = "flake-compat";
|
|
systems.follows = "systems";
|
|
};
|
|
};
|
|
|
|
zon2nix = {
|
|
url = "github:jcollie/zon2nix?ref=main";
|
|
inputs = {
|
|
nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
home-manager = {
|
|
url = "github:nix-community/home-manager";
|
|
inputs = {
|
|
nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
zig,
|
|
zon2nix,
|
|
home-manager,
|
|
...
|
|
}: let
|
|
inherit (nixpkgs) lib legacyPackages;
|
|
|
|
# Our supported systems are the same supported systems as the Zig binaries.
|
|
platforms = lib.attrNames zig.packages;
|
|
|
|
# It's not always possible to build Ghostty with Nix for each system,
|
|
# one such example being macOS due to missing Swift 6 and xcodebuild
|
|
# support in the Nix ecosystem. Therefore for things like package outputs
|
|
# we need to limit the attributes we expose.
|
|
buildablePlatforms = lib.filter (p: !(lib.systems.elaborate p).isDarwin) platforms;
|
|
|
|
forAllPlatforms = f: lib.genAttrs platforms (s: f legacyPackages.${s});
|
|
forBuildablePlatforms = f: lib.genAttrs buildablePlatforms (s: f legacyPackages.${s});
|
|
|
|
mkPkgArgs = optimize: {
|
|
inherit optimize;
|
|
revision = self.shortRev or self.dirtyShortRev or "dirty";
|
|
};
|
|
in {
|
|
devShells = forAllPlatforms (pkgs: {
|
|
default =
|
|
pkgs.callPackage ./nix/devShell.nix
|
|
(let
|
|
libfyaml =
|
|
if pkgs.stdenv.hostPlatform.isDarwin
|
|
then
|
|
pkgs.libfyaml.overrideAttrs (prev: {
|
|
# Manually fix libfyaml.pc until NixOS/nixpkgs#515614 is available
|
|
postInstall =
|
|
(prev.postInstall or "")
|
|
+ ''
|
|
substituteInPlace "$dev/lib/pkgconfig/libfyaml.pc" \
|
|
--replace-fail " none required" ""
|
|
'';
|
|
})
|
|
else pkgs.libfyaml;
|
|
|
|
appstream = pkgs.appstream.override {libfyaml = libfyaml;};
|
|
libadwaita = pkgs.libadwaita.override {appstream = appstream;};
|
|
blueprint-compiler = pkgs.blueprint-compiler.override {libadwaita = libadwaita;};
|
|
in {
|
|
zig = zig.packages.${pkgs.stdenv.hostPlatform.system}."0.16.0";
|
|
wraptest = pkgs.callPackage ./nix/pkgs/wraptest.nix {};
|
|
zon2nix = zon2nix;
|
|
|
|
python3 = pkgs.python3.override {
|
|
self = pkgs.python3;
|
|
packageOverrides = pyfinal: pyprev: {
|
|
blessed = pyfinal.callPackage ./nix/pkgs/blessed.nix {};
|
|
ucs-detect = pyfinal.callPackage ./nix/pkgs/ucs-detect.nix {};
|
|
wcwidth = pyfinal.callPackage ./nix/pkgs/wcwidth.nix {};
|
|
};
|
|
};
|
|
|
|
inherit appstream libadwaita blueprint-compiler;
|
|
});
|
|
});
|
|
|
|
packages =
|
|
builtins.foldl'
|
|
lib.recursiveUpdate
|
|
{}
|
|
[
|
|
(
|
|
forAllPlatforms (pkgs: rec {
|
|
# Deps are needed for environmental setup on macOS
|
|
deps = pkgs.callPackage ./build.zig.zon.nix {};
|
|
|
|
libghostty-vt-debug = pkgs.callPackage ./nix/libghostty-vt.nix (mkPkgArgs "Debug");
|
|
libghostty-vt-releasesafe = pkgs.callPackage ./nix/libghostty-vt.nix (mkPkgArgs "ReleaseSafe");
|
|
libghostty-vt-releasefast = pkgs.callPackage ./nix/libghostty-vt.nix (mkPkgArgs "ReleaseFast");
|
|
libghostty-vt-debug-no-simd = pkgs.callPackage ./nix/libghostty-vt.nix ((mkPkgArgs "Debug") // {simd = false;});
|
|
libghostty-vt-releasesafe-no-simd = pkgs.callPackage ./nix/libghostty-vt.nix ((mkPkgArgs "ReleaseSafe") // {simd = false;});
|
|
libghostty-vt-releasefast-no-simd = pkgs.callPackage ./nix/libghostty-vt.nix ((mkPkgArgs "ReleaseFast") // {simd = false;});
|
|
|
|
libghostty-vt = libghostty-vt-releasefast;
|
|
})
|
|
)
|
|
(
|
|
forBuildablePlatforms (pkgs: rec {
|
|
ghostty-debug = pkgs.callPackage ./nix/package.nix (mkPkgArgs "Debug");
|
|
ghostty-releasesafe = pkgs.callPackage ./nix/package.nix (mkPkgArgs "ReleaseSafe");
|
|
ghostty-releasefast = pkgs.callPackage ./nix/package.nix (mkPkgArgs "ReleaseFast");
|
|
|
|
ghostty = ghostty-releasefast;
|
|
default = ghostty;
|
|
})
|
|
)
|
|
];
|
|
|
|
formatter = forAllPlatforms (pkgs: pkgs.alejandra);
|
|
|
|
apps = forBuildablePlatforms (pkgs: let
|
|
runVM = module: let
|
|
vm = import ./nix/vm/create.nix {
|
|
inherit (pkgs.stdenv.hostPlatform) system;
|
|
inherit module nixpkgs;
|
|
overlay = self.overlays.debug;
|
|
};
|
|
program = pkgs.writeShellScript "run-ghostty-vm" ''
|
|
SHARED_DIR=$(pwd)
|
|
export SHARED_DIR
|
|
|
|
${pkgs.lib.getExe vm.config.system.build.vm} "$@"
|
|
'';
|
|
in {
|
|
type = "app";
|
|
program = "${program}";
|
|
meta.description = "start a vm from ${toString module}";
|
|
};
|
|
in {
|
|
wayland-cinnamon = runVM ./nix/vm/wayland-cinnamon.nix;
|
|
wayland-gnome = runVM ./nix/vm/wayland-gnome.nix;
|
|
wayland-plasma6 = runVM ./nix/vm/wayland-plasma6.nix;
|
|
x11-cinnamon = runVM ./nix/vm/x11-cinnamon.nix;
|
|
x11-plasma6 = runVM ./nix/vm/x11-plasma6.nix;
|
|
x11-xfce = runVM ./nix/vm/x11-xfce.nix;
|
|
});
|
|
|
|
checks = forAllPlatforms (pkgs:
|
|
import ./nix/tests.nix {
|
|
inherit home-manager nixpkgs self;
|
|
inherit (pkgs.stdenv.hostPlatform) system;
|
|
});
|
|
|
|
overlays = {
|
|
default = self.overlays.releasefast;
|
|
releasefast = final: prev: {
|
|
ghostty = final.callPackage ./nix/package.nix (mkPkgArgs "ReleaseFast");
|
|
};
|
|
debug = final: prev: {
|
|
ghostty = final.callPackage ./nix/package.nix (mkPkgArgs "Debug");
|
|
};
|
|
};
|
|
};
|
|
|
|
nixConfig = {
|
|
extra-substituters = ["https://ghostty.cachix.org"];
|
|
extra-trusted-public-keys = ["ghostty.cachix.org-1:QB389yTa6gTyneehvqG58y0WnHjQOqgnA+wBnpWWxns="];
|
|
};
|
|
}
|