-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from Perigord-Kleisli/dev
Make repo a flake and make ld-linux be dynamically located
- Loading branch information
Showing
6 changed files
with
193 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
{ | ||
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 = "0.0.8"; | ||
|
||
src = ./.; | ||
|
||
nativeBuildInputs = with pkgs; [cmake pkg-config makeWrapper]; | ||
buildInputs = with pkgs; [zstd libxml2 libsigsegv glib pcre2 libllvm libbacktrace]; | ||
|
||
patchPhase = '' | ||
sed -i -e '/CPMAddPackage(/,/)/d' CMakeLists.txt | ||
sed -i -e 's/app\///' app/*.cc | ||
sed -i -e 's/app\///' app/commands/*.h | ||
''; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
mkdir -p bin/Release | ||
#HACK: uses RelWithDebInfo since normal realease causes a segfault | ||
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=RelWithDebInfo \ | ||
-DEXECUTABLE_OUTPUT_PATH="bin/Release" $@ . | ||
cmake --build . --config RelWithDebInfo -- -j $NIX_BUILD_CORES | ||
runHook postBuild | ||
''; | ||
installPhase = let | ||
snowball = '' | ||
''; | ||
in '' | ||
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 | ||
]; | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters