diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..015ca42 --- /dev/null +++ b/default.nix @@ -0,0 +1,14 @@ +{ pkgs ? import {} }: +let + inherit (pkgs) callPackage; + inherit (pkgs.lib) filterAttrs mapAttrs; + inherit (builtins) substring readDir; + + here = ./.; + + want = filterAttrs (name: type: + type == "directory" && (substring 0 1 name) != "." + ) (readDir here); +in mapAttrs (name: type: + callPackage (import here/name) +) want diff --git a/sourcetrail/default.nix b/sourcetrail/default.nix new file mode 100644 index 0000000..a2aba5a --- /dev/null +++ b/sourcetrail/default.nix @@ -0,0 +1,44 @@ +{lib, stdenv, pkgs, fetchurl, buildFHSUserEnv}: +let + libPath = lib.makeLibraryPath (with pkgs; [ + zlib + expat + ]); + + sourcetrail = stdenv.mkDerivation rec { + name = "sourcetrail-${version}"; + version = "2018.2.77"; + + src = fetchurl { + name = "${name}.tar.gz"; + url = "https://www.sourcetrail.com/downloads/${version}/linux/64bit"; + sha256 = "1edfe95818f656840640d360df0cee72944af668d09b1a83cb6cb967ccaee719"; + sha512 = "667b45449689d8f22a2a3ab2b9ad5d7d0c919fa61701e164927624df8843804b7b3f4c19e38e41da4afcff892a464157bea4cbffaa38e529bda364d1c284ee52"; + }; + + phases = [ "unpackPhase" "installPhase" ]; + + installPhase = '' + mkdir -p $out/{opt/sourcetrail,usr,bin} + rm install.sh uninstall.sh + mv setup/share $out/usr/ + mv * $out/opt/sourcetrail/ + + substituteInPlace $out/usr/share/applications/sourcetrail.desktop --replace '/usr/bin' "$out/bin" + + for exe in $out/opt/sourcetrail/{Sourcetrail,sourcetrail_indexer}; do + patchelf \ + --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" \ + $exe + done + + ln -s $out/opt/sourcetrail/Sourcetrail.sh $out/bin/sourcetrail + ''; + }; +in buildFHSUserEnv rec { + name = sourcetrail.name; + + profile = "LD_LIBRARY_PATH=${libPath}:$LD_LIBRARY_PATH"; + targetPkgs = pkgs: [ sourcetrail ]; + runScript = "sourcetrail"; +}