forked from nickgirardo/fish
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
131 lines (119 loc) · 4.11 KB
/
flake.nix
File metadata and controls
131 lines (119 loc) · 4.11 KB
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
{
description = "Grand Fantasy Fish, an RPG for the GameTank";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-24.05";
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
cc65.url = "github:nickgirardo/nix-cc65-unstable/18b6c7417518c54bb95a2071782f2603d883edc9";
GameTankEmulator.url = "github:nickgirardo/nix-GameTankEmulator/32aa921c65e9bb480da79eb4e90287f77e94a5fe";
GTFO.url = "github:nickgirardo/nix-GTFO/e159f175b9ef3c2698f8c81a6843fac2fd3fcef0";
};
outputs = { self, nixpkgs, gitignore, cc65, GameTankEmulator, GTFO }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
node_scripts = pkgs.buildNpmPackage {
name = "node_scripts";
src = gitignore.lib.gitignoreSource ./scripts;
npmDepsHash = "sha256-q+CvN0cnzBB9Kn1+6kaGHhgJcqMdf4piuzvedtyWJDo=";
dontNpmBuild = true;
installPhase = ''
mkdir -p $out/bin
cp -r . $out/bin
'';
};
fish = pkgs.stdenv.mkDerivation {
inherit system;
name = "Grand Fantasy Fish";
src = gitignore.lib.gitignoreSource ./.;
nativeBuildInputs = [
cc65.outputs.packages.${system}.default
pkgs.gnumake
pkgs.zip
pkgs.nodejs
pkgs.zopfli
];
NODE_SCRIPTS="${node_scripts}/bin";
CC65_LIB="${cc65.outputs.packages.${system}.default}/share/cc65/lib";
phases = [
"unpackPhase"
"patchPhase"
"preBuildPhase"
"buildPhase"
"installPhase"
];
preBuildPhase = "node $NODE_SCRIPTS/build_setup/import_assets.js";
buildPhase = "make bin/game.gtr";
installPhase = ''
mkdir -p $out/bin
cp -r bin $out
mkdir -p $out/web
cp -r web $out
'';
};
web-emulator = GameTankEmulator.outputs.packages.${system}.gte-web.overrideAttrs (final: prev: {
rom = "${fish}/bin/game.gtr";
WEB_SHELL = "${fish}/web/shell.html";
WEB_ASSETS = "${fish}/web/assets/";
WINDOW_TITLE = "Grand Fantasy Fish";
});
web-emulator-embed = GameTankEmulator.outputs.packages.${system}.gte-web.overrideAttrs (final: prev: {
rom = "${fish}/bin/game.gtr";
WEB_SHELL = "web/embedded.html";
});
in {
devShells.${system}.default = pkgs.mkShell {
buildInputs = [ cc65.outputs.packages.${system}.default pkgs.gnumake pkgs.nodejs pkgs.zip pkgs.zopfli ];
CC65_LIB="${cc65.outputs.packages.${system}.default}/share/cc65/lib";
};
packages.${system} = {
inherit fish web-emulator web-emulator-embed;
default = fish;
};
apps.${system} = let
emu = pkgs.writeShellApplication {
name = "emulate";
runtimeInputs = [ GameTankEmulator.outputs.packages.${system}.default ];
text = "GameTankEmulator ${fish}/bin/game.gtr";
};
emulate = {
type = "app";
program = "${emu}/bin/emulate";
};
emu-web = pkgs.writeShellApplication {
name = "emulate-web";
runtimeInputs = [ pkgs.caddy ];
text = ''
# Takes the port as first argument
# Default to port 8080
PORT="''${1:-8080}"
caddy file-server --listen :"$PORT" --root ${web-emulator.outPath}/dist
'';
};
emulate-web = {
type = "app";
program = "${emu-web}/bin/emulate-web";
};
flash_ = pkgs.writeShellApplication {
name = "flash";
runtimeInputs = [ GTFO.outputs.packages.${system}.default ];
text = ''
if [ "$#" -ne 1 ]; then
echo "Please specify the port to flash onto"
exit 1
fi
GTFO -p "$1" ${fish}/bin/game.gtr.bank*
'';
};
flash = {
type = "app";
program = "${flash_}/bin/flash";
};
in {
inherit emulate emulate-web flash;
default = emulate;
};
};
}