Browse Source

Use flakes instead, superior

master
Knarkzel 2 years ago
parent
commit
636431a3a2
  1. 32
      README.md
  2. 27
      devkitA64.nix
  3. 27
      devkitARM.nix
  4. 28
      devkitPPC.nix
  5. 47
      extract-docker.nix
  6. 27
      flake.lock
  7. 161
      flake.nix

32
README.md

@ -1,28 +1,18 @@ @@ -1,28 +1,18 @@
# devkitnix
Collection of devkitPro toolchains using Nix.
To install a toolchain, use following:
Collection of devkitPro packages for Nix using flakes.
To build a toolchain like devkitPPC, use following:
```
git clone https://github.com/zig-homebrew/devkitnix
cd devkitnix
nix-build <toolchain>.nix
nix build github:zig-homebrew/devkitnix#devkitPPC
```
## devkitARM
## Toolchains
- Game Boy Advance
- Nintendo DS
- Nintendo 3DS
- GP32
- GP2X
## devkitPPC
- GameCube
- Wii
- Wii U
## devkitA64
- Nintendo Switch
```
└───packages
└───x86_64-linux
├───devkitA64: package 'devkitA64'
├───devkitARM: package 'devkitARM'
└───devkitPPC: package 'devkitPPC'
```

27
devkitA64.nix

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/e3583ad6e533a9d8dd78f90bfa93812d390ea187.tar.gz") {};
image = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkita64";
imageDigest = "sha256:70db4c954eea43be5f1bc64c8882154126c99f47927ecb1e6b27fa18004fc961";
sha256 = "a05LU5jF5KxQdqWJv+4b3EBRlVCZjBGx69WpFL57wP4=";
finalImageName = "devkitpro/devkita64";
finalImageTag = "20221113";
};
in {
devkitA64 = pkgs.stdenv.mkDerivation {
name = "devkitA64";
src = import ./extract-docker.nix pkgs image;
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
'';
};
}

27
devkitARM.nix

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/e3583ad6e533a9d8dd78f90bfa93812d390ea187.tar.gz") {};
image = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkitarm";
imageDigest = "sha256:695d1eb865ca4b908b1f5c4de777b9eef0f927680f0c0654b07721f1df908606";
sha256 = "U2Xkt4IYUeU00w/FzlvySzG5lFL2R7kN8sjxL0EEKD4=";
finalImageName = "devkitpro/devkitarm";
finalImageTag = "20221115";
};
in {
devkitARM = pkgs.stdenv.mkDerivation {
name = "devkitARM";
src = import ./extract-docker.nix pkgs image;
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
'';
};
}

28
devkitPPC.nix

@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/e3583ad6e533a9d8dd78f90bfa93812d390ea187.tar.gz") {};
image = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkitppc";
imageDigest = "sha256:d88e21c1a7b5f8070ba7a15aa892e395f118ded9803b0f8223a3d29ba279fff3";
sha256 = "nVtz/9mbYveKbvTMj/39EzND7qiLkjBHfqSOgT6SBUY=";
finalImageName = "devkitpro/devkitppc";
finalImageTag = "20220821";
};
in {
devkitPPC = pkgs.stdenv.mkDerivation {
name = "devkitPPC";
src = import ./extract-docker.nix pkgs image;
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
buildInputs = [
pkgs.stdenv.cc.cc
pkgs.ncurses5
pkgs.expat
pkgs.xz
];
buildPhase = "true";
installPhase = ''
mkdir -p $out
cp -r $src/{devkitPPC,libogc,portlibs,tools,wut} $out
rm -rf $out/pacman
'';
};
}

47
extract-docker.nix

@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
pkgs: image:
let
directory = "/opt/devkitpro";
in
pkgs.vmTools.runInLinuxVM (
pkgs.runCommand "docker-preload-image" {
memSize = 12 * 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 '${toString directory}' -c . | tar -xv --no-same-owner -C $out || true
echo end
kill %1
''
)

27
flake.lock

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1668595291,
"narHash": "sha256-j8cyfbtT5sAYPYwbERgTDzfD48ZernL0/V668eGpXAM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6474d93e007e4d165bcf48e7f87de2175c93d10b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

161
flake.nix

@ -1,46 +1,131 @@ @@ -1,46 +1,131 @@
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-22.05";
};
flake-utils = {
url = "github:numtide/flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
};
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {};
image = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkitppc";
imageDigest = "sha256:d88e21c1a7b5f8070ba7a15aa892e395f118ded9803b0f8223a3d29ba279fff3";
sha256 = "nVtz/9mbYveKbvTMj/39EzND7qiLkjBHfqSOgT6SBUY=";
finalImageName = "devkitpro/devkitppc";
finalImageTag = "20220821";
};
in {
devkitPPC = pkgs.stdenv.mkDerivation {
name = "devkitPPC";
src = import ./extract-docker.nix pkgs image;
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
buildInputs = [
pkgs.stdenv.cc.cc
pkgs.ncurses5
pkgs.expat
pkgs.xz
];
buildPhase = "true";
installPhase = ''
mkdir -p $out
cp -r $src/{devkitPPC,libogc,portlibs,tools,wut} $out
rm -rf $out/pacman
'';
};
});
}: let
pkgs = import nixpkgs {system = "x86_64-linux";};
imageA64 = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkita64";
imageDigest = "sha256:70db4c954eea43be5f1bc64c8882154126c99f47927ecb1e6b27fa18004fc961";
sha256 = "a05LU5jF5KxQdqWJv+4b3EBRlVCZjBGx69WpFL57wP4=";
finalImageName = "devkitpro/devkita64";
finalImageTag = "20221113";
};
imageARM = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkitarm";
imageDigest = "sha256:695d1eb865ca4b908b1f5c4de777b9eef0f927680f0c0654b07721f1df908606";
sha256 = "U2Xkt4IYUeU00w/FzlvySzG5lFL2R7kN8sjxL0EEKD4=";
finalImageName = "devkitpro/devkitarm";
finalImageTag = "20221115";
};
imagePPC = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkitppc";
imageDigest = "sha256:d88e21c1a7b5f8070ba7a15aa892e395f118ded9803b0f8223a3d29ba279fff3";
sha256 = "nVtz/9mbYveKbvTMj/39EzND7qiLkjBHfqSOgT6SBUY=";
finalImageName = "devkitpro/devkitppc";
finalImageTag = "20220821";
};
extractDocker = image:
pkgs.vmTools.runInLinuxVM (
pkgs.runCommand "docker-preload-image" {
memSize = 10 * 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.ncurses5
pkgs.expat
pkgs.xz
];
buildPhase = "true";
installPhase = ''
mkdir -p $out
cp -r $src/{devkitPPC,libogc,portlibs,tools,wut} $out
rm -rf $out/pacman
'';
};
};
}

Loading…
Cancel
Save