Skip to content

Instantly share code, notes, and snippets.

@ChadSki
Created March 8, 2023 05:52
Show Gist options
  • Save ChadSki/37db0e1645e79adfffb8d96ff6334b49 to your computer and use it in GitHub Desktop.
Save ChadSki/37db0e1645e79adfffb8d96ff6334b49 to your computer and use it in GitHub Desktop.
Steps for cross-compiling Nix 2.8 for ppc64le
# Get a ppc64le-compatible branch and build cross (this takes a long time)
git clone https://github.com/ChadSki/nixpkgs.git -b nixos-22.05-small-ppc64le
nix-build './nixpkgs' -A pkgsCross.powernv.nix
# Get a donor copy of the installer
wget https://releases.nixos.org/nix/nix-2.8.1/nix-2.8.1-x86_64-linux.tar.xz
tar xf nix-2.8.1-x86_64-linux.tar.xz
# Copy the cert package to our new installer
mkdir -p nix-2.8.1-ppc64le-linux/store
cp -r nix-2.8.1-x86_64-linux/store/*nss-cacert* nix-2.8.1-ppc64le-linux/store/
# Toss other packages, but keep the scripts
rm -rf nix-2.8.1-x86_64-linux/store
mv nix-2.8.1-x86_64-linux/* nix-2.8.1-ppc64le-linux/
# Add ppc64le packages
cp -r $(nix-store -qR result) nix-2.8.1-ppc64le-linux/store/
# Generate a .reginfo for those ppc64le packages
nix-store --dump-db $(nix-store -qR result) > nix-2.8.1-ppc64le-linux/.reginfo
# Replace NIX_INSTALLED_NIX in install script
export NIX_INSTALLED_NIX=$(readlink result)
sed -i "s#NIX_INSTALLED_NIX=\".*\"#NIX_INSTALLED_NIX=\"$NIX_INSTALLED_NIX\"#" nix-2.8.1-ppc64le-linux/install-multi-user
# Compress for transfer
tar cJvf nix-2.8.1-ppc64le-linux.tar.xz nix-2.8.1-ppc64le-linux
echo "Done! Copy nix-ppc64le-linux to ppc64le machine and run ./install --daemon"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment