This repository has no description
1{
2 description = "👻";
3
4 inputs = {
5 # We want to stay as up to date as possible but need to be careful that the
6 # glibc versions used by our dependencies from Nix are compatible with the
7 # system glibc that the user is building for.
8 #
9 # We are currently on nixpkgs-unstable to get Zig 0.15 for our package.nix and
10 # Gnome 49/Gtk 4.20.
11 #
12 nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
13
14 # Used for shell.nix
15 flake-compat = {
16 url = "github:edolstra/flake-compat";
17 flake = false;
18 };
19
20 systems = {
21 url = "github:nix-systems/default";
22 flake = false;
23 };
24
25 zig = {
26 url = "github:mitchellh/zig-overlay";
27 inputs = {
28 nixpkgs.follows = "nixpkgs";
29 flake-compat.follows = "flake-compat";
30 systems.follows = "systems";
31 };
32 };
33
34 zon2nix = {
35 url = "github:jcollie/zon2nix?ref=main";
36 inputs = {
37 nixpkgs.follows = "nixpkgs";
38 };
39 };
40
41 home-manager = {
42 url = "github:nix-community/home-manager";
43 inputs = {
44 nixpkgs.follows = "nixpkgs";
45 };
46 };
47 };
48
49 outputs = {
50 self,
51 nixpkgs,
52 zig,
53 zon2nix,
54 home-manager,
55 ...
56 }: let
57 inherit (nixpkgs) lib legacyPackages;
58
59 # Our supported systems are the same supported systems as the Zig binaries.
60 platforms = lib.attrNames zig.packages;
61
62 # It's not always possible to build Ghostty with Nix for each system,
63 # one such example being macOS due to missing Swift 6 and xcodebuild
64 # support in the Nix ecosystem. Therefore for things like package outputs
65 # we need to limit the attributes we expose.
66 buildablePlatforms = lib.filter (p: !(lib.systems.elaborate p).isDarwin) platforms;
67
68 forAllPlatforms = f: lib.genAttrs platforms (s: f legacyPackages.${s});
69 forBuildablePlatforms = f: lib.genAttrs buildablePlatforms (s: f legacyPackages.${s});
70
71 mkPkgArgs = optimize: {
72 inherit optimize;
73 revision = self.shortRev or self.dirtyShortRev or "dirty";
74 };
75 in {
76 devShells = forAllPlatforms (pkgs: {
77 default = pkgs.callPackage ./nix/devShell.nix {
78 zig =
79 if pkgs.stdenv.hostPlatform.isDarwin
80 then zig.packages.${pkgs.stdenv.hostPlatform.system}.brew."0.15.2"
81 else zig.packages.${pkgs.stdenv.hostPlatform.system}."0.15.2";
82 wraptest = pkgs.callPackage ./nix/pkgs/wraptest.nix {};
83 zon2nix = zon2nix;
84
85 python3 = pkgs.python3.override {
86 self = pkgs.python3;
87 packageOverrides = pyfinal: pyprev: {
88 blessed = pyfinal.callPackage ./nix/pkgs/blessed.nix {};
89 ucs-detect = pyfinal.callPackage ./nix/pkgs/ucs-detect.nix {};
90 wcwidth = pyfinal.callPackage ./nix/pkgs/wcwidth.nix {};
91 };
92 };
93 };
94 });
95
96 packages =
97 builtins.foldl'
98 lib.recursiveUpdate
99 {}
100 [
101 (
102 forAllPlatforms (pkgs: rec {
103 # Deps are needed for environmental setup on macOS
104 deps = pkgs.callPackage ./build.zig.zon.nix {};
105
106 libghostty-vt-debug = pkgs.callPackage ./nix/libghostty-vt.nix (mkPkgArgs "Debug");
107 libghostty-vt-releasesafe = pkgs.callPackage ./nix/libghostty-vt.nix (mkPkgArgs "ReleaseSafe");
108 libghostty-vt-releasefast = pkgs.callPackage ./nix/libghostty-vt.nix (mkPkgArgs "ReleaseFast");
109 libghostty-vt-debug-no-simd = pkgs.callPackage ./nix/libghostty-vt.nix ((mkPkgArgs "Debug") // {simd = false;});
110 libghostty-vt-releasesafe-no-simd = pkgs.callPackage ./nix/libghostty-vt.nix ((mkPkgArgs "ReleaseSafe") // {simd = false;});
111 libghostty-vt-releasefast-no-simd = pkgs.callPackage ./nix/libghostty-vt.nix ((mkPkgArgs "ReleaseFast") // {simd = false;});
112
113 libghostty-vt = libghostty-vt-releasefast;
114 })
115 )
116 (
117 forBuildablePlatforms (pkgs: rec {
118 ghostty-debug = pkgs.callPackage ./nix/package.nix (mkPkgArgs "Debug");
119 ghostty-releasesafe = pkgs.callPackage ./nix/package.nix (mkPkgArgs "ReleaseSafe");
120 ghostty-releasefast = pkgs.callPackage ./nix/package.nix (mkPkgArgs "ReleaseFast");
121
122 ghostty = ghostty-releasefast;
123 default = ghostty;
124 })
125 )
126 ];
127
128 formatter = forAllPlatforms (pkgs: pkgs.alejandra);
129
130 apps = forBuildablePlatforms (pkgs: let
131 runVM = module: let
132 vm = import ./nix/vm/create.nix {
133 inherit (pkgs.stdenv.hostPlatform) system;
134 inherit module nixpkgs;
135 overlay = self.overlays.debug;
136 };
137 program = pkgs.writeShellScript "run-ghostty-vm" ''
138 SHARED_DIR=$(pwd)
139 export SHARED_DIR
140
141 ${pkgs.lib.getExe vm.config.system.build.vm} "$@"
142 '';
143 in {
144 type = "app";
145 program = "${program}";
146 meta.description = "start a vm from ${toString module}";
147 };
148 in {
149 wayland-cinnamon = runVM ./nix/vm/wayland-cinnamon.nix;
150 wayland-gnome = runVM ./nix/vm/wayland-gnome.nix;
151 wayland-plasma6 = runVM ./nix/vm/wayland-plasma6.nix;
152 x11-cinnamon = runVM ./nix/vm/x11-cinnamon.nix;
153 x11-plasma6 = runVM ./nix/vm/x11-plasma6.nix;
154 x11-xfce = runVM ./nix/vm/x11-xfce.nix;
155 });
156
157 checks = forAllPlatforms (pkgs:
158 import ./nix/tests.nix {
159 inherit home-manager nixpkgs self;
160 inherit (pkgs.stdenv.hostPlatform) system;
161 });
162
163 overlays = {
164 default = self.overlays.releasefast;
165 releasefast = final: prev: {
166 ghostty = final.callPackage ./nix/package.nix (mkPkgArgs "ReleaseFast");
167 };
168 debug = final: prev: {
169 ghostty = final.callPackage ./nix/package.nix (mkPkgArgs "Debug");
170 };
171 };
172 };
173
174 nixConfig = {
175 extra-substituters = ["https://ghostty.cachix.org"];
176 extra-trusted-public-keys = ["ghostty.cachix.org-1:QB389yTa6gTyneehvqG58y0WnHjQOqgnA+wBnpWWxns="];
177 };
178}