-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathflake.nix
117 lines (93 loc) · 2.88 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
{
description = "Rugburn, a patcher for PangYa";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Common dependencies
nativeBuildInputs = [
pkgs.makeWrapper
pkgs.pkgsCross.mingw32.stdenv.cc
];
nativeCheckInputs = [ pkgs.python3Packages.tappy ];
# Rugburn derivation
rugburn = pkgs.stdenv.mkDerivation {
name = "rugburn";
src = self;
inherit nativeBuildInputs;
nativeCheckInputs = nativeCheckInputs ++ [ pkgs.winePackages.minimal ];
FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = [ ]; };
checkPhase = ''
runHook preCheck
export WINEPREFIX="$PWD/.wine"
export WINEARCH="win32"
HOME="$PWD" WINEDEBUG="-all" wineboot
HOME="$PWD" WINEDEBUG="fixme-all" make check
runHook postCheck
'';
doCheck = true;
buildPhase = ''
runHook preBuild
make -j
(printf -- "-nostdlib\n-nostdinc\n-nostdinc++\n--target=i686-pc-windows-gnu\n-D_WIN32\n-D__MINGW32__\n-DSTRSAFE_NO_DEPRECATE" \
&& </dev/null i686-w64-mingw32-gcc -E -v - 2>&1 \
| grep ^COLLECT_GCC_OPTIONS= \
| tail -1 \
| cut -d= -f2- \
| xargs -n1 printf "%s\n" \
) > compile_flags.txt
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -D -t $out/lib out/ijl15.dll
install -D --mode=0644 -t $out compile_flags.txt
runHook postInstall
'';
};
# Dev shell
devShell = pkgs.mkShell {
nativeBuildInputs = nativeBuildInputs ++ nativeCheckInputs ++ [ pkgs.clang.cc ];
};
# Clangd setup
setupClangd = pkgs.writeShellScriptBin "setup-clangd.sh" ''
install -D --mode=0644 -t . ${rugburn}/compile_flags.txt
'';
# Website setup
caddyfile = pkgs.writeText "caddyfile" ''
:8080
root * ${rugburn}/dist
file_server
'';
web = pkgs.writeShellScriptBin "web.sh" ''
exec ${pkgs.caddy}/bin/caddy run --adapter caddyfile --config ${caddyfile}
'';
dockerImage = pkgs.dockerTools.buildImage {
name = "rugburn-docker";
config.Cmd = [ "${web}/bin/web.sh" ];
};
in
{
inherit devShell;
packages = {
inherit
rugburn
setupClangd
web
dockerImage
;
default = rugburn;
};
}
);
}