Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 38 additions & 16 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,52 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
crane.url = "github:ipetkov/crane";
};

outputs = {
self,
nixpkgs,
crane,
}: let
# Spotify only ships on this so it's fine
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
systems = [
"x86_64-linux"
"aarch64-darwin"
];
forEachSystem = nixpkgs.lib.genAttrs systems;
pkgsForSystem = system:
import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in {
devShells.${system} = {
default = pkgs.callPackage ./nix/shell.nix {inherit self;};
};
devShells = forEachSystem (system: {
default = (pkgsForSystem system).callPackage ./nix/shell.nix {
inherit self;
};
});

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;
};
packages = forEachSystem (
system: let
pkgs = pkgsForSystem system;
craneLib = crane.mkLib pkgs;
in {
cef = pkgs.callPackage ./nix/cef.nix {};
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.${system} = pkgs.callPackage ./nix/fmt.nix {};
formatter = forEachSystem (
system: let
pkgs = pkgsForSystem system;
in
pkgs.callPackage ./nix/fmt.nix {}
);
};
}
48 changes: 44 additions & 4 deletions nix/cef.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,50 @@
{
cef-binary,
fetchurl,
stdenv,
}:
cef-binary.override {
stdenvNoCC,
}: let
selectSystem = attrs:
attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system ${stdenv.hostPlatform.system}");

platformString = selectSystem {
x86_64-linux = "linux64";
aarch64-darwin = "macosarm64";
};

version = "144.0.11";
gitRevision = "e135be2";
chromiumVersion = "144.0.7559.97";
srcHashes.${stdenv.hostPlatform.system} = "sha256-almKJ18g//Wi2CDRX1yibODvR6TF0DlUl1EnDNlIHBY=";
}
srcHashes = {
x86_64-linux = "sha256-almKJ18g//Wi2CDRX1yibODvR6TF0DlUl1EnDNlIHBY=";
aarch64-darwin = "sha256-Q94fht0yAkwAIqv29I1ZkpaS7WiYvJIcHWFcmBSvqHw=";
};
in
if stdenv.hostPlatform.isLinux
then
cef-binary.override {
inherit version gitRevision chromiumVersion srcHashes;
}
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 = srcHashes.${stdenv.hostPlatform.system};
};

dontBuild = true;
dontConfigure = true;

unpackPhase = ''
tar --strip-components=1 -xjf $src
'';

installPhase = ''
mkdir -p $out
cp -r ./* $out/
'';
}
else throw "Unsupported system: ${stdenv.hostPlatform.system}"
83 changes: 48 additions & 35 deletions nix/native.nix
Original file line number Diff line number Diff line change
@@ -1,50 +1,63 @@
{
rustPlatform,
clang,
pkg-config,
openssl,
llvmPackages,
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"];
};
}
meta = {
homepage = "https://github.com/extendify-mod/extendify";
# wtf is the license
# license = lib.licenses.gpl3;
maintainers = [lib.maintainers.fazzi];
platforms = [
"x86_64-linux"
"aarch64-darwin"
];
};
}
)
58 changes: 35 additions & 23 deletions nix/spotify-extendify.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,42 @@
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"];
};
}
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"
"aarch64-darwin"
];
};
}
Loading