refactor(nix): specify source

this should reduce the amount of rebuilds that need to occur that due to
the souce changing invalidating the cache

also note that a update to nixpkgs-stable had to occur such that the new
lib functions existed
This commit is contained in:
isabel
2024-06-21 15:17:43 +01:00
parent 89fa275eeb
commit a73e0183d3
3 changed files with 92 additions and 52 deletions

66
flake.lock generated
View File

@ -3,11 +3,11 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1673956053, "lastModified": 1696426674,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -33,12 +33,15 @@
} }
}, },
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1705309234,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -49,7 +52,7 @@
}, },
"flake-utils_2": { "flake-utils_2": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems_2"
}, },
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1710146030,
@ -67,7 +70,7 @@
}, },
"flake-utils_3": { "flake-utils_3": {
"inputs": { "inputs": {
"systems": "systems_2" "systems": "systems_3"
}, },
"locked": { "locked": {
"lastModified": 1705309234, "lastModified": 1705309234,
@ -118,27 +121,27 @@
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1702049175, "lastModified": 1718955215,
"narHash": "sha256-c/q2+tGHbmLgzT3sXyUKVJR98h1CTks2+nkVaoZPRM0=", "narHash": "sha256-3vNXv4zrblZFobrxz1P3RwLpHl6X3/GzfArdTxq0+nI=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b15508bd65870620f1df5864e8e861dffbc4e428", "rev": "201ed88e66f7f34d5c74e46d2e4399cc4bea1501",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "release-23.05", "ref": "release-24.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1713687659, "lastModified": 1718870667,
"narHash": "sha256-Yd8KuOBpZ0Slau/NxFhMPJI0gBxeax0vq/FD0rqKwuQ=", "narHash": "sha256-jab3Kpc8O1z3qxwVsCMHL4+18n5Wy/HHKyu1fcsF7gs=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f2d7a289c5a5ece8521dd082b81ac7e4a57c2c5c", "rev": "9b10b8f00cb5494795e5f51b39210fed4d2b0748",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -186,6 +189,21 @@
"type": "github" "type": "github"
} }
}, },
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"zig": { "zig": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
@ -195,11 +213,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1713659103, "lastModified": 1718929454,
"narHash": "sha256-WgWH0HPGsxd7Ov5M4Ug7qjmxbTeG8517xO6hY3198tU=", "narHash": "sha256-lh7877nXtLucRmiJFrgJsND9iduZEX1I0HZ8VUHhGYA=",
"owner": "mitchellh", "owner": "mitchellh",
"repo": "zig-overlay", "repo": "zig-overlay",
"rev": "a13735003a235a2e4e202b47277129f99bfc9294", "rev": "16b1b7e06642c9fa72f978e4c7e8561466f06ca8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -218,11 +236,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1717848532, "lastModified": 1718539737,
"narHash": "sha256-d+xIUvSTreHl8pAmU1fnmkfDTGQYCn2Rb/zOwByxS2M=", "narHash": "sha256-hvQ900gSqzGnJWMRQwv65TixciIbC44iX0Nh5ENRwCU=",
"owner": "mitchellh", "owner": "mitchellh",
"repo": "zig-overlay", "repo": "zig-overlay",
"rev": "02fc5cc555fc14fda40c42d7c3250efa43812b43", "rev": "6eb42ce6f85d247b1aecf854c45d80902821d0ad",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -242,11 +260,11 @@
"zig-overlay": "zig-overlay" "zig-overlay": "zig-overlay"
}, },
"locked": { "locked": {
"lastModified": 1717891972, "lastModified": 1718930611,
"narHash": "sha256-VyLdi6nZPMeQ431uKqJpQ01kwtmUQqYKgpvUdgSZ+DM=", "narHash": "sha256-FtfVhs6XHNfSQRQorrrz03nD0LCNp2FCnGllRntHBts=",
"owner": "zigtools", "owner": "zigtools",
"repo": "zls", "repo": "zls",
"rev": "c5ceadf362df07aa40b657db166bf6229a5ea1c5", "rev": "0b9746b60c2020ab948f6556f1c729858b82a0f0",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -7,7 +7,7 @@
# We want to stay as up to date as possible but need to be careful that the # 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 # glibc versions used by our dependencies from Nix are compatible with the
# system glibc that the user is building for. # system glibc that the user is building for.
nixpkgs-stable.url = "github:nixos/nixpkgs/release-23.05"; nixpkgs-stable.url = "github:nixos/nixpkgs/release-24.05";
zig = { zig = {
url = "github:mitchellh/zig-overlay"; url = "github:mitchellh/zig-overlay";

View File

@ -38,6 +38,27 @@
zig_default_flags = "-Dcpu=baseline -Doptimize=${optimize}"; zig_default_flags = "-Dcpu=baseline -Doptimize=${optimize}";
}; };
# We limit source like this to try and reduce the amount of rebuilds as possible
# thus we only provide the source that is needed for the build
#
# NOTE: as of the current moment only linux files are provided,
# since darwin support is not finished
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.intersection (lib.fileset.fromSource (lib.sources.cleanSource ../.)) (
lib.fileset.unions [
../dist/linux
../conformance
../images
../pkg
../src
../vendor
../build.zig
../build.zig.zon
]
);
};
# This hash is the computation of the zigCache fixed-output derivation. This # This hash is the computation of the zigCache fixed-output derivation. This
# allows us to use remote package dependencies without breaking the sandbox. # allows us to use remote package dependencies without breaking the sandbox.
# #
@ -52,11 +73,13 @@
# derivation in your store already. If so, just update the value as above.) # derivation in your store already. If so, just update the value as above.)
zigCacheHash = import ./zigCacheHash.nix; zigCacheHash = import ./zigCacheHash.nix;
zigCache = src: zigCache = stdenv.mkDerivation {
stdenv.mkDerivation {
inherit src; inherit src;
name = "ghostty-cache"; name = "ghostty-cache";
nativeBuildInputs = [git zig_0_12.hook]; nativeBuildInputs = [
git
zig_0_12.hook
];
dontConfigure = true; dontConfigure = true;
dontUseZigBuild = true; dontUseZigBuild = true;
@ -86,8 +109,7 @@ in
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
pname = "ghostty"; pname = "ghostty";
version = "0.1.0"; version = "0.1.0";
inherit src;
src = ./..;
nativeBuildInputs = [ nativeBuildInputs = [
git git
@ -129,7 +151,7 @@ in
preBuild = '' preBuild = ''
rm -rf $ZIG_GLOBAL_CACHE_DIR rm -rf $ZIG_GLOBAL_CACHE_DIR
cp -r --reflink=auto ${zigCache finalAttrs.src} $ZIG_GLOBAL_CACHE_DIR cp -r --reflink=auto ${zigCache} $ZIG_GLOBAL_CACHE_DIR
chmod u+rwX -R $ZIG_GLOBAL_CACHE_DIR chmod u+rwX -R $ZIG_GLOBAL_CACHE_DIR
''; '';
@ -159,9 +181,9 @@ in
patchelf --add-rpath "${lib.makeLibraryPath [libX11]}" "$out/bin/.ghostty-wrapped" patchelf --add-rpath "${lib.makeLibraryPath [libX11]}" "$out/bin/.ghostty-wrapped"
''; '';
meta = with lib; { meta = {
homepage = "https://github.com/ghostty-org/ghostty"; homepage = "https://github.com/ghostty-org/ghostty";
license = licenses.mit; license = lib.licenses.mit;
platforms = ["x86_64-linux" "aarch64-linux"]; platforms = ["x86_64-linux" "aarch64-linux"];
mainProgram = "ghostty"; mainProgram = "ghostty";
}; };