From f8b0000444663ade13d75e1e703bbad3cfdd1ce2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 29 Mar 2022 09:04:32 -0700 Subject: [PATCH] Initial --- .envrc | 5 +++ .gitignore | 3 ++ .gitmodules | 3 ++ flake.lock | 111 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 33 ++++++++++++++ nix/devshell.nix | 17 ++++++++ nix/overlay.nix | 14 ++++++ shell.nix | 9 ++++ vendor/mach-glfw | 1 + 9 files changed, 196 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/devshell.nix create mode 100644 nix/overlay.nix create mode 100644 shell.nix create mode 160000 vendor/mach-glfw diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..10eba288e --- /dev/null +++ b/.envrc @@ -0,0 +1,5 @@ +# If we are a computer with nix-shell available, then use that to setup +# the build environment with exactly what we need. +if has nix-shell; then + use nix +fi diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..5ffab5fc4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +zig-cache/ +zig-out/ +/result* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..d886933e2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/mach-glfw"] + path = vendor/mach-glfw + url = https://github.com/hexops/mach-glfw.git diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..5f058fc8c --- /dev/null +++ b/flake.lock @@ -0,0 +1,111 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1648199409, + "narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "64a525ee38886ab9028e6f61790de0832aa3ef03", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1648297722, + "narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1648219316, + "narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1631288242, + "narHash": "sha256-sXm4KiKs7qSIf5oTAmrlsEvBW193sFj+tKYVirBaXz0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0e24c87754430cb6ad2f8c8c8021b29834a8845e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "zig": "zig" + } + }, + "zig": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1648514449, + "narHash": "sha256-JRFuHkCPcZuzZG7/Jn1JRE9Yad4d6oa+r82Y9IlyFgk=", + "owner": "roarkanize", + "repo": "zig-overlay", + "rev": "bea2f952e65ce19ad0133ae4aa6ac225da6f0dfc", + "type": "github" + }, + "original": { + "owner": "roarkanize", + "repo": "zig-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..f93a852d7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "ghostty"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + zig.url = "github:roarkanize/zig-overlay"; + + # Used for shell.nix + flake-compat = { url = github:edolstra/flake-compat; flake = false; }; + }; + + outputs = { self, nixpkgs, flake-utils, ... }@inputs: + let + overlays = [ + # Our repo overlay + (import ./nix/overlay.nix) + + # Other overlays + (final: prev: { + zigpkgs = inputs.zig.packages.${prev.system}; + }) + ]; + + # 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; + } + ); +} diff --git a/nix/devshell.nix b/nix/devshell.nix new file mode 100644 index 000000000..4a7530fb1 --- /dev/null +++ b/nix/devshell.nix @@ -0,0 +1,17 @@ +{ mkShell + +, pkg-config +, scdoc +, zig +}: mkShell rec { + name = "ghostty"; + + nativeBuildInputs = [ + pkg-config + scdoc + zig + ]; + + buildInputs = [ + ]; +} diff --git a/nix/overlay.nix b/nix/overlay.nix new file mode 100644 index 000000000..2939823b7 --- /dev/null +++ b/nix/overlay.nix @@ -0,0 +1,14 @@ +final: prev: rec { + # Notes: + # + # When determining a SHA256, use this to set a fake one until we know + # the real value: + # + # vendorSha256 = nixpkgs.lib.fakeSha256; + # + + devShell = prev.callPackage ./devshell.nix { }; + + # zig we want to be the latest nightly since 0.9.0 is not released yet. + zig = final.zigpkgs.master.latest; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..7e231b715 --- /dev/null +++ b/shell.nix @@ -0,0 +1,9 @@ +(import + ( + let flake-compat = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat; in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${flake-compat.locked.rev}.tar.gz"; + sha256 = flake-compat.locked.narHash; + } + ) + { src = ./.; }).shellNix diff --git a/vendor/mach-glfw b/vendor/mach-glfw new file mode 160000 index 000000000..fe72a5d53 --- /dev/null +++ b/vendor/mach-glfw @@ -0,0 +1 @@ +Subproject commit fe72a5d53188fe5016f96d2c519c604f9550e542