From 70a04d448c0ffda9ff8eb5f3f1f10bee525f940c Mon Sep 17 00:00:00 2001 From: 7elia <176603882+7elia@users.noreply.github.com> Date: Wed, 24 Jun 2026 00:42:41 +0200 Subject: [PATCH 1/6] feat(nix): start mac support --- flake.nix | 75 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/flake.nix b/flake.nix index 0535b04..4ab2cfb 100644 --- a/flake.nix +++ b/flake.nix @@ -5,28 +5,59 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = { - self, - nixpkgs, - }: let - # Spotify only ships on this so it's fine - system = "x86_64-linux"; - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - }; - in { - devShells.${system} = { - default = pkgs.callPackage ./nix/shell.nix {inherit self;}; - }; + outputs = + { + self, + nixpkgs, + }: + let + systems = [ + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + forEachSystem = nixpkgs.lib.genAttrs systems; + in + { + devShells = forEachSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + in + { - packages.${system} = { - cef = pkgs.callPackage ./nix/cef.nix {}; - extendify-native = pkgs.callPackage ./nix/native.nix {inherit self;}; - spotify-extendify = pkgs.callPackage ./nix/spotify-extendify.nix {inherit self;}; - default = self.packages.${system}.spotify-extendify; - }; + default = pkgs.callPackage ./nix/shell.nix { inherit self; }; + } + ); - formatter.${system} = pkgs.callPackage ./nix/fmt.nix {}; - }; + packages = forEachSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + in + { + cef = pkgs.callPackage ./nix/cef.nix { }; + extendify-native = pkgs.callPackage ./nix/native.nix { inherit self; }; + spotify-extendify = pkgs.callPackage ./nix/spotify-extendify.nix { inherit self; }; + default = self.packages.${system}.spotify-extendify; + } + ); + + formatter = forEachSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + in + pkgs.callPackage ./nix/fmt.nix { } + ); + }; } From 987f88991149681250d469efb86735f4271164f3 Mon Sep 17 00:00:00 2001 From: 7elia <176603882+7elia@users.noreply.github.com> Date: Thu, 2 Jul 2026 18:15:01 +0200 Subject: [PATCH 2/6] feat(mac): more work --- crates/extendify-native/src/unix/dyld.rs | 47 ++++++++ crates/extendify-native/src/unix/mod.rs | 5 + nix/cef.nix | 137 ++++++++++++++++++++++- nix/native.nix | 8 +- nix/spotify-extendify.nix | 10 +- 5 files changed, 196 insertions(+), 11 deletions(-) create mode 100644 crates/extendify-native/src/unix/dyld.rs diff --git a/crates/extendify-native/src/unix/dyld.rs b/crates/extendify-native/src/unix/dyld.rs new file mode 100644 index 0000000..5ddede9 --- /dev/null +++ b/crates/extendify-native/src/unix/dyld.rs @@ -0,0 +1,47 @@ +#[allow(unused_macros)] +macro_rules! extern_c_overrides { + (unsafe fn $c_api:ident/$real_api:ident($($param_name:ident : $param_type:ty),*) -> $return_type:ty $override_body:block $($more_tokens:tt)*) => { + + pub unsafe fn $real_api($($param_name: $param_type),*) -> $return_type { + use std::ffi::{c_char, c_void}; + use std::sync::OnceLock; + + unsafe extern "C" { + fn dlsym(handle: *const c_void, symbol: *const c_char) -> *const c_void; + } + + #[allow(non_camel_case_types)] + type $c_api = unsafe fn($($param_type),*) -> $return_type; + + #[allow(non_upper_case_globals)] + static _dl_resolver: OnceLock<$c_api> = OnceLock::new(); + + let real_fn = _dl_resolver.get_or_init(|| { + unsafe { + const RTLD_NEXT: *const c_void = -1isize as *const c_void; + let sym = dlsym( + RTLD_NEXT, + concat!(stringify!($c_api), "\0").as_ptr() as *const c_char, + ); + if sym.is_null() { + panic!("dlsym(RTLD_NEXT): cannot find {}", stringify!($c_api)); + } + core::mem::transmute(sym) + } + }); + + unsafe { real_fn($($param_name),*) } + } + + #[unsafe(no_mangle)] + pub unsafe extern "C" fn $c_api($($param_name: $param_type),*) -> $return_type { + unsafe { + let $c_api = $real_api; + $override_body + } + } + + extern_c_overrides! { $($more_tokens)* } + }; + () => {}; +} diff --git a/crates/extendify-native/src/unix/mod.rs b/crates/extendify-native/src/unix/mod.rs index b4d3393..44c7e9c 100644 --- a/crates/extendify-native/src/unix/mod.rs +++ b/crates/extendify-native/src/unix/mod.rs @@ -7,8 +7,13 @@ use crate::cef::{ use crate::{log, vtable_hooks}; #[macro_use] +#[cfg(target_os = "linux")] mod preload; +#[macro_use] +#[cfg(target_os = "macos")] +mod dyld; + extern_c_overrides! { unsafe fn cef_browser_view_create/real_cef_browser_view_create( client: *mut _cef_client_t, diff --git a/nix/cef.nix b/nix/cef.nix index 2e84727..4cc1677 100644 --- a/nix/cef.nix +++ b/nix/cef.nix @@ -1,10 +1,135 @@ { - cef-binary, + lib, stdenv, + fetchurl, + glib ? null, + nss ? null, + nspr ? null, + atk ? null, + at-spi2-atk ? null, + libdrm ? null, + expat ? null, + libxkbcommon ? null, + libgbm ? null, + gtk3 ? null, + pango ? null, + cairo ? null, + alsa-lib ? null, + dbus ? null, + at-spi2-core ? null, + cups ? null, + libGL ? null, + udev ? null, + systemdLibs ? null, + libxrandr ? null, + libxfixes ? null, + libxext ? null, + libxdamage ? null, + libxcomposite ? null, + libx11 ? null, + libxshmfence ? null, + libxcb ? null, + + version ? "144.0.11", + gitRevision ? "e135be2", + chromiumVersion ? "144.0.7559.97", + buildType ? "Release", + srcHashes ? { + aarch64-linux = "sha256-almKJ18g//Wi2CDRX1yibODvR6TF0DlUl1EnDNlIHBY="; + aarch64-darwin = "sha256-Q94fht0yAkwAIqv29I1ZkpaS7WiYvJIcHWFcmBSvqHw="; + x86_64-darwin = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + }, }: -cef-binary.override { - version = "144.0.11"; - gitRevision = "e135be2"; - chromiumVersion = "144.0.7559.97"; - srcHashes.${stdenv.hostPlatform.system} = "sha256-almKJ18g//Wi2CDRX1yibODvR6TF0DlUl1EnDNlIHBY="; + +let + isLinux = stdenv.hostPlatform.isLinux; + + selectSystem = + attrs: + attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system ${stdenv.hostPlatform.system}"); + + platformString = selectSystem { + aarch64-linux = "linuxarm64"; + x86_64-linux = "linux64"; + aarch64-darwin = "macosarm64"; + x86_64-darwin = "macosx64"; + }; + + linuxRpath = lib.optionalString isLinux ( + lib.makeLibraryPath [ + glib + nss + nspr + atk + at-spi2-atk + libdrm + expat + libxkbcommon + libgbm + gtk3 + pango + cairo + alsa-lib + dbus + at-spi2-core + cups + libGL + udev + systemdLibs + libxcb + libx11 + libxcomposite + libxdamage + libxext + libxfixes + libxrandr + libxshmfence + ] + ); + glRpath = lib.optionalString isLinux (lib.makeLibraryPath [ stdenv.cc.cc ]); +in + +stdenv.mkDerivation { + pname = "cef-binary"; + inherit version; + + src = fetchurl { + url = "https://cef-builds.spotifycdn.com/cef_binary_${version}+g${gitRevision}+chromium-${chromiumVersion}_${platformString}_minimal.tar.bz2"; + hash = selectSystem srcHashes; + }; + + dontStrip = true; + dontPatchELF = true; + + installPhase = + if isLinux then + '' + runHook preInstall + sed 's/-O0/-O2/' -i cmake/cef_variables.cmake + patchelf --set-rpath "${linuxRpath}" --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" ${buildType}/chrome-sandbox + patchelf --add-needed libudev.so --set-rpath "${linuxRpath}" ${buildType}/libcef.so + patchelf --set-rpath "${glRpath}" ${buildType}/libEGL.so + patchelf --add-needed libGL.so.1 --set-rpath "${glRpath}" ${buildType}/libGLESv2.so + patchelf --set-rpath "${glRpath}" ${buildType}/libvk_swiftshader.so + patchelf --set-rpath "${glRpath}" ${buildType}/libvulkan.so.1 + cp --recursive . $out + runHook postInstall + '' + else + '' + runHook preInstall + sed 's/-O0/-O2/' -i cmake/cef_variables.cmake + cp --recursive . $out + runHook postInstall + ''; + + passthru.buildType = buildType; + + meta = { + description = "Simple framework for embedding Chromium-based browsers in other applications"; + homepage = "https://cef-builds.spotifycdn.com/index.html"; + license = lib.licenses.bsd3; + platforms = builtins.attrNames srcHashes; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; } diff --git a/nix/native.nix b/nix/native.nix index 2ece199..7ed6d76 100644 --- a/nix/native.nix +++ b/nix/native.nix @@ -44,7 +44,11 @@ rustPlatform.buildRustPackage { homepage = "https://github.com/extendify-mod/extendify"; # wtf is the license # license = lib.licenses.gpl3; - maintainers = [lib.maintainers.fazzi]; - platforms = ["x86_64-linux"]; + maintainers = [ lib.maintainers.fazzi ]; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; }; } diff --git a/nix/spotify-extendify.nix b/nix/spotify-extendify.nix index c9b0bcc..995ce7c 100644 --- a/nix/spotify-extendify.nix +++ b/nix/spotify-extendify.nix @@ -15,7 +15,7 @@ symlinkJoin { self.packages.${stdenv.hostPlatform.system}.extendify-native ]; - buildInputs = [makeWrapper]; + buildInputs = [ makeWrapper ]; postBuild = '' wrapProgram $out/bin/spotify \ @@ -28,7 +28,11 @@ symlinkJoin { homepage = "https://github.com/extendify-mod/extendify"; # wtf is the license # license = lib.licenses.gpl3; - maintainers = [lib.maintainers.fazzi]; - platforms = ["x86_64-linux"]; + maintainers = [ lib.maintainers.fazzi ]; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; }; } From 620e809fa98dfdb6fb6a4711b76ca1ea60c8e51f Mon Sep 17 00:00:00 2001 From: 7elia <176603882+7elia@users.noreply.github.com> Date: Wed, 24 Jun 2026 00:42:41 +0200 Subject: [PATCH 3/6] feat(nix): start mac support --- flake.nix | 97 +++++++++++------------ nix/cef.nix | 159 +++++++++----------------------------- nix/native.nix | 2 +- nix/spotify-extendify.nix | 63 ++++++++------- 4 files changed, 119 insertions(+), 202 deletions(-) diff --git a/flake.nix b/flake.nix index 4ab2cfb..2353843 100644 --- a/flake.nix +++ b/flake.nix @@ -5,59 +5,50 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = - { - self, - nixpkgs, - }: - let - systems = [ - "x86_64-linux" - "aarch64-darwin" - "x86_64-darwin" - ]; - forEachSystem = nixpkgs.lib.genAttrs systems; - in - { - devShells = forEachSystem ( - system: - let - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - }; - in - { + outputs = { + self, + nixpkgs, + }: let + systems = [ + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + forEachSystem = nixpkgs.lib.genAttrs systems; + in { + devShells = forEachSystem ( + system: let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + in { + default = pkgs.callPackage ./nix/shell.nix {inherit self;}; + } + ); - default = pkgs.callPackage ./nix/shell.nix { inherit self; }; - } - ); + packages = forEachSystem ( + system: let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + in { + cef = pkgs.callPackage ./nix/cef.nix {}; + extendify-native = pkgs.callPackage ./nix/native.nix {inherit self;}; + spotify-extendify = pkgs.callPackage ./nix/spotify-extendify.nix {inherit self;}; + default = self.packages.${system}.spotify-extendify; + } + ); - packages = forEachSystem ( - system: - let - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - }; - in - { - cef = pkgs.callPackage ./nix/cef.nix { }; - extendify-native = pkgs.callPackage ./nix/native.nix { inherit self; }; - spotify-extendify = pkgs.callPackage ./nix/spotify-extendify.nix { inherit self; }; - default = self.packages.${system}.spotify-extendify; - } - ); - - formatter = forEachSystem ( - system: - let - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - }; - in - pkgs.callPackage ./nix/fmt.nix { } - ); - }; + formatter = forEachSystem ( + system: let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + in + pkgs.callPackage ./nix/fmt.nix {} + ); + }; } diff --git a/nix/cef.nix b/nix/cef.nix index 4cc1677..d7d0352 100644 --- a/nix/cef.nix +++ b/nix/cef.nix @@ -1,51 +1,10 @@ { - lib, - stdenv, + cef-binary, fetchurl, - glib ? null, - nss ? null, - nspr ? null, - atk ? null, - at-spi2-atk ? null, - libdrm ? null, - expat ? null, - libxkbcommon ? null, - libgbm ? null, - gtk3 ? null, - pango ? null, - cairo ? null, - alsa-lib ? null, - dbus ? null, - at-spi2-core ? null, - cups ? null, - libGL ? null, - udev ? null, - systemdLibs ? null, - libxrandr ? null, - libxfixes ? null, - libxext ? null, - libxdamage ? null, - libxcomposite ? null, - libx11 ? null, - libxshmfence ? null, - libxcb ? null, - - version ? "144.0.11", - gitRevision ? "e135be2", - chromiumVersion ? "144.0.7559.97", - buildType ? "Release", - srcHashes ? { - aarch64-linux = "sha256-almKJ18g//Wi2CDRX1yibODvR6TF0DlUl1EnDNlIHBY="; - aarch64-darwin = "sha256-Q94fht0yAkwAIqv29I1ZkpaS7WiYvJIcHWFcmBSvqHw="; - x86_64-darwin = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; - }, -}: - -let - isLinux = stdenv.hostPlatform.isLinux; - - selectSystem = - attrs: + stdenv, + stdenvNoCC, +}: let + selectSystem = attrs: attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system ${stdenv.hostPlatform.system}"); platformString = selectSystem { @@ -55,81 +14,39 @@ let x86_64-darwin = "macosx64"; }; - linuxRpath = lib.optionalString isLinux ( - lib.makeLibraryPath [ - glib - nss - nspr - atk - at-spi2-atk - libdrm - expat - libxkbcommon - libgbm - gtk3 - pango - cairo - alsa-lib - dbus - at-spi2-core - cups - libGL - udev - systemdLibs - libxcb - libx11 - libxcomposite - libxdamage - libxext - libxfixes - libxrandr - libxshmfence - ] - ); - glRpath = lib.optionalString isLinux (lib.makeLibraryPath [ stdenv.cc.cc ]); -in - -stdenv.mkDerivation { - pname = "cef-binary"; - inherit version; - - src = fetchurl { - url = "https://cef-builds.spotifycdn.com/cef_binary_${version}+g${gitRevision}+chromium-${chromiumVersion}_${platformString}_minimal.tar.bz2"; - hash = selectSystem srcHashes; + version = "144.0.11"; + gitRevision = "e135be2"; + chromiumVersion = "144.0.7559.97"; + srcHashes = { + x86_64-linux = "sha256-almKJ18g//Wi2CDRX1yibODvR6TF0DlUl1EnDNlIHBY="; + aarch64-darwin = "sha256-Q94fht0yAkwAIqv29I1ZkpaS7WiYvJIcHWFcmBSvqHw="; }; - - dontStrip = true; - dontPatchELF = true; - - installPhase = - if isLinux then - '' - runHook preInstall - sed 's/-O0/-O2/' -i cmake/cef_variables.cmake - patchelf --set-rpath "${linuxRpath}" --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" ${buildType}/chrome-sandbox - patchelf --add-needed libudev.so --set-rpath "${linuxRpath}" ${buildType}/libcef.so - patchelf --set-rpath "${glRpath}" ${buildType}/libEGL.so - patchelf --add-needed libGL.so.1 --set-rpath "${glRpath}" ${buildType}/libGLESv2.so - patchelf --set-rpath "${glRpath}" ${buildType}/libvk_swiftshader.so - patchelf --set-rpath "${glRpath}" ${buildType}/libvulkan.so.1 - cp --recursive . $out - runHook postInstall - '' - else - '' - runHook preInstall - sed 's/-O0/-O2/' -i cmake/cef_variables.cmake - cp --recursive . $out - runHook postInstall +in + if stdenv.hostPlatform.isLinux + then + cef-binary.override { + inherit version gitRevision chromiumVersion srcHashes; + } + else if stdenv.hostPlatform.isDarwin + then + stdenvNoCC.mkDerivation { + name = "darwin-cef"; + + src = fetchurl { + url = "https://cef-builds.spotifycdn.com/cef_binary_${version}+g${gitRevision}+chromium-${chromiumVersion}_${platformString}_minimal.tar.bz2"; + hash = selectSystem srcHashes; + }; + + dontBuild = true; + dontConfigure = true; + + unpackPhase = '' + tar --strip-components=1 -xjf $src ''; - passthru.buildType = buildType; - - meta = { - description = "Simple framework for embedding Chromium-based browsers in other applications"; - homepage = "https://cef-builds.spotifycdn.com/index.html"; - license = lib.licenses.bsd3; - platforms = builtins.attrNames srcHashes; - sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; - }; -} + installPhase = '' + mkdir -p $out + cp -r ./* $out/ + ''; + } + else throw "Unsupported system: ${stdenv.hostPlatform.system}" diff --git a/nix/native.nix b/nix/native.nix index 7ed6d76..2401710 100644 --- a/nix/native.nix +++ b/nix/native.nix @@ -44,7 +44,7 @@ rustPlatform.buildRustPackage { homepage = "https://github.com/extendify-mod/extendify"; # wtf is the license # license = lib.licenses.gpl3; - maintainers = [ lib.maintainers.fazzi ]; + maintainers = [lib.maintainers.fazzi]; platforms = [ "x86_64-linux" "x86_64-darwin" diff --git a/nix/spotify-extendify.nix b/nix/spotify-extendify.nix index 995ce7c..c9863e8 100644 --- a/nix/spotify-extendify.nix +++ b/nix/spotify-extendify.nix @@ -5,34 +5,43 @@ makeWrapper, self, lib, -}: -symlinkJoin { - name = "spotify-extendify"; - inherit (spotify) version; +}: let + exe = + if stdenv.isDarwin + then "Applications/Spotify.app/MacOS/Spotify" + else "bin/spotify"; + preloadVar = + if stdenv.isDarwin + then "DYLD_INSERT_LIBRARIES" + else "LD_PRELOAD"; +in + symlinkJoin { + name = "spotify-extendify"; + inherit (spotify) version; - paths = [ - spotify - self.packages.${stdenv.hostPlatform.system}.extendify-native - ]; + paths = [ + spotify + self.packages.${stdenv.hostPlatform.system}.extendify-native + ]; - buildInputs = [ makeWrapper ]; + buildInputs = [makeWrapper]; - postBuild = '' - wrapProgram $out/bin/spotify \ - --set LD_PRELOAD $out/lib/libextendify_native.so - ''; + postBuild = '' + wrapProgram $out/${exe} \ + --set ${preloadVar} $out/lib/libextendify_native.so + ''; - meta = { - mainProgram = "spotify"; - description = spotify.meta.description + "(patched with Extendify)"; - homepage = "https://github.com/extendify-mod/extendify"; - # wtf is the license - # license = lib.licenses.gpl3; - maintainers = [ lib.maintainers.fazzi ]; - platforms = [ - "x86_64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - }; -} + meta = { + mainProgram = "spotify"; + description = spotify.meta.description + "(patched with Extendify)"; + homepage = "https://github.com/extendify-mod/extendify"; + # wtf is the license + # license = lib.licenses.gpl3; + maintainers = [lib.maintainers.fazzi]; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + }; + } From 7a10853ab371f9c0d2e6e9400ba59a4cadafd436 Mon Sep 17 00:00:00 2001 From: Fazzi Date: Sat, 4 Jul 2026 21:26:16 +0100 Subject: [PATCH 4/6] nix: initial crane setup --- flake.lock | 22 +++++++++++-- flake.nix | 41 +++++++++++------------ nix/native.nix | 88 ++++++++++++++++++++++++++++---------------------- 3 files changed, 89 insertions(+), 62 deletions(-) diff --git a/flake.lock b/flake.lock index 14e3cb3..a0cc932 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,27 @@ { "nodes": { + "crane": { + "locked": { + "lastModified": 1783102699, + "narHash": "sha256-7inE9/GtbWf3MkV6wj2lRr0RixOpWBZboAKTPAnRDxY=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7605d0ca1a69331596d4ec0f2577fc566d17b3ad", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1780749050, - "narHash": "sha256-3av0pIjlOWQ6rDbNOmpUSvbNnJkGORQKKjb4LtCZsIY=", + "lastModified": 1782959384, + "narHash": "sha256-xnJJk+ct+D2+wdRxj1wk36w5zV9RVESwRqcklPdt3fM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a799d3e3886da994fa307f817a6bc705ae538eeb", + "rev": "65179426c83bb3f6bc14898b42ea1c6f01d374b0", "type": "github" }, "original": { @@ -18,6 +33,7 @@ }, "root": { "inputs": { + "crane": "crane", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 2353843..d8741cb 100644 --- a/flake.nix +++ b/flake.nix @@ -3,11 +3,13 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + crane.url = "github:ipetkov/crane"; }; outputs = { self, nixpkgs, + crane, }: let systems = [ "x86_64-linux" @@ -15,38 +17,37 @@ "x86_64-darwin" ]; forEachSystem = nixpkgs.lib.genAttrs systems; + pkgsForSystem = system: + import nixpkgs { + inherit system; + config.allowUnfree = true; + }; in { - devShells = forEachSystem ( - system: let - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - }; - in { - default = pkgs.callPackage ./nix/shell.nix {inherit self;}; - } - ); + devShells = forEachSystem (system: { + default = (pkgsForSystem system).callPackage ./nix/shell.nix { + inherit self; + }; + }); packages = forEachSystem ( system: let - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - }; + pkgs = pkgsForSystem system; + craneLib = crane.mkLib pkgs; in { cef = pkgs.callPackage ./nix/cef.nix {}; - extendify-native = pkgs.callPackage ./nix/native.nix {inherit self;}; - spotify-extendify = pkgs.callPackage ./nix/spotify-extendify.nix {inherit self;}; + extendify-native = pkgs.callPackage ./nix/native.nix { + inherit self craneLib; + }; + spotify-extendify = pkgs.callPackage ./nix/spotify-extendify.nix { + inherit self; + }; default = self.packages.${system}.spotify-extendify; } ); formatter = forEachSystem ( system: let - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - }; + pkgs = pkgsForSystem system; in pkgs.callPackage ./nix/fmt.nix {} ); diff --git a/nix/native.nix b/nix/native.nix index 2401710..214d49d 100644 --- a/nix/native.nix +++ b/nix/native.nix @@ -1,5 +1,4 @@ { - rustPlatform, clang, pkg-config, openssl, @@ -7,48 +6,59 @@ lib, self, stdenv, -}: -rustPlatform.buildRustPackage { - pname = "extendify-native"; - version = (lib.importTOML ../crates/extendify-native/Cargo.toml).package.version; + craneLib, +}: let + commonArgs = { + pname = "extendify-native"; + version = (lib.importTOML ../crates/extendify-native/Cargo.toml).package.version; + src = lib.fileset.toSource { + root = ../.; + fileset = lib.fileset.unions [ + ../crates + ../Cargo.lock + ../Cargo.toml + ]; + }; - src = lib.fileset.toSource { - root = ../.; - fileset = lib.fileset.unions [ - ../crates - ../Cargo.lock - ../Cargo.toml + strictDeps = true; + + nativeBuildInputs = [ + clang + pkg-config ]; - }; - cargoLock = { - lockFile = ../Cargo.lock; - allowBuiltinFetchGit = true; + buildInputs = [ + openssl + ]; }; - nativeBuildInputs = [ - clang - pkg-config - ]; + cargoArtifacts = craneLib.buildDepsOnly ( + commonArgs + // { + name = "${commonArgs.pname}-deps"; + } + ); +in + craneLib.buildPackage ( + commonArgs + // { + inherit cargoArtifacts; - buildInputs = [ - openssl - ]; + env = { + LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib"; + CEF_PATH = self.packages.${stdenv.hostPlatform.system}.cef; + }; - env = { - LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib"; - CEF_PATH = self.packages.${stdenv.hostPlatform.system}.cef; - }; - - meta = { - homepage = "https://github.com/extendify-mod/extendify"; - # wtf is the license - # license = lib.licenses.gpl3; - maintainers = [lib.maintainers.fazzi]; - platforms = [ - "x86_64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - }; -} + meta = { + homepage = "https://github.com/extendify-mod/extendify"; + # wtf is the license + # license = lib.licenses.gpl3; + maintainers = [lib.maintainers.fazzi]; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + }; + } + ) From 7be09f1d2a0029d3a33a70599ea1ba04d33e7e21 Mon Sep 17 00:00:00 2001 From: Fazzi Date: Sat, 4 Jul 2026 21:28:12 +0100 Subject: [PATCH 5/6] nix: remove x86_64-darwin from supportedSystems --- flake.nix | 1 - nix/cef.nix | 6 ++---- nix/native.nix | 1 - nix/spotify-extendify.nix | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index d8741cb..675d11b 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,6 @@ systems = [ "x86_64-linux" "aarch64-darwin" - "x86_64-darwin" ]; forEachSystem = nixpkgs.lib.genAttrs systems; pkgsForSystem = system: diff --git a/nix/cef.nix b/nix/cef.nix index d7d0352..0f8f0e8 100644 --- a/nix/cef.nix +++ b/nix/cef.nix @@ -8,10 +8,8 @@ attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system ${stdenv.hostPlatform.system}"); platformString = selectSystem { - aarch64-linux = "linuxarm64"; x86_64-linux = "linux64"; aarch64-darwin = "macosarm64"; - x86_64-darwin = "macosx64"; }; version = "144.0.11"; @@ -27,14 +25,14 @@ in cef-binary.override { inherit version gitRevision chromiumVersion srcHashes; } - else if stdenv.hostPlatform.isDarwin + else if stdenv.hostPlatform.system == "aarch64-darwin" then stdenvNoCC.mkDerivation { name = "darwin-cef"; src = fetchurl { url = "https://cef-builds.spotifycdn.com/cef_binary_${version}+g${gitRevision}+chromium-${chromiumVersion}_${platformString}_minimal.tar.bz2"; - hash = selectSystem srcHashes; + hash = srcHashes.${stdenv.hostPlatform.system}; }; dontBuild = true; diff --git a/nix/native.nix b/nix/native.nix index 214d49d..e23ade6 100644 --- a/nix/native.nix +++ b/nix/native.nix @@ -56,7 +56,6 @@ in maintainers = [lib.maintainers.fazzi]; platforms = [ "x86_64-linux" - "x86_64-darwin" "aarch64-darwin" ]; }; diff --git a/nix/spotify-extendify.nix b/nix/spotify-extendify.nix index c9863e8..fbeee5a 100644 --- a/nix/spotify-extendify.nix +++ b/nix/spotify-extendify.nix @@ -40,7 +40,6 @@ in maintainers = [lib.maintainers.fazzi]; platforms = [ "x86_64-linux" - "x86_64-darwin" "aarch64-darwin" ]; }; From 21b2b7d3950dbf8c0e9d4eed6dbe902711a47112 Mon Sep 17 00:00:00 2001 From: wyn <176603882+wynjamin@users.noreply.github.com> Date: Mon, 7 Sep 2026 14:41:25 +0200 Subject: [PATCH 6/6] fix: remove macos stuff from native --- bun.lock | 2 +- crates/extendify-native/src/unix/dyld.rs | 47 ------------------------ crates/extendify-native/src/unix/mod.rs | 5 --- 3 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 crates/extendify-native/src/unix/dyld.rs diff --git a/bun.lock b/bun.lock index 9d82424..f5a463d 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "extendify", "devDependencies": { - "@biomejs/biome": "^2.4.15", + "@biomejs/biome": "2.5.0", "@types/bun": "^1.3.14", "@types/react": "18.3.1", "@types/react-dom": "18.3.1", diff --git a/crates/extendify-native/src/unix/dyld.rs b/crates/extendify-native/src/unix/dyld.rs deleted file mode 100644 index 5ddede9..0000000 --- a/crates/extendify-native/src/unix/dyld.rs +++ /dev/null @@ -1,47 +0,0 @@ -#[allow(unused_macros)] -macro_rules! extern_c_overrides { - (unsafe fn $c_api:ident/$real_api:ident($($param_name:ident : $param_type:ty),*) -> $return_type:ty $override_body:block $($more_tokens:tt)*) => { - - pub unsafe fn $real_api($($param_name: $param_type),*) -> $return_type { - use std::ffi::{c_char, c_void}; - use std::sync::OnceLock; - - unsafe extern "C" { - fn dlsym(handle: *const c_void, symbol: *const c_char) -> *const c_void; - } - - #[allow(non_camel_case_types)] - type $c_api = unsafe fn($($param_type),*) -> $return_type; - - #[allow(non_upper_case_globals)] - static _dl_resolver: OnceLock<$c_api> = OnceLock::new(); - - let real_fn = _dl_resolver.get_or_init(|| { - unsafe { - const RTLD_NEXT: *const c_void = -1isize as *const c_void; - let sym = dlsym( - RTLD_NEXT, - concat!(stringify!($c_api), "\0").as_ptr() as *const c_char, - ); - if sym.is_null() { - panic!("dlsym(RTLD_NEXT): cannot find {}", stringify!($c_api)); - } - core::mem::transmute(sym) - } - }); - - unsafe { real_fn($($param_name),*) } - } - - #[unsafe(no_mangle)] - pub unsafe extern "C" fn $c_api($($param_name: $param_type),*) -> $return_type { - unsafe { - let $c_api = $real_api; - $override_body - } - } - - extern_c_overrides! { $($more_tokens)* } - }; - () => {}; -} diff --git a/crates/extendify-native/src/unix/mod.rs b/crates/extendify-native/src/unix/mod.rs index 44c7e9c..b4d3393 100644 --- a/crates/extendify-native/src/unix/mod.rs +++ b/crates/extendify-native/src/unix/mod.rs @@ -7,13 +7,8 @@ use crate::cef::{ use crate::{log, vtable_hooks}; #[macro_use] -#[cfg(target_os = "linux")] mod preload; -#[macro_use] -#[cfg(target_os = "macos")] -mod dyld; - extern_c_overrides! { unsafe fn cef_browser_view_create/real_cef_browser_view_create( client: *mut _cef_client_t,