diff --git a/README.md b/README.md index 0d4f31de4..4f25bef7c 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ beta users using Ghostty as their primary terminal. See more in | ------------------ | ------------------------------------------------------------------------ | -------------------------- | | macOS | [Tip ("Nightly")](https://github.com/mitchellh/ghostty/releases/tag/tip) | MacOS 12+ Universal Binary | | Linux | [Build from Source](#developing-ghostty) | | +| Linux (NixOS/Nix) | [Use the Flake](#nix-package) | | | Windows | [Build from Source](#developing-ghostty) | [Notes](#windows-notes) | ### Configuration @@ -505,50 +506,42 @@ Make sure your Prettier version matches the version of in [devshell.nix](https:/ ### Nix Package -> [!WARNING] -> The Nix package currently depends on versions of LLVM and Zig that are -> currently not in cache.nixos.org and will be built from source. This can take -> a very long time, especially in situations where CPU is at a premium. Most -> people should follow the instructions in [Developing -> Ghostty](#developing-ghostty) instead. +There is Nix package that can be used in the flake (`packages.ghostty` or `packages.default`). +It can be used in NixOS configurations and otherwise built off of. -There is a functional Nix package that can be used in the `flake.nix` file -(`packages.ghostty`). It can be used in NixOS configurations and otherwise -built off of (however, please heed the above warning). - -Below is a sample on how to add it to a NixOS overlay: +Below is an example: ```nix { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - # NOTE: This will require your git SSH access to the repo + # NOTE: This will require your git SSH access to the repo. + # + # WARNING: Do NOT pin the `nixpkgs` input, as that will + # declare the cache useless. If you do, you will have + # to compile LLVM, Zig and Ghostty itself on your machine, + # which will take a very very long time. ghostty = { url = "git+ssh://git@github.com/mitchellh/ghostty"; - inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { nixpkgs, ghostty, ... }: { - nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + nixosConfigurations.mysystem = nixpkgs.lib.nixosSystem { modules = [ { - nixpkgs.overlays = [ - (final: prev: { - ghostty = ghostty.packages.${prev.system}.ghostty; - }) + environment.systemPackages = [ + ghostty.packages.x86_64-linux.default ]; } - - # Other modules here... ]; }; }; } ``` -You can also test the build of the nix package at any time by running `nix build .` +You can also test the build of the nix package at any time by running `nix build .`. #### Updating the Zig Cache Fixed-Output Derivation Hash @@ -567,5 +560,5 @@ To update it, you can run the following in the repository root: ./nix/build-support/check-zig-cache-hash.sh --update ``` -This will write out the `nix/zig_cache_hash.nix` file with the updated hash +This will write out the `nix/zigCacheHash.nix` file with the updated hash that can then be committed and pushed to fix the builds. diff --git a/flake.lock b/flake.lock index 046409e95..d99077202 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1648199409, - "narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "owner": "edolstra", "repo": "flake-compat", - "rev": "64a525ee38886ab9028e6f61790de0832aa3ef03", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { @@ -32,38 +32,7 @@ "type": "github" } }, - "flake-compat_3": { - "flake": false, - "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-utils": { - "locked": { - "lastModified": 1656065134, - "narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -78,7 +47,7 @@ "type": "github" } }, - "flake-utils_3": { + "flake-utils_2": { "inputs": { "systems": "systems" }, @@ -96,7 +65,7 @@ "type": "github" } }, - "flake-utils_4": { + "flake-utils_3": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -114,7 +83,7 @@ "gitignore": { "inputs": { "nixpkgs": [ - "zls-master", + "zls", "nixpkgs" ] }, @@ -144,13 +113,13 @@ "url": "https://raw.githubusercontent.com/ziglang/zig/63bd2bff12992aef0ce23ae4b344e9cb5d65f05d/doc/langref.html.in" } }, - "nixpkgs": { + "nixpkgs-stable": { "locked": { - "lastModified": 1691950488, - "narHash": "sha256-iUNEeudc4dGjx+HsHccnGiuZUVE/nhjXuQ1DVCsHIUY=", + "lastModified": 1702049175, + "narHash": "sha256-c/q2+tGHbmLgzT3sXyUKVJR98h1CTks2+nkVaoZPRM0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "720e61ed8de116eec48d6baea1d54469b536b985", + "rev": "b15508bd65870620f1df5864e8e861dffbc4e428", "type": "github" }, "original": { @@ -192,47 +161,13 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1689088367, - "narHash": "sha256-Y2tl2TlKCWEHrOeM9ivjCLlRAKH3qoPUE/emhZECU14=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5c9ddb86679c400d6b7360797b8a22167c2053f8", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "release-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1701336116, - "narHash": "sha256-kEmpezCR/FpITc6yMbAh4WrOCiT2zg5pSjnKrq51h5Y=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f5c27c6136db4d76c30e533c20517df6864c46ee", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable", "nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-zig-0-12": "nixpkgs-zig-0-12", "zig": "zig", - "zls-master": "zls-master" + "zls": "zls" } }, "systems": { @@ -252,9 +187,11 @@ }, "zig": { "inputs": { - "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2" + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs-stable" + ] }, "locked": { "lastModified": 1701908568, @@ -272,10 +209,10 @@ }, "zig-overlay": { "inputs": { - "flake-compat": "flake-compat_3", - "flake-utils": "flake-utils_4", + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_3", "nixpkgs": [ - "zls-master", + "zls", "nixpkgs" ] }, @@ -293,12 +230,14 @@ "type": "github" } }, - "zls-master": { + "zls": { "inputs": { - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_2", "gitignore": "gitignore", "langref": "langref", - "nixpkgs": "nixpkgs_3", + "nixpkgs": [ + "nixpkgs-stable" + ], "zig-overlay": "zig-overlay" }, "locked": { diff --git a/flake.nix b/flake.nix index b1411652b..af1891f43 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,13 @@ { - description = "ghostty"; + description = "👻"; inputs = { nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - zig.url = "github:mitchellh/zig-overlay"; - zls-master.url = "github:zigtools/zls/master"; + + # 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. + nixpkgs-stable.url = "github:nixos/nixpkgs/release-23.05"; # This is a nixpkgs mirror (based off of nixos-unstable) that contains # patches for LLVM 17 and Zig 0.12 (master/nightly). @@ -17,54 +19,44 @@ # devShell) to build a Zig that can be included in a NixOS configuration. nixpkgs-zig-0-12.url = "github:vancluever/nixpkgs/vancluever-zig-0-12"; - # 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. - nixpkgs.url = "github:nixos/nixpkgs/release-23.05"; + zig = { + url = "github:mitchellh/zig-overlay"; + inputs.nixpkgs.follows = "nixpkgs-stable"; + }; - # Used for shell.nix - flake-compat = { url = github:edolstra/flake-compat; flake = false; }; + zls = { + url = "github:zigtools/zls/master"; + inputs.nixpkgs.follows = "nixpkgs-stable"; + }; }; - outputs = { self, nixpkgs, flake-utils, ... }@inputs: - let - overlays = [ - # Our repo overlay - (import ./nix/overlay.nix) + outputs = { + nixpkgs-unstable + , nixpkgs-stable + , nixpkgs-zig-0-12 + , zig + , zls + , ... + }: builtins.foldl' nixpkgs-stable.lib.recursiveUpdate {} (builtins.map (system: let + pkgs-stable = nixpkgs-stable.legacyPackages.${system}; + pkgs-unstable = nixpkgs-unstable.legacyPackages.${system}; + pkgs-zig-0-12 = nixpkgs-zig-0-12.legacyPackages.${system}; + in { + devShell.${system} = pkgs-stable.callPackage ./nix/devShell.nix { + inherit (pkgs-unstable) tracy; + inherit (zls.packages.${system}) zls; - # Other overlays - (final: prev: { - zigpkgs = inputs.zig.packages.${prev.system}; + zig = zig.packages.${system}.master; + wraptest = pkgs-stable.callPackage ./nix/wraptest.nix {}; + }; - zig_0_12 = inputs.nixpkgs-zig-0-12.legacyPackages.${prev.system}.zig_0_12; + packages.${system} = rec { + ghostty = pkgs-stable.callPackage ./nix/package.nix { + inherit (pkgs-zig-0-12) zig_0_12; + }; + default = ghostty; + }; - # Latest version of Tracy - tracy = inputs.nixpkgs-unstable.legacyPackages.${prev.system}.tracy; - - # Latest version of ZLS - zls = inputs.zls-master.packages.${prev.system}.zls; - }) - ]; - - # Our supported systems are the same supported systems as the Zig binaries - systems = builtins.attrNames inputs.zig.packages; - in - flake-utils.lib.eachSystem systems (system: - let pkgs = import nixpkgs { inherit overlays system; }; - in rec { - devShell = pkgs.devShell; - - # NOTE: using packages.ghostty right out of the flake currently - # requires a build of LLVM 17 and Zig master from source. This will - # take quite a bit of time. Until LLVM 17 and an upcoming Zig 0.12 are - # up in nixpkgs, most folks will want to continue to use the devShell - # and the instructions found at: - # - # https://github.com/mitchellh/ghostty/tree/main#developing-ghostty - # - packages.ghostty = pkgs.ghostty; - packages.default = packages.ghostty; - defaultPackage = packages.ghostty; - } - ); + # Our supported systems are the same supported systems as the Zig binaries. + }) (builtins.attrNames zig.packages)); } diff --git a/garnix.yaml b/garnix.yaml new file mode 100644 index 000000000..0fff899d6 --- /dev/null +++ b/garnix.yaml @@ -0,0 +1,6 @@ +builds: + exclude: [] + include: + - "*.aarch64-darwin.*" + - "*.aarch64-linux.*" + - "*.x86_64-linux.*" diff --git a/nix/build-support/check-zig-cache-hash.sh b/nix/build-support/check-zig-cache-hash.sh index 8c02e237b..26669b008 100755 --- a/nix/build-support/check-zig-cache-hash.sh +++ b/nix/build-support/check-zig-cache-hash.sh @@ -3,15 +3,15 @@ # Nothing in this script should fail. set -e -CACHE_HASH_FILE="$(realpath "$(dirname "$0")/../zig_cache_hash.nix")" +CACHE_HASH_FILE="$(realpath "$(dirname "$0")/../zigCacheHash.nix")" help() { echo "" echo "To fix, please (manually) re-run the script from the repository root," echo "commit, and push the update:" echo "" - echo " ./nix/build-support/check-zig-cache-hash.sh --update" - echo " git add nix/zig_cache_hash.nix" + echo " ./nix/build-support/check-zigCacheHash.sh --update" + echo " git add nix/zigCacheHash.nix" echo " git commit -m \"nix: update Zig cache hash\"" echo " git push" echo "" @@ -52,7 +52,7 @@ fi # Write out the cache file cat > "${CACHE_HASH_FILE}" <