From e9de44475e821595c6ef51335f910f8592cddc8b Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sun, 17 Mar 2024 11:47:32 -0500 Subject: [PATCH] allow building nix package with different optimizations --- flake.nix | 14 +++++++++++++- nix/package.nix | 15 ++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index 0536b52470..ad7d4da173 100644 --- a/flake.nix +++ b/flake.nix @@ -53,10 +53,22 @@ }; packages.${system} = rec { - ghostty = pkgs-stable.callPackage ./nix/package.nix { + ghostty-debug = pkgs-stable.callPackage ./nix/package.nix { inherit (pkgs-zig-0-12) zig_0_12; revision = self.shortRev or self.dirtyShortRev or "dirty"; + optimize = "Debug"; }; + ghostty-releasesafe = pkgs-stable.callPackage ./nix/package.nix { + inherit (pkgs-zig-0-12) zig_0_12; + revision = self.shortRev or self.dirtyShortRev or "dirty"; + optimize = "ReleaseSafe"; + }; + ghostty-releasefast = pkgs-stable.callPackage ./nix/package.nix { + inherit (pkgs-zig-0-12) zig_0_12; + revision = self.shortRev or self.dirtyShortRev or "dirty"; + optimize = "ReleaseFast"; + }; + ghostty = ghostty-releasesafe; default = ghostty; }; diff --git a/nix/package.nix b/nix/package.nix index dee192b120..b638831da4 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -25,6 +25,7 @@ zig_0_12, pandoc, revision ? "dirty", + optimize ? "Debug", }: let # The Zig hook has no way to select the release type without actual # overriding of the default flags. @@ -34,7 +35,7 @@ # ultimately acted on and has made its way to a nixpkgs implementation, this # can probably be removed in favor of that. zig012Hook = zig_0_12.hook.overrideAttrs { - zig_default_flags = "-Dcpu=baseline -Doptimize=ReleaseFast"; + zig_default_flags = "-Dcpu=baseline -Doptimize=${optimize}"; }; # This hash is the computation of the zigCache fixed-output derivation. This @@ -132,18 +133,6 @@ in chmod u+rwX -R $ZIG_GLOBAL_CACHE_DIR ''; - buildPhase = '' - runHook preBuild - zig build -Dcpu=baseline -Doptimize=ReleaseSafe -Dversion-string=${finalAttrs.version}-${revision}-nix - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - zig build install -Dcpu=baseline -Doptimize=ReleaseSafe -Dversion-string=${finalAttrs.version}-${revision}-nix --prefix $out - runHook postInstall - ''; - outputs = ["out" "terminfo" "shell_integration"]; postInstall = ''