diff --git a/pkgs/by-name/sp/speedscope/fix-shebang.patch b/pkgs/by-name/sp/speedscope/fix-shebang.patch new file mode 100644 index 000000000000..690b67429efd --- /dev/null +++ b/pkgs/by-name/sp/speedscope/fix-shebang.patch @@ -0,0 +1,13 @@ +diff --git a/scripts/prepack.sh b/scripts/prepack.sh +index 2172706..1f8f152 100755 +--- a/scripts/prepack.sh ++++ b/scripts/prepack.sh +@@ -41,7 +41,7 @@ mkdir -p "$OUTDIR" + # Place info about the current commit into the build dir to easily identify releases + npm ls -depth -1 | head -n 1 | cut -d' ' -f 1 > "$OUTDIR"/release.txt + date >> "$OUTDIR"/release.txt +-git rev-parse HEAD >> "$OUTDIR"/release.txt ++cp COMMIT "$OUTDIR"/release.txt + + # Place a json schema for the file format into the build directory too + node scripts/generate-file-format-schema-json.js > "$OUTDIR"/file-format-schema.json diff --git a/pkgs/by-name/sp/speedscope/package.nix b/pkgs/by-name/sp/speedscope/package.nix new file mode 100644 index 000000000000..114bf98add0c --- /dev/null +++ b/pkgs/by-name/sp/speedscope/package.nix @@ -0,0 +1,58 @@ +{ + lib, + buildNpmPackage, + fetchFromGitHub, + versionCheckHook, +}: + +buildNpmPackage rec { + pname = "speedscope"; + version = "1.22.2"; + + src = fetchFromGitHub { + owner = "jlfwong"; + repo = "speedscope"; + tag = "v${version}"; + hash = "sha256-JzlS5onVac1UKJUl1YYE7a3oWk2crMyuowea8a7UoOo="; + + # scripts/prepack.sh wants to extract the git commit from .git + # We don't want to keep .git for reproducibility reasons, so save the commit + # to a file and patch the script. + leaveDotGit = true; + postFetch = '' + ( cd $out; git rev-parse HEAD > COMMIT ) + rm -rf $out/.git + ''; + }; + + npmDepsHash = "sha256-3LCixJJyz3O6xQxP0A/WyQXsDvkXpdo7KYNDoufZVS4="; + + patches = [ + ./fix-shebang.patch + ]; + + postConfigure = '' + patchShebangs scripts + ''; + + dontNpmBuild = true; + + postFixup = '' + # Remove some dangling symlinks + rm $out/lib/node_modules/speedscope/node_modules/.bin/sshpk* + ''; + + nativeInstallCheckInputs = [ + versionCheckHook + ]; + doInstallCheck = true; + + meta = { + description = "Fast and interactive web-based viewer for performance profiles"; + homepage = "https://github.com/jlfwong/speedscope"; + license = lib.licenses.mit; + platforms = lib.platforms.linux; + mainProgram = "speedscope"; + maintainers = with lib.maintainers; [ thomasjm ]; + }; +}