Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions pkgs/development/node-packages/generate.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/usr/bin/env nix-shell
#! nix-shell -I nixpkgs=../../.. -i bash -p nodePackages.node2nix
# NOTE: Script must be run from the node-packages directory

#! nix-shell shell-generate.nix -i bash
set -eu -o pipefail

rm -f node-env.nix
node2nix --nodejs-10 -i node-packages-v10.json -o node-packages-v10.nix -c composition-v10.nix
node2nix --nodejs-12 -i node-packages-v12.json -o node-packages-v12.nix -c composition-v12.nix
node2nix --nodejs-13 -i node-packages-v13.json -o node-packages-v13.nix -c composition-v13.nix
cd "$NODE_NIXPKGS_PATH/pkgs/development/node-packages"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you know you can have the current path in nix?

let here = toString ./.;

You don’t have to do any tmpdir/cd magic, just use here as an absolute path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try it out with nix-instantiate --eval -E 'toString ./.'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tmpdir magic is in order to not break nixpkgs if something goes wrong during evaluation (which happens if your network is unstable for instance)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d argue that’s what git is for, but I’m fine with the code as it stands.

rm -f ./node-env.nix
for version in 10 12 13; do
tmpdir=$(mktemp -d)
node2nix --nodejs-$version -i node-packages-v$version.json -o $tmpdir/node-packages-v$version.nix -c $tmpdir/composition-v$version.nix
if [ $? -eq 0 ]; then
mv $tmpdir/node-packages-v$version.nix .
mv $tmpdir/composition-v$version.nix .
fi
done
cd -
9 changes: 9 additions & 0 deletions pkgs/development/node-packages/shell-generate.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ nixpkgs ? import ../../.. {} }:
with nixpkgs;
mkShell {
buildInputs = [
bash nodePackages.node2nix
];
NODE_NIXPKGS_PATH = toString ./.;
}