about summary refs log tree commit diff
path: root/pkgs/tools
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2022-07-04 12:52:03 +0200
committerGitHub <noreply@github.com>2022-07-04 12:52:03 +0200
commitaac9ff65da0cb5076bef423ccbe2bc658aacb139 (patch)
treebd02123b2b9ff1194db226560e145e0962be3d06 /pkgs/tools
parent9cf60d2e988dd80317ea9f6364adc897ab9a715f (diff)
parentcf19e96438c4b772ed7f4600d35348ccca90ccae (diff)
Merge pull request #179992 from ranfdev/edgedb
edgedb: init at unstable-2022-06-27
Diffstat (limited to 'pkgs/tools')
-rw-r--r--pkgs/tools/networking/edgedb/0001-dynamically-patchelf-binaries.patch34
-rw-r--r--pkgs/tools/networking/edgedb/default.nix55
2 files changed, 89 insertions, 0 deletions
diff --git a/pkgs/tools/networking/edgedb/0001-dynamically-patchelf-binaries.patch b/pkgs/tools/networking/edgedb/0001-dynamically-patchelf-binaries.patch
new file mode 100644
index 0000000000000..ec2dccfc359a9
--- /dev/null
+++ b/pkgs/tools/networking/edgedb/0001-dynamically-patchelf-binaries.patch
@@ -0,0 +1,34 @@
+diff --git a/src/portable/install.rs b/src/portable/install.rs
+index dc0d932..5394fc1 100644
+--- a/src/portable/install.rs
++++ b/src/portable/install.rs
+@@ -133,8 +133,16 @@ fn unpack_package(cache_file: &Path, target_dir: &Path)
+     for entry in arch.entries()? {
+         let mut entry = entry?;
+         let path = entry.path()?;
++        let is_inside_bin = {
++            let mut path_iter = path.iter();
++            path_iter.next(); // discards first folder
++            path_iter.as_path().starts_with("bin")
++        };
+         if let Some(path) = build_path(&target_dir, &*path)? {
+-            entry.unpack(path)?;
++            entry.unpack(&path)?;
++            if is_inside_bin {
++                nix_patchelf_if_needed(&path);
++            }
+         }
+     }
+     bar.finish_and_clear();
+@@ -203,3 +211,11 @@ pub fn package(pkg_info: &PackageInfo) -> anyhow::Result<InstallInfo> {
+ 
+     Ok(info)
+ }
++
++fn nix_patchelf_if_needed(dest_path: &Path) {
++    let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
++        .arg("--set-interpreter")
++        .arg("@dynamicLinker@")
++        .arg(dest_path)
++        .output();
++}
diff --git a/pkgs/tools/networking/edgedb/default.nix b/pkgs/tools/networking/edgedb/default.nix
new file mode 100644
index 0000000000000..9fe04ee70daf9
--- /dev/null
+++ b/pkgs/tools/networking/edgedb/default.nix
@@ -0,0 +1,55 @@
+{ stdenv
+, lib
+, runCommand
+, patchelf
+, fetchFromGitHub
+, rustPlatform
+, makeWrapper
+, pkg-config
+, curl
+, Security
+, CoreServices
+, libiconv
+, xz
+, perl
+, substituteAll
+}:
+
+rustPlatform.buildRustPackage rec {
+  pname = "edgedb";
+  version = "unstable-2022-06-27";
+
+  src = fetchFromGitHub {
+    owner = "edgedb";
+    repo = "edgedb-cli";
+    rev = "3c65c8bf0a09988356ad477d0ae234182f809b0a";
+    sha256 = "sha256-UqoRa5ZbPJEHo9wyyygrN1ssorgY3cLw/mMrCDXr4gw=";
+  };
+
+  cargoSha256 = "sha256-6HJkkem44+dat5bmVEM+7GSJFjCz1dYZeRIPEoEwNlI=";
+
+  nativeBuildInputs = [ makeWrapper pkg-config perl ];
+
+  buildInputs = [
+    curl
+  ] ++ lib.optionals stdenv.isDarwin [ CoreServices Security libiconv xz ];
+
+  checkFeatures = [ ];
+
+  patches = [
+    (substituteAll {
+      src = ./0001-dynamically-patchelf-binaries.patch;
+      inherit patchelf;
+      dynamicLinker = stdenv.cc.bintools.dynamicLinker;
+    })
+  ];
+
+  doCheck = false;
+
+  meta = with lib; {
+    description = "EdgeDB cli";
+    homepage = "https://www.edgedb.com/docs/cli/index";
+    license = with licenses; [ asl20 /* or */ mit ];
+    maintainers = [ maintainers.ranfdev ];
+  };
+}