forked from ghostty-org/ghostty
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
151 lines (133 loc) · 4.75 KB
/
flake.nix
File metadata and controls
151 lines (133 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
{
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";
flake-utils.url = "github:numtide/flake-utils";
# Used for shell.nix
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
zig = {
url = "github:mitchellh/zig-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
flake-compat.follows = "flake-compat";
};
};
zon2nix = {
url = "github:jcollie/zon2nix?rev=c28e93f3ba133d4c1b1d65224e2eebede61fd071";
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});
in {
devShell = forAllPlatforms (pkgs:
pkgs.callPackage ./nix/devShell.nix {
zig = zig.packages.${pkgs.stdenv.hostPlatform.system}."0.15.2";
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 {};
};
};
});
packages =
forAllPlatforms (pkgs: {
# Deps are needed for environmental setup on macOS
deps = pkgs.callPackage ./build.zig.zon.nix {};
})
// forBuildablePlatforms (pkgs: let
mkArgs = optimize: {
inherit optimize;
revision = self.shortRev or self.dirtyShortRev or "dirty";
};
in rec {
ghostty-debug = pkgs.callPackage ./nix/package.nix (mkArgs "Debug");
ghostty-releasesafe = pkgs.callPackage ./nix/package.nix (mkArgs "ReleaseSafe");
ghostty-releasefast = pkgs.callPackage ./nix/package.nix (mkArgs "ReleaseFast");
ghostty = ghostty-releasefast;
default = ghostty;
});
formatter = forAllPlatforms (pkgs: pkgs.alejandra);
apps = forBuildablePlatforms (pkgs: let
runVM = module: desc: 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 = self.packages.${prev.stdenv.hostPlatform.system}.ghostty-releasefast;
};
debug = final: prev: {
ghostty = self.packages.${prev.stdenv.hostPlatform.system}.ghostty-debug;
};
};
};
nixConfig = {
extra-substituters = ["https://ghostty.cachix.org"];
extra-trusted-public-keys = ["ghostty.cachix.org-1:QB389yTa6gTyneehvqG58y0WnHjQOqgnA+wBnpWWxns="];
};
}