Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 9
feat: make use of Nix files to set up dev env#22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
f6543b13a89bf67534642885db6bcfde596b7b5eeda8c190f6b487ff5686fcf7f7804217b2b04b429723File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -9,25 +9,54 @@ RUN useradd --uid $USER_UID --gid $USER_GID --shell /bin/bash --create-home deve | ||
| # Install sudo first | ||
| RUN apt-get update | ||
| RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends sudo | ||
| RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl git git-restore-mtime sudo xz-utils | ||
| # No Sudo Prompt - thanks Electron for this | ||
| RUN echo 'developer ALL=NOPASSWD: ALL' >> /etc/sudoers.d/developer | ||
| RUN echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep | ||
| ENV DEBIAN_FRONTEND=1 | ||
| ENV PATH=/usr/lib/ccache:$PATH | ||
| # Copy scripts and make them executable by both root and developer | ||
| COPY --chown=root:developer --chmod=0755 ./scripts/ /home/developer/scripts/ | ||
| RUN /home/developer/scripts/install.sh | ||
| RUN /home/developer/scripts/ccache.sh | ||
| USER developer | ||
| RUN /home/developer/scripts/clone.sh | ||
| # Installing Nix using the same script test-shared workflow uses upstream. | ||
| # See https://github.com/nodejs/node/blob/HEAD/.github/workflows/test-shared.yml | ||
| # See https://github.com/cachix/install-nix-action/blob/HEAD/install-nix.sh | ||
| RUN curl -L "https://github.com/$(sed -nE 's#.*(cachix/install-nix-action)@([a-f0-9]+).*#\1/raw/\2#p' /home/developer/nodejs/node/.github/workflows/test-shared.yml)/install-nix.sh" | \ | ||
aduh95 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| USER=developer \ | ||
| INPUT_SET_AS_TRUSTED_USER=true \ | ||
| INPUT_ENABLE_KVM=true \ | ||
| INPUT_EXTRA_NIX_CONFIG= \ | ||
| INPUT_INSTALL_OPTIONS= \ | ||
| RUNNER_TEMP=$(mktemp -d) GITHUB_ENV=/dev/null GITHUB_PATH=/dev/null bash | ||
| ENV NIX_PROFILES="/nix/var/nix/profiles/default /home/developer/.nix-profile" | ||
| ENV NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt | ||
| ENV PATH="/home/developer/.local/bin:/home/developer/.nix-profile/bin:${PATH}" | ||
| # Installing Cachix, and set it up to reuse binaries build by the CI. | ||
| RUN nix-env -iA cachix -f https://cachix.org/api/v1/install | ||
| RUN USER=developer cachix use nodejs | ||
| # Installing direnv | ||
| RUN nix profile add nixpkgs#nix-direnv nixpkgs#direnv -I nixpkgs=/home/developer/nodejs/node/tools/nix/pkgs.nix | ||
| RUN mkdir -p /home/developer/.config/direnv && \ | ||
| echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > /home/developer/.config/direnv/direnvrc | ||
| RUN echo 'eval "$(direnv hook bash)"' >> /home/developer/.bashrc | ||
| # Setting up direnv for the local clone, see envrc/README.md for more info | ||
| COPY --chown=root:developer --chmod=0755 ./envrc/ /home/developer/envrc/ | ||
| ARG IMAGE_VARIANT=static-libs | ||
| RUN cp "/home/developer/envrc/${IMAGE_VARIANT}.envrc" /home/developer/nodejs/node/.envrc | ||
joyeecheung marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page.
| ||
| RUN direnv allow /home/developer/nodejs/node | ||
| RUN /home/developer/scripts/build.sh | ||
| ENV PATH=/home/developer/.local/bin:$PATH | ||
| WORKDIR /home/developer/nodejs/node | ||
| RUN /home/developer/scripts/install-node.sh | ||
| RUN /home/developer/scripts/ncu.sh | ||
| # direnv will automatically load the nix environment when entering the directory | ||
| ENTRYPOINT ["/bin/bash", "-l"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Image variants using Nix and direnv | ||
| `.envrc` files are consumed by [nix-direnv][], and will install software and | ||
| environment variables defined in the [`shell.nix`][] in the nodejs/node repository. | ||
| To add an image variant, add a new file starting with `use nix` with the flags such as: | ||
| - [`--impure`][]: to make sure user can still access non-Nix software. | ||
| - [`-I nixpkgs=/home/developer/nodejs/node/tools/nix/pkgs.nix`][`-I`]: | ||
| that defines which version of the [NixOS/nixpkgs][] repository it should load. | ||
| - [`--arg <key> <nix-value>`][`--arg`]: Override the default values defines in the | ||
| [`shell.nix`][] with some custom value. E.g., pass | ||
| `--arg extraConfigFlags '["--enable-asan" "--enable-ubsan"]'` to | ||
| enable ASAN and UBSAN. | ||
| - [`--argstr <key> <string-value>`][`--argstr`]: Useful to avoid the double quoting, | ||
| e.g. instead of `--arg icu '"small"'`, it is equivalent to pass `--argstr icu small`. | ||
aduh95 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| It is possible to add custom environment variables, or to override Nix-defined ones by | ||
| adding `export NAME_OF_THE_VAR=value` lines at the end of the file, however it is | ||
| preferred to keep all environment variable definitions in one place. | ||
| [nix-direnv]: https://github.com/nix-community/nix-direnv | ||
| [`shell.nix`]: https://github.com/nodejs/node/blob/HEAD/shell.nix | ||
| [NixOS/nixpkgs]: https://github.com/NixOS/nixpkgs | ||
| [`--impure`]: https://nix.dev/manual/nix/2.33/command-ref/nix-shell.html#opt-impure | ||
| [`-I`]: https://nix.dev/manual/nix/2.33/command-ref/nix-shell.html#opt-I | ||
| [`--arg`]: https://nix.dev/manual/nix/2.33/command-ref/nix-shell.html#opt-arg | ||
| [`--argstr`]: https://nix.dev/manual/nix/2.33/command-ref/nix-shell.html#opt-argstr | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| use nix --impure -I nixpkgs=/home/developer/nodejs/node/tools/nix/pkgs.nix |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| use nix --impure -I nixpkgs=/home/developer/nodejs/node/tools/nix/pkgs.nix \ | ||
| --arg sharedLibDeps '{}' \ | ||
| --argstr icu full |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| #!/usr/bin/env bash | ||
| set -e # Exit with nonzero exit code if anything fails | ||
| set -xe | ||
| /home/developer/nodejs/node/configure --ninja && make -C /home/developer/nodejs/node | ||
| cd /home/developer/nodejs/node | ||
| eval "$(direnv export bash)" | ||
| # Build tools and env variables (including e.g. BUILD_WITH=ninja) are | ||
| # defined in https://github.com/nodejs/node/blob/HEAD/shell.nix | ||
| make -C /home/developer/nodejs/node build-ci | ||
aduh95 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
| set -e # Exit with nonzero exit code if anything fails | ||
| set -xe | ||
| mkdir -p /home/developer/nodejs | ||
| cd /home/developer/nodejs | ||
| git clone https://github.com/nodejs/node.git --single-branch --branch main --depth 1 | ||
| cd /home/developer/nodejs/node | ||
| git remote add upstream https://github.com/nodejs/node.git | ||
| git restore-mtime # Restore file modification times to commit times for build cache to match. | ||
| git clone https://github.com/nodejs/node.git --depth 1 /home/developer/nodejs/node | ||
| ( | ||
| cd /home/developer/nodejs/node | ||
| git remote add upstream https://github.com/nodejs/node.git | ||
| git restore-mtime # Restore file modification times to commit times for build cache to match. | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| #!/usr/bin/env bash | ||
| set -e # Exit with nonzero exit code if anything fails | ||
| set -xe | ||
| cd /home/developer/nodejs/node | ||
| eval "$(direnv export bash)" | ||
| make install PREFIX=/home/developer/.local -C /home/developer/nodejs/node | ||
| echo '' >> /home/developer/.bashrc | ||
| echo 'export PATH=/home/developer/.local/bin:$PATH' >> /home/developer/.bashrc | ||
| { | ||
| echo '' | ||
| # Expose the PATH generated by Nix + the recently built `node` installation | ||
| echo 'export PATH=/home/developer/.local/bin:$PATH' | ||
| } >> /home/developer/.bashrc |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| #!/usr/bin/env bash | ||
| set -e # Exit with nonzero exit code if anything fails | ||
| set -xe | ||
| npm install -g @node-core/utils | ||
| cd /home/developer/nodejs/node | ||
| eval "$(direnv export bash)" | ||
| ncu-config set upstream upstream | ||
| ncu-config set branch main |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.