-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathflake.nix
99 lines (87 loc) · 3.41 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
{
description = "Source port of Homeworld 1";
inputs = {
guidestone = {
url = git+https://gitlab.com/homeworldsdl/the-guidestone.git;
inputs.nixpkgs.follows = "nixpkgs";
};
nixGL = {
url = github:guibou/nixGL;
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, guidestone, nixGL }: {
devShells.x86_64-linux.default = with nixpkgs.legacyPackages.x86_64-linux;
mkShell {
buildInputs = self.packages.x86_64-linux.default.buildInputs ++ [
SDL2_image
clang-tools_16 # clangd, clang-format
meson
pkg-config
python3
ninja
gdb
ffmpeg
nixpkgs-fmt
emscripten
];
# With --enable-sanitizers dlopen() fails to find libs. This is used by SDL2 to open the sound library (pipewire), and by libglvnd to open the vendor-specific OpenGL driver
LD_LIBRARY_PATH = "${pipewire}/lib;/run/opengl-driver/lib";
# The (wrapped) gcc provided by this nix env has source fortifications enabled because its the same gcc that's used to compile nix packages.
# However we are in a dev build env and we'd like to have sanitizers enabled. They require `-O0` which is incompatible with source fortification
# `error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O)`
hardeningDisable = [ "all" ];
};
source-code = with nixpkgs.legacyPackages.x86_64-linux; runCommand "Source Code"
{ }
''
mkdir -p $out/Linux/stuff
cp ${./stuff}/{acinclude.m4,configure.ac,Makefile.am} $out/Linux/stuff
cp -r ${./../src} $out/src
cp -r ${./../tools} $out/tools
'';
version = "${builtins.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}.${self.shortRev or "dirty"}";
packages.x86_64-linux.default = (guidestone.galactic_map {
version = self.version;
src = self.source-code;
configureOptions = "--enable-hwdebug --enable-sanitizers";
}).overrideAttrs (attrs: {
dontStrip = true;
nativeBuildInputs = [ nixpkgs.legacyPackages.x86_64-linux.makeWrapper ];
buildInputs = attrs.buildInputs ++ [ nixpkgs.legacyPackages.x86_64-linux.SDL2_image ];
installPhase = attrs.installPhase + ''
wrapProgram $out/bin/homeworld --set LD_LIBRARY_PATH "${self.devShells.x86_64-linux.default.LD_LIBRARY_PATH}"
'';
});
packages.x86_64-linux.i-am-not-on-nixos = nixpkgs.legacyPackages.x86_64-linux.writeShellScriptBin "non-nixos" ''
${nixGL.packages.x86_64-linux.default}/bin/nixGL ${self.packages.x86_64-linux.default}/bin/homeworld
'';
ci-docker-image = with nixpkgs.legacyPackages.x86_64-linux;
dockerTools.buildLayeredImage {
name = "registry.gitlab.com/gardens-of-kadesh/gardens-of-kadesh/emscripten-build-env";
tag = "latest";
contents = [
busybox
meson
pkg-config
ninja
emscripten
gcc
yacc
flex
# Root certificates for HTTPS, so emscripten can download SDL2
dockerTools.caCertificates
];
config = {
Env = [
"PKG_CONFIG_PATH=${SDL2.dev}/lib/pkgconfig"
];
Cmd = [ "/bin/sh" ];
};
};
apps.x86_64-linux.default = {
type = "app";
program = "${self.packages.x86_64-linux.default}/bin/homeworld";
};
};
}