forked from snowball-lang/snowball
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
123 lines (105 loc) · 3.49 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
121
122
123
{
description = "Snowball is a low-weight, statically typed, object oriented programming language. ";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
flake-utils,
nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
in {
packages.snowball = pkgs.stdenv.mkDerivation {
name = "snowball";
version = pkgs.lib.strings.readFile ./snowball.version.str;
src = ./.;
nativeBuildInputs = with pkgs; [cmake pkg-config makeWrapper];
buildInputs = with pkgs; [
zstd
libxml2
libsigsegv
glib
pcre2
libllvm
libbacktrace
curl.dev
openssl
nlohmann_json
];
patchPhase = ''
sed -i '191i find_package(nlohmann_json REQUIRED)' CMakeLists.txt
sed -i -e '/CPMAddPackage(/,/)/d' CMakeLists.txt
sed -i -e '/include(FetchContent)/d' CMakeLists.txt
sed -i -e '/FetchContent_Declare(/,/)/d' CMakeLists.txt
sed -i -e '/FetchContent_MakeAvailable(json)/d' CMakeLists.txt
sed -i -e 's/libcurl/curl/' CMakeLists.txt
sed -i -e 's/app\///' app/*.cc
sed -i -e 's/app\///' app/commands/*.h
'';
buildPhase = ''
runHook preBuild
mkdir -p bin/Release
cmake \
-DLLVM_ENABLE_BACKTRACES=OFF \
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DCMAKE_OSX_ARCHITECTURES="${system}" \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTABLE_OUTPUT_PATH="bin/Release" $@ .
cmake --build . --config Release -- -j $NIX_BUILD_CORES
runHook postBuild
'';
installPhase = ''
runHook preInstall
install --mode +x -D ./bin/Release/snowball $out/bin/unwrapped/snowball
install --mode +x -D ./libSnowball.so $out/lib/libSnowball.so
install --mode +x -D ./libsnowballrt.so $out/lib/libsnowballrt.so
cp -r $src/stdlib "$out"
wrapProgram "$out/bin/unwrapped/snowball" --suffix LD_LIBRARY_PATH ':' "$out/lib"
cat <<EOF > "$out/bin/snowball"
#!/bin/sh
if [ ! -d "\$HOME/.snowball/stdlib" ]; then
echo -e "\x1b[32mCreating \$HOME/.snowball/stdlib\x1b[0m"
mkdir "\$HOME/.snowball"
cp -r "$out/stdlib" "\$HOME/.snowball/stdlib"
fi
exec "$out/bin/unwrapped/snowball" \$@
EOF
chmod +x "$out/bin/snowball"
runHook postInstall
'';
meta = {
description = "Snowball is a low-weight, statically typed, object oriented programming language";
homepage = "https://github.com/snowball-lang/snowball";
license = pkgs.lib.licenses.mit;
platforms = pkgs.lib.platforms.all;
};
};
packages.default = self.packages.${system}.snowball;
devShells.default = pkgs.mkShell {
packages = with pkgs; [
zstd
libsigsegv
cmake
pkg-config
glib
pcre2
libllvm
libbacktrace
libxml2
clang-tools
cmake-language-server
cppcheck
openssl
lldb
nlohmann_json
];
};
});
}