-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathflake.nix
executable file
·120 lines (110 loc) · 2.86 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
flake-utils,
nixpkgs,
...
}: let
mkDevkit = pkgs: {
name,
src,
includePaths ? [],
}:
pkgs.stdenv.mkDerivation (finalAttrs: {
inherit name;
src = pkgs.dockerTools.pullImage (pkgs.lib.importJSON src);
nativeBuildInputs = with pkgs; [
autoPatchelfHook
];
buildInputs = with pkgs; [
ncurses
stdenv.cc.cc.lib
];
dontPatchShebangs = true;
phases = ["buildPhase" "fixupPhase"];
buildPhase = ''
tar -xf $src
for archive in $(find *.tar)
do
tar -xf $archive
done
mkdir -p $out
cp -r opt $out/opt
ln -sf $out/opt/devkitpro/tools/bin $out/bin
'';
passthru = rec {
CPATH = pkgs.lib.makeSearchPath "include" (builtins.map (x: "${finalAttrs.finalPackage}/opt/devkitpro/${x}") includePaths);
shellHook = ''
export DEVKITPRO="${finalAttrs.finalPackage}/opt/devkitpro"
export DEVKITARM="$DEVKITPRO/devkitARM"
export DEVKITPPC="$DEVKITPRO/devkitPPC"
export CPATH=${CPATH}
export PATH="${pkgs.lib.makeBinPath ["$DEVKITPRO" "$DEVKITARM" "$DEVKITPPC"]}:$PATH}"
'';
};
});
packages = pkgs: {
devkitA64 = mkDevkit pkgs {
name = "devkitA64";
src = ./sources/devkita64.json;
includePaths = [
"devkitA64"
"devkitA64/aarch64-none-elf"
"libnx"
"portlibs/switch"
];
};
devkitARM = mkDevkit pkgs {
name = "devkitARM";
src = ./sources/devkitarm.json;
includePaths = [
"devkitARM"
"devkitARM/arm-none-eabi"
"libctru"
"libgba"
"libmirko"
"libnds"
"liborcus"
"libtonc"
"portlibs/3ds"
"portlibs/armv4t"
"portlibs/gba"
"portlibs/gp2x"
"portlibs/nds"
];
};
devkitPPC = mkDevkit pkgs {
name = "devkitPPC";
src = ./sources/devkitppc.json;
includePaths = [
"devkitPPC"
"devkitPPC/powerpc-eabi"
"libogc"
"portlibs/gamecube"
"portlibs/ppc"
"portlibs/wii"
"portlibs/wiiu"
"wut"
];
};
};
in
(flake-utils.lib.eachDefaultSystem (system: let
pkgs' = nixpkgs.legacyPackages.${system};
in {
packages = {
inherit (packages pkgs') devkitA64 devkitARM devkitPPC;
};
}))
// {
overlays.default = final: prev: {
devkitNix = {
inherit (packages prev) devkitA64 devkitARM devkitPPC;
};
};
};
}