nix: Fix gpu-lib/wayland binary patching on nix package (#16958)

Also, includes some cleanup -- adds missing flake-compat input and
aligns the nix build module with how nixpkgs does it.

Release Notes:

- Fixed an issue on NixOS package where the wrong binaries were being
patched, leading to missing Wayland libs when launching Zed
This commit is contained in:
jvmncs 2024-08-27 12:24:42 -04:00 committed by GitHub
parent 1f0b7d45ff
commit ff26abdc2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 29 deletions

29
flake.lock generated
View file

@ -28,11 +28,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1724480904, "lastModified": 1724740262,
"narHash": "sha256-puBjYiWZMu/VhDk5ZQW88o/IlwsYuoqvCglOESolyBc=", "narHash": "sha256-cpFasbzOTlwLi4fNas6hDznVUdCJn/lMLxi7MAMG6hg=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "dba5ef499c684acae11a2661d0ed45017fe75b71", "rev": "703efdd9b5c6a7d5824afa348a24fbbf8ff226be",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -45,23 +45,24 @@
"locked": { "locked": {
"lastModified": 1696426674, "lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57, "type": "github"
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
}, },
"original": { "original": {
"type": "tarball", "owner": "edolstra",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" "repo": "flake-compat",
"type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1724224976, "lastModified": 1724479785,
"narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=", "narHash": "sha256-pP3Azj5d6M5nmG68Fu4JqZmdGt4S4vqI5f8te+E/FTw=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c374d94f1536013ca8e92341b540eba4c22f9c62", "rev": "d0e1602ddde669d5beb01aec49d71a51937ed7be",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -82,11 +83,11 @@
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1724436261, "lastModified": 1724666781,
"narHash": "sha256-N6p1Qd7qgIATJz61JXAqV/rd8umeg0Uj1IawJCTdDlU=", "narHash": "sha256-nOQDgjTDlWe0/+Ptf3o2p6UrznQFHnXBHRV1ZAsSpe8=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "ab34fdd9f3367d1761991f78e3a7006a4d8d2b34", "rev": "095926ea6f008477a15a2ec6b0b8797e2e5be0e5",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -11,7 +11,7 @@
url = "github:ipetkov/crane"; url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
flake-compat.url = "github:edolstra/flake-compat";
}; };
outputs = { outputs = {
@ -32,8 +32,11 @@
in { in {
packages = forAllSystems (pkgs: let packages = forAllSystems (pkgs: let
craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.fenix.stable.toolchain); craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.fenix.stable.toolchain);
rustPlatform = pkgs.makeRustPlatform {
inherit (pkgs.fenix.stable.toolchain) cargo rustc;
};
nightlyBuild = pkgs.callPackage ./nix/build.nix { nightlyBuild = pkgs.callPackage ./nix/build.nix {
inherit craneLib; inherit craneLib rustPlatform;
}; };
in { in {
zed-editor = nightlyBuild; zed-editor = nightlyBuild;
@ -46,9 +49,12 @@
formatter = forAllSystems (pkgs: pkgs.alejandra); formatter = forAllSystems (pkgs: pkgs.alejandra);
overlays.default = final: _prev: { overlays.default = final: prev: {
zed-editor = final.callPackage ./nix/build.nix { zed-editor = final.callPackage ./nix/build.nix {
craneLib = (crane.mkLib final).overrideToolchain (p: p.fenix.stable.toolchain); craneLib = (crane.mkLib final).overrideToolchain (p: p.fenix.stable.toolchain);
rustPlatform = final.makeRustPlatform {
inherit (final.fenix.stable.toolchain) cargo rustc;
};
}; };
}; };
}; };

View file

@ -1,6 +1,7 @@
{ {
lib, lib,
craneLib, craneLib,
rustPlatform,
clang, clang,
llvmPackages_18, llvmPackages_18,
mold-wrapped, mold-wrapped,
@ -48,6 +49,17 @@
// { // {
inherit src stdenv; inherit src stdenv;
nativeBuildInputs = [
clang
copyDesktopItems
curl
mold-wrapped
perl
pkg-config
protobuf
rustPlatform.bindgenHook
];
buildInputs = [ buildInputs = [
curl curl
fontconfig fontconfig
@ -57,22 +69,13 @@
sqlite sqlite
zlib zlib
zstd zstd
alsa-lib alsa-lib
libxkbcommon libxkbcommon
wayland wayland
xorg.libxcb xorg.libxcb
]; ];
nativeBuildInputs = [
clang
copyDesktopItems
curl
mold-wrapped
perl
pkg-config
protobuf
];
ZSTD_SYS_USE_PKG_CONFIG = true; ZSTD_SYS_USE_PKG_CONFIG = true;
FONTCONFIG_FILE = makeFontsConf { FONTCONFIG_FILE = makeFontsConf {
fontDirectories = [ fontDirectories = [
@ -103,8 +106,8 @@
else ""; else "";
postFixup = '' postFixup = ''
patchelf --add-rpath ${gpu-lib}/lib $out/bin/* patchelf --add-rpath ${gpu-lib}/lib $out/libexec/*
patchelf --add-rpath ${wayland}/lib $out/bin/* patchelf --add-rpath ${wayland}/lib $out/libexec/*
''; '';
postInstall = '' postInstall = ''