summary refs log tree commit diff
path: root/pkgs/tools/text/gpt2tc/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
committerAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
commit62614cbef7da005c1eda8c9400160f6bcd6546b8 (patch)
treec2630f69080637987b68acb1ee8676d2681fe304 /pkgs/tools/text/gpt2tc/default.nix
parentd9c82ed3044c72cecf01c6ea042489d30914577c (diff)
parente24069138dfec3ef94f211f1da005bb5395adc11 (diff)
downloadnixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.gz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.bz2
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.lz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.xz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.zst
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.zip
Merge branch 'nixpkgs-update' into master
Diffstat (limited to 'pkgs/tools/text/gpt2tc/default.nix')
-rw-r--r--pkgs/tools/text/gpt2tc/default.nix44
1 files changed, 44 insertions, 0 deletions
diff --git a/pkgs/tools/text/gpt2tc/default.nix b/pkgs/tools/text/gpt2tc/default.nix
new file mode 100644
index 00000000000..3714a418548
--- /dev/null
+++ b/pkgs/tools/text/gpt2tc/default.nix
@@ -0,0 +1,44 @@
+{ lib, stdenv, fetchurl, autoPatchelfHook, python3 }:
+
+stdenv.mkDerivation rec {
+  pname = "gpt2tc";
+  version = "2021-04-24";
+
+  src = fetchurl {
+    url = "https://bellard.org/libnc/gpt2tc-${version}.tar.gz";
+    hash = "sha256-kHnRziSNRewifM/oKDQwG27rXRvntuUUX8M+PUNHpA4=";
+  };
+
+  patches = [
+    # Add a shebang to the python script so that nix detects it as such and
+    # wraps it properly. Otherwise, it runs in shell and freezes the system.
+    ./0001-add-python-shebang.patch
+  ];
+
+  nativeBuildInputs = [ autoPatchelfHook ];
+
+  buildInputs = [
+    (python3.withPackages (p: with p; [ numpy tensorflow ]))
+  ];
+
+  installPhase = ''
+    runHook preInstall
+
+    install -D -m755 -t $out/lib libnc${stdenv.hostPlatform.extensions.sharedLibrary}
+    addAutoPatchelfSearchPath $out/lib
+    install -D -m755 -t $out/bin gpt2tc
+    install -T -m755 download_model.sh $out/bin/gpt2-download-model
+    install -T -m755 gpt2convert.py $out/bin/gpt2-convert
+    install -D -m644 -t $out/share/gpt2tc readme.txt gpt2vocab.txt Changelog
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Text completion and compression using GPT-2";
+    homepage = "https://bellard.org/nncp/gpt2tc.html";
+    license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ anna328p ];
+  };
+}