Skip to content

Commit

Permalink
chore(directory-structure): Add nix directory
Browse files Browse the repository at this point in the history
  • Loading branch information
haruki7049 committed Oct 20, 2024
1 parent 341134b commit 4b83566
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
45 changes: 4 additions & 41 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,50 +1,13 @@
self: super:
let
lib = super.lib;
fetchurl = super.fetchurl;
rpath = super.lib.makeLibraryPath [ super.pkgs.gcc-unwrapped ];
mkBinaryInstall =
{
pname ? "surrealdb",
version,
url,
sha256,
}:
super.stdenv.mkDerivation rec {
inherit pname version;

src = fetchurl { inherit url sha256; };

sourceRoot = ".";

installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp surreal $out/bin/surreal
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 lib; {
description = "A scalable, distributed, collaborative, document-graph database, for the realtime web";
homepage = "https://surrealdb.com/";
mainProgram = "surreal";
license = licenses.bsl11;
};
};
mkBinaryInstall-x86_64-linux = super.callPackage ./nix/mkBinInstall.x86_64-linux.nix { };
in
{
surrealdb = {
"1.4.2" = mkBinaryInstall {
"1.4.2" = mkBinaryInstall-x86_64-linux {
version = "1.4.2";
url = "https://github.com/surrealdb/surrealdb/releases/download/v1.4.2/surreal-v1.4.2.linux-arm64.tgz";
sha256 = "0xdaz8gy787rf3f3frk7czkdi1fyy5d24xip9lsnx7d88s02slw6";
url = "https://github.com/surrealdb/surrealdb/releases/download/v1.4.2/surreal-v1.4.2.linux-amd64.tgz";
sha256 = "10hswwyckfcysindffiaf8z8g0lib800j1id8pws70250s4dz895";
};
};
}
42 changes: 42 additions & 0 deletions nix/mkBinInstall.x86_64-linux.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
lib,
fetchurl,
stdenv,
rpath ? lib.makeLibraryPath [ gcc-unwrapped ],
gcc-unwrapped,
}:

{
pname ? "surrealdb",
version,
url,
sha256,
}:
stdenv.mkDerivation {
inherit pname version;

src = fetchurl { inherit url sha256; };

sourceRoot = ".";

installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp surreal $out/bin/surreal
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 lib; {
description = "A scalable, distributed, collaborative, document-graph database, for the realtime web";
homepage = "https://surrealdb.com/";
mainProgram = "surreal";
license = licenses.bsl11;
};
}

0 comments on commit 4b83566

Please sign in to comment.