diff --git a/pkgs/by-name/su/super-productivity/package.nix b/pkgs/by-name/su/super-productivity/package.nix index 787b57039a6e..3be5ecbcb5ef 100644 --- a/pkgs/by-name/su/super-productivity/package.nix +++ b/pkgs/by-name/su/super-productivity/package.nix @@ -7,25 +7,66 @@ makeDesktopItem, nix-update-script, npm-lockfile-fix, + prefetch-npm-deps, + rsync, stdenv, }: buildNpmPackage rec { pname = "super-productivity"; - version = "13.0.10"; + version = "14.0.5"; src = fetchFromGitHub { owner = "johannesjo"; repo = "super-productivity"; tag = "v${version}"; - hash = "sha256-2K/6T4f9tLlrKimT/DPSdoz8LHij5nsaF6BWSQf6u7U="; + hash = "sha256-VoE86uBl6DM6aXz7MLYekEzfixVSLjLL3yYgc2vBhp0="; postFetch = '' - ${lib.getExe npm-lockfile-fix} -r $out/package-lock.json + find $out -name package-lock.json -exec ${lib.getExe npm-lockfile-fix} -r {} \; ''; }; - npmDepsHash = "sha256-l9P11ZvLYiTu/cVPQIw391ZTJ0K+cNPUzoVMsdze2uo="; + # Use custom fetcher for deps because super-productivity uses multiple + # package-lock.json files to manage plugins. It checks all lock + # files and produces a merged output. This should still be compatible + # with nix-update. + npmDeps = stdenv.mkDerivation ( + lib.fetchers.normalizeHash { } { + pname = "super-productivity-deps"; + inherit version src; + + nativeBuildInputs = [ + prefetch-npm-deps + rsync + ]; + + # Some lockfiles do not include any dependencies to install so + # prefertch-npm-deps produces an error. Those can be ignored with + # this flag. + env.FORCE_EMPTY_CACHE = true; + + buildPhase = '' + mkdir -p $out + find -name package-lock.json | while read -r lockfile; do + prefetch-npm-deps $lockfile /tmp/cache + # Merge output + rsync -a /tmp/cache/ $out + rm -rf /tmp/cache + done + # Ensure that the root package-lock.json is placed in the output. + # This means only the root lockfile is checked for consistancy, + # but that should not be an issue. + cp package-lock.json $out + ''; + + dontInstall = true; + + outputHashMode = "recursive"; + hash = "sha256-Jj7ulTjC19Q9PmOeVui/FAyfpsSviGLHiiz8gwsLXAg="; + } + ); + makeCacheWritable = true; env = { @@ -64,13 +105,13 @@ buildNpmPackage rec { if stdenv.hostPlatform.isDarwin then '' mkdir -p $out/Applications - cp -r "app-builds/mac"*"/Super Productivity.app" "$out/Applications" + cp -r ".tmp/app-builds/mac"*"/Super Productivity.app" "$out/Applications" makeWrapper "$out/Applications/Super Productivity.app/Contents/MacOS/Super Productivity" "$out/bin/super-productivity" '' else '' mkdir -p $out/share/{super-productivity,icons/hicolor/scalable/apps} - cp -r app-builds/*-unpacked/resources/app.asar $out/share/super-productivity + cp -r .tmp/app-builds/*-unpacked/resources/app.asar $out/share/super-productivity cp electron/assets/icons/ico-circled.svg $out/share/icons/hicolor/scalable/apps/super-productivity.svg makeWrapper '${lib.getExe electron}' "$out/bin/super-productivity" \