Created
January 8, 2025 21:56
-
-
Save alloydwhitlock/c001f983be26dd5e2fbb5485efef5c44 to your computer and use it in GitHub Desktop.
Nix flake for socket_vmnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "socket_vmnet - user-mode networking for macOS VMs"; | |
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
outputs = { self, nixpkgs }: let | |
version = "1.2.1"; | |
# Helper function to create the package for a specific architecture | |
mkSocket = system: let | |
pkgs = nixpkgs.legacyPackages.${system}; | |
arch = if system == "aarch64-darwin" then "arm64" else "x86_64"; | |
sha256 = if system == "aarch64-darwin" | |
then "sha256-fJfKz1NTvawSkuHTcciKArWVb1zTGHMvpR7HiRg2QQ8=" | |
else "15q1kjykibhqwflw1ivxfgqwys5d1z5n25yfgl3g66z8ggy3k9v4"; | |
in pkgs.stdenv.mkDerivation { | |
pname = "socket_vmnet"; | |
inherit version; | |
src = pkgs.fetchurl { | |
url = "https://github.com/lima-vm/socket_vmnet/releases/download/v${version}/socket_vmnet-${version}-${arch}.tar.gz"; | |
inherit sha256; | |
}; | |
buildInputs = [ | |
pkgs.darwin.apple_sdk.frameworks.Security | |
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration | |
]; | |
dontBuild = true; | |
installPhase = '' | |
runHook preInstall | |
mkdir -p $out/opt/socket_vmnet | |
cp -r ./socket_vmnet/. $out/opt/socket_vmnet/ | |
mkdir -p $out/bin | |
chmod +x $out/opt/socket_vmnet/bin/* | |
ln -s $out/opt/socket_vmnet/bin/* $out/bin/ | |
for bin in $out/opt/socket_vmnet/bin/*; do | |
${pkgs.darwin.cctools}/bin/install_name_tool -add_rpath @executable_path/../Frameworks $bin | |
done | |
runHook postInstall | |
''; | |
meta = with pkgs.lib; { | |
description = "User-mode networking for macOS VMs"; | |
homepage = "https://github.com/lima-vm/socket_vmnet"; | |
license = licenses.bsd3; | |
platforms = platforms.darwin; | |
maintainers = [ ]; | |
}; | |
}; | |
in { | |
packages = { | |
aarch64-darwin.default = mkSocket "aarch64-darwin"; | |
x86_64-darwin.default = mkSocket "x86_64-darwin"; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment