about summary refs log tree commit diff
path: root/pkgs/applications/graphics/imgbrd-grabber
diff options
context:
space:
mode:
authorEvan Stoll <evanjsx@gmail.com>2020-10-19 20:29:30 -0400
committerEvan Stoll <evanjsx@gmail.com>2020-10-19 20:29:30 -0400
commit99e2f6cb8eb52bc37771f1354e74e419efc7827d (patch)
treea6489738cde395de79418eac9c5335671b99acc4 /pkgs/applications/graphics/imgbrd-grabber
parent8ad56944fa000006a057e191f70ff7752c6d540b (diff)
imgbrd-grabber: build from source
Diffstat (limited to 'pkgs/applications/graphics/imgbrd-grabber')
-rw-r--r--pkgs/applications/graphics/imgbrd-grabber/default.nix91
1 files changed, 64 insertions, 27 deletions
diff --git a/pkgs/applications/graphics/imgbrd-grabber/default.nix b/pkgs/applications/graphics/imgbrd-grabber/default.nix
index 994f2a10e6cda..259f40567072b 100644
--- a/pkgs/applications/graphics/imgbrd-grabber/default.nix
+++ b/pkgs/applications/graphics/imgbrd-grabber/default.nix
@@ -1,50 +1,87 @@
 { stdenv
 , cmake
-, fetchzip
-, openssl
-, autoPatchelfHook
-, makeWrapper
-, qtmultimedia
+, fetchFromGitHub
 , wrapQtAppsHook
+, qtmultimedia
+, qttools
+, qtscript
+, qtdeclarative
+, qtbase
+, autogen
+, automake
+, makeWrapper
+, catch2
+, nodejs
+, libpulseaudio
+, openssl
+, rsync
+, typescript
 }:
 stdenv.mkDerivation rec {
   name = "imgbrd-grabber";
+
   version = "7.3.2";
+  src = fetchFromGitHub {
+    owner = "Bionus";
+    repo = "imgbrd-grabber";
+    rev = "v${version}";
+    sha256 = "053rwvcr88fcba0447a6r115cgnqsm9rl066z8d5jacqnhdij58k";
+    fetchSubmodules = true;
+  };
 
   buildInputs = [
-    stdenv.cc.cc.lib
     openssl
-    qtmultimedia
+    makeWrapper
+    libpulseaudio
+    typescript
   ];
 
   nativeBuildInputs = [
-    autoPatchelfHook
-    makeWrapper
+    qtmultimedia
+    qtbase
+    qtdeclarative
+    qttools
+    nodejs
+    cmake
     wrapQtAppsHook
   ];
 
-  installPhase = ''
-    mkdir -p $out/share/grabber
-    cp -R * $out/share/grabber
+  extraOutputsToLink = [ "doc" ];
+
+  postPatch = ''
+    # the package.sh script provides some install helpers
+    # using this might make it easier to maintain/less likely for the
+    # install phase to fail across version bumps
+    patchShebangs ./scripts/package.sh
+
+    # ensure the script uses the rsync package from nixpkgs
+    substituteInPlace ../scripts/package.sh --replace "rsync" "${rsync}/bin/rsync"
+
 
-    mkdir -p $out/bin
-    ln -s $out/share/grabber/Grabber /$out/bin/grabber
+    # the npm build step only runs typescript
+    # run this step directly so it doesn't try and fail to download the unnecessary node_modules, etc.
+    substituteInPlace ./sites/CMakeLists.txt --replace "npm install" "npm run build"
 
-    mkdir -p $out/share/applications
-    mv $out/share/grabber/Grabber.desktop $out/share/applications/
+    # remove the vendored catch2
+    rm -rf tests/src/vendor/catch
 
+    # link the catch2 sources from nixpkgs
+    ln -sf ${catch2.src} tests/src/vendor/catch
   '';
 
-  src = fetchzip {
-    url = "https://github.com/Bionus/imgbrd-grabber/releases/download/v${version}/Grabber_v${version}.tar.gz";
-    sha256 = "05isnqhvcp8ycaj8hx6wn0c3la729mb36dzpmlpxfb1p5dj8p49k";
-  };
+  postInstall = ''
+    # move the binaries to the share/Grabber folder so 
+    # some relative links can be resolved (e.g. settings.ini)
+    mv $out/bin/* $out/share/Grabber/
+    
+    cd ../..
+    # run the package.sh with $out/share/Grabber as the $APP_DIR 
+    sh ./scripts/package.sh $out/share/Grabber
 
-  meta = with stdenv.lib; {
-    homepage = "https://github.com/Bionus/imgbrd-grabber";
-    description = "Very customizable imageboard/booru downloader with powerful filenaming features.";
-    license = licenses.asl20;
-    platforms = [ "x86_64-linux" ];
-    maintainers = with maintainers; [ evanjs ];
-  };
+    # add symlinks for the binaries to $out/bin
+    ln -s $out/share/Grabber/Grabber $out/bin/Grabber
+    ln -s $out/share/Grabber/Grabber-cli $out/bin/Grabber-cli
+  '';
+
+  sourceRoot = "source/src";
 }