Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: automated pkg definition #11

Closed
wants to merge 8 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 63 additions & 38 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,48 +1,73 @@
self: super: {
surrealdb = {
"1.4.2" = let
inherit (super.stdenv.hostPlatform) system;
rpath = super.lib.makeLibraryPath [ super.pkgs.gcc-unwrapped ];
in super.stdenv.mkDerivation rec {
pname = "surrealdb";
version = "1.4.2";

src = {
x86_64-linux = super.fetchurl {
url =
"https://github.com/surrealdb/surrealdb/releases/download/v${version}/surreal-v${version}.linux-amd64.tgz";
hash = "sha256-JaHfiAZFgKP5RS0GCQBakYKHPnIqOtds1J65yTznGoI=";
};
aarch64-linux = super.fetchurl {
url =
"https://github.com/surrealdb/surrealdb/releases/download/v${version}/surreal-v${version}.linux-arm64.tgz";
hash = "sha256-hlMtgEaonW41TTd2Ilrx3oXY5mdnZjfccPmg4x/6qnU=";
};
}.${system};
surrealdb = let
pname = "surrealdb";
inherit (super.stdenv.hostPlatform) system;
rpath = super.lib.makeLibraryPath [ super.pkgs.gcc-unwrapped ];

releases = builtins.fromJSON (builtins.readFile ./sources.json);
assets = builtins.concatMap (release: release.assets) releases;
downloadURLs = builtins.map (asset: asset.browser_download_url) assets;

x86_64-linuxURLs =
builtins.filter (link: super.lib.strings.hasInfix "linux-amd" link)
downloadURLs;
aarch64-linuxURLs =
builtins.filter (link: super.lib.strings.hasInfix "linux-arm64" link)
downloadURLs;
x86_64-linuxUrlFetcher = version:
builtins.head
(builtins.filter (url: super.lib.strings.hasInfix version url)
x86_64-linuxURLs);
aarch64-linuxUrlFetcher = version:
builtins.head
(builtins.filter (url: super.lib.strings.hasInfix version url)
aarch64-linuxURLs);

sourceRoot = ".";
mkBinaryInstall = version: x86_64-linuxHash: aarch64-linuxHash:
super.stdenv.mkDerivation rec {
inherit pname version;

installPhase = ''
runHook preInstall
src = {
x86_64-linux = super.fetchurl {
url = x86_64-linuxUrlFetcher version;
hash = x86_64-linuxHash;
};
aarch64-linux = super.fetchurl {
url = aarch64-linuxUrlFetcher version;
hash = aarch64-linuxHash;
};
}.${system};

mkdir -p $out/bin
cp surreal $out/bin/surreal
sourceRoot = ".";

runHook postInstall
'';
installPhase = ''
runHook preInstall

postFixup = ''
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$out/bin/surreal" || true
patchelf --set-rpath ${rpath} "$out/bin/surreal" || true
'';
mkdir -p $out/bin
cp surreal $out/bin/surreal

meta = with super.lib; {
description =
"A scalable, distributed, collaborative, document-graph database, for the realtime web";
homepage = "https://surrealdb.com/";
mainProgram = "surreal";
license = licenses.bsl11;
runHook postInstall
'';

postFixup = ''
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$out/bin/surreal" || true
patchelf --set-rpath ${rpath} "$out/bin/surreal" || true
'';

meta = with super.lib; {
description =
"A scalable, distributed, collaborative, document-graph database, for the realtime web";
homepage = "https://surrealdb.com/";
mainProgram = "surreal";
license = licenses.bsl11;
};
};
};
in {
"1.4.2" = mkBinaryInstall "1.4.2"
"sha256-JaHfiAZFgKP5RS0GCQBakYKHPnIqOtds1J65yTznGoI="
"sha256-hlMtgEaonW41TTd2Ilrx3oXY5mdnZjfccPmg4x/6qnU=";
"1.4.0" = mkBinaryInstall "1.4.0"
"sha256-zvf+97Pl0Iw/WW9g/TMMCFHPt88emxvUZpdMWmhVAeA="
"sha256-hlMtgEaonW41TTd2Ilrx3oXY5mdnZjfccPmg4x/6qnU=";
};
}