-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
180 lines (146 loc) · 4.77 KB
/
Copy pathflake.nix
File metadata and controls
180 lines (146 loc) · 4.77 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
{
description = ''
cbn-custom-flake: A nix flake to install pre-built CBN games bundled
with my preferred modifications and patches.
'';
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
...
}:
let
supportedSystems = [ "x86_64-linux" ];
in
flake-utils.lib.eachSystem supportedSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
lib = pkgs.lib;
pinnedSources =
with pkgs;
(import ./_sources/generated.nix {
inherit
fetchurl
fetchgit
fetchFromGitHub
dockerTools
;
});
module = import ./default.nix { inherit pkgs lib pinnedSources; };
in
rec {
packages = rec {
expanded = extras.overrideAttrs (
let
extraContents = module.game.stable.expanded;
in
{
prePatch = (module.contentsInstaller.install extraContents ".");
}
);
# With extra mods and all the goodies I like.
extras = default.overrideAttrs (
let
extraContents = module.game.stable.extras;
in
{
prePatch = (module.contentsInstaller.install extraContents ".");
patchFlags = [
"-p1"
"-d"
"data/mods"
];
patches = [ ];
}
);
development = default.overrideAttrs (
let
launcherFile = "cbn-tiles-launcher-development";
jsonFormatterFile = "json_formatter.cgi";
developmentUserDir = ".cbn-custom-development";
writeLauncherScript = ''
cat << EOF > launcher
#!${pkgs.runtimeShell}
if [[ -z "\$1" ]]; then
userdir="\$HOME/${developmentUserDir}"
else
userdir="\$1"
fi
content_dir="\$userdir/content"
if [[ ! -d "\$content_dir" ]]; then
mkdir -p "\$content_dir"
cp --no-preserve=mode -R $out/data $out/gfx $out/share/doc "\$content_dir/"
fi
"$out/bin/cataclysm-bn-tiles" --basepath "\$content_dir" --userdir "\$userdir"
EOF
install -m755 -D launcher $out/bin/${launcherFile}
'';
in
previousAttrs: rec {
name = launcherFile;
pname = "development";
meta.mainProgram = launcherFile;
nativeBuildInputs = previousAttrs.nativeBuildInputs ++ [ pkgs.stdenv.cc.cc ];
installPhase = ''
runHook preInstall
mkdir $out
install -m755 -D ${jsonFormatterFile} $out/bin/${jsonFormatterFile}
mkdir -p $out
cp -R data gfx doc $out
install -m755 -D cataclysm-bn-tiles $out/bin/cataclysm-bn-tiles
${writeLauncherScript}
runHook postInstall
'';
}
);
default =
let
game = module.game;
writeLauncherScript = ''
cat << EOF > launcher
#!${pkgs.runtimeShell}
if [[ -z "\$1" ]]; then
userdir="\$HOME/.cbn-custom"
else
userdir="\$1"
fi
$out/bin/cataclysm-bn-tiles --basepath $out --userdir "\$userdir"
EOF
install -m755 -D launcher $out/bin/cbn-tiles-launcher
'';
makeInstallPhase = ''
runHook preInstall
mkdir -p $out
cp -R data gfx doc $out
install -m755 -D cataclysm-bn-tiles $out/bin/cataclysm-bn-tiles
${writeLauncherScript}
runHook postInstall
'';
in
pkgs.stdenvNoCC.mkDerivation {
name = "cbn-tiles-launcher";
version = game.stable.gameSource.version;
src = game.stable.gameSource.src;
nativeBuildInputs = with pkgs; [ autoPatchelfHook ];
buildInputs = with pkgs; [
SDL2
SDL2_image
SDL2_mixer
SDL2_ttf
];
dontConfigure = true;
dontBuild = true;
dontStrip = true;
installPhase = makeInstallPhase;
};
};
devShells.default = module.devshell;
}
);
}