forked from svelterust/devkitnix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
134 lines (125 loc) · 4.01 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
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:fec55807a9f84d457e8bc814cf9b63785756aad2b979a43a47ae92b7ac23336d";
sha256 = "sha256-c81gYwoeODcp77Gy/krmJhe3Y8CEmEUd4gSPry09gLs=";
finalImageName = "devkitpro/devkita64";
finalImageTag = "20240224";
};
imageARM = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkitarm";
imageDigest = "sha256:2ee5e6ecdc768aa7fb8f2e37be2e27ce33299e081caac20a0a2675cdc791cf32";
sha256 = "sha256-KUiKhA3QhMR9cIQC82FI0AgE+Ud7dAXY50xSn5oWZzI=";
finalImageName = "devkitpro/devkitarm";
finalImageTag = "20240202";
};
imagePPC = pkgs.dockerTools.pullImage {
imageName = "devkitpro/devkitppc";
imageDigest = "sha256:654446a7ae7a6dc88baf8bdec9ae446cdda2b7e5d995c8e5b50d35ec4271ba6c";
sha256 = "sha256-uAuZUkF+vfcJG5spmglT+DQPUBA00wHy+/G5kOhCPBA=";
finalImageName = "devkitpro/devkitppc";
finalImageTag = "20240220";
};
extractDocker = image:
pkgs.vmTools.runInLinuxVM (
pkgs.runCommand "docker-preload-image" {
# After updating the switch image the vm
# started to run out of space. Since it
# has an tmpfs fs I just gave it more ram
memSize = 10 * 1536;
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,examples} $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
'';
};
};
}