Collection of devkitpro toolchains compatible with Nix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.8 KiB

{
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; };
outputs = { self, nixpkgs, }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
imageA64 = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkita64";
imageDigest =
"sha256:fa47ae6e5c73e0ae81154a120858d3de2d1fcc0bfbf810581ba1d14a2fedef0f";
sha256 = "i1zJ+3Usvk7D7ZQF2Gdi2Ea6u04J0JVMSuLQY4q6rmM=";
finalImageName = "devkitpro/devkita64";
finalImageTag = "20240324";
};
imageARM = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkitarm";
imageDigest =
"sha256:340c466b53961c0d90e7536f6db3364d4bfede0f65a26492c25b118d0a00d82e";
sha256 = "KUiKhA3QhMR9cIQC82FI0AgE+Ud7dAXY50xSn5oWZzI=";
finalImageName = "devkitpro/devkitarm";
finalImageTag = "20240202";
};
imagePPC = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkitppc";
imageDigest =
"sha256:bc904413f470ea85d559d042da2f077208fe2adebeecc70d34f61828e87f3310";
sha256 = "6GGKWpgw27mq+1dLJGPS5sJBGQ35JmzAHM2qokW73cI=";
finalImageName = "devkitpro/devkitppc";
finalImageTag = "20240417";
};
extractDocker = image:
pkgs.vmTools.runInLinuxVM (pkgs.runCommand "docker-preload-image" {
memSize = 40 * 1024;
buildInputs =
[ pkgs.curl pkgs.kmod pkgs.docker pkgs.e2fsprogs pkgs.utillinux ];
} ''
modprobe overlay
# from https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
cd /sys/fs/cgroup
for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
mkdir -p $sys
if ! mountpoint -q $sys; then
if ! mount -n -t cgroup -o $sys cgroup $sys; then
rmdir $sys || true
fi
fi
done
dockerd -H tcp://127.0.0.1:5555 -H unix:///var/run/docker.sock &
until $(curl --output /dev/null --silent --connect-timeout 2 http://127.0.0.1:5555); do
printf '.'
sleep 1
done
echo load image
docker load -i ${image}
echo run image
docker run ${image.destNameTag} tar -C /opt/devkitpro -c . | tar -xv --no-same-owner -C $out || true
echo end
kill %1
'');
in {
packages.x86_64-linux.devkitA64 = pkgs.stdenv.mkDerivation {
name = "devkitA64";
src = extractDocker imageA64;
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
buildInputs = [ pkgs.stdenv.cc.cc pkgs.ncurses6 pkgs.zsnes ];
buildPhase = "true";
installPhase = ''
mkdir -p $out
cp -r $src/{devkitA64,libnx,portlibs,tools} $out
rm -rf $out/pacman
'';
};
packages.x86_64-linux.devkitARM = pkgs.stdenv.mkDerivation {
name = "devkitARM";
src = extractDocker imageARM;
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
buildInputs = [ pkgs.stdenv.cc.cc pkgs.ncurses6 pkgs.zsnes ];
buildPhase = "true";
installPhase = ''
mkdir -p $out
cp -r $src/{devkitARM,libgba,libnds,libctru,libmirko,liborcus,portlibs,tools} $out
rm -rf $out/pacman
'';
};
packages.x86_64-linux.devkitPPC = pkgs.stdenv.mkDerivation {
name = "devkitPPC";
src = extractDocker imagePPC;
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
buildInputs = [ pkgs.stdenv.cc.cc pkgs.ncurses6 pkgs.expat pkgs.xz ];
buildPhase = "true";
installPhase = ''
mkdir -p $out
cp -r $src/{devkitPPC,libogc,portlibs,tools,wut} $out
rm -rf $out/pacman
'';
};
};
}