-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1576 from dodona-edu/nix-package
Add package to flake
- Loading branch information
Showing
3 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ lib | ||
, buildNpmPackage | ||
, jq | ||
, unzip | ||
}: | ||
buildNpmPackage rec { | ||
pname = "dolos"; | ||
version = "2.7.1"; | ||
|
||
src = ./.; | ||
|
||
npmDepsHash = "sha256-6/+j8KPcVYhsbeTYFp8WRisuVowlYdzKFCKG5qo/HNU="; | ||
|
||
npmWorkspace="cli"; | ||
|
||
makeWrapperArgs = "--prefix PATH : ${lib.makeBinPath [ unzip ]}"; | ||
|
||
makeCacheWritable = true; | ||
|
||
prePatch = '' | ||
test -f parsers/bash/binding.gyp || (echo -e "\n Submodules are not present, run flake with '.?submodules=1'\n" && exit 1) | ||
''; | ||
|
||
postPatch = '' | ||
${jq}/bin/jq -r 'del(.devDependencies) | del(.scripts.prepare)' parsers/package.json > package.json.tmp | ||
mv package.json.tmp parsers/package.json | ||
''; | ||
|
||
buildInputs = [ unzip ]; | ||
|
||
buildPhase = '' | ||
# Build each needed workspace | ||
for dir in core parsers lib web cli; do | ||
echo "Building dolos-$dir" | ||
npm --workspace="$dir" run build | ||
done | ||
''; | ||
|
||
postInstall = '' | ||
for dir in core parsers lib web; do | ||
# npm creates a symlink to each dependent workspace in node_modules | ||
# overwrite each link with that workspace's build output (with npm pack) | ||
local module="$packageOut/node_modules/@dodona/dolos-$dir" | ||
rm "$module" | ||
while IFS= read -r file; do | ||
local dest="$module/$(dirname "$file")" | ||
mkdir -p "$dest" | ||
cp "$dir/$file" "$dest" | ||
done < <(${jq}/bin/jq --raw-output '.[0].files | map(.path | select(. | startswith("node_modules/") | not)) | join("\n")' <<< "$(npm_config_cache="$HOME/.npm" npm pack --json --dry-run --loglevel=warn --no-foreground-scripts --workspace="$dir")") | ||
done | ||
# dolos-parsers does not include the built parsers with npm pack, copy them | ||
cp -r parsers/build "$packageOut/node_modules/@dodona/dolos-parsers" | ||
''; | ||
|
||
} |