├── .envrc ├── .github ├── CODEOWNERS ├── pull_request_template.md └── workflows │ ├── update.yml │ └── ci.yml ├── bun.lockb ├── nodejs ├── overlay.nix ├── setup-hook.sh ├── gen.ts ├── default.nix ├── versions.json └── build-node.nix ├── ruby ├── overlay.nix └── default.nix ├── python ├── overlay.nix └── default.nix ├── rust ├── overlay.nix └── default.nix ├── package.json ├── gen.ts ├── biome.jsonc ├── tsconfig.json ├── LICENSE ├── flake.nix ├── .gitignore └── flake.lock /.envrc: -------------------------------------------------------------------------------- 1 | use flake . 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @replit/devex 2 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/replit/overlang/main/bun.lockb -------------------------------------------------------------------------------- /nodejs/overlay.nix: -------------------------------------------------------------------------------- 1 | final: _: { 2 | nodejsVersions = final.callPackage ./default.nix {}; 3 | } 4 | -------------------------------------------------------------------------------- /ruby/overlay.nix: -------------------------------------------------------------------------------- 1 | nixpkgs-ruby: final: prev: { 2 | rubyVersions = final.callPackage ./. {inherit nixpkgs-ruby;}; 3 | } 4 | -------------------------------------------------------------------------------- /python/overlay.nix: -------------------------------------------------------------------------------- 1 | nixpkgs-python: final: prev: { 2 | pythonVersions = final.callPackage ./. {inherit nixpkgs-python;}; 3 | } 4 | -------------------------------------------------------------------------------- /nodejs/setup-hook.sh: -------------------------------------------------------------------------------- 1 | addNodePath () { 2 | addToSearchPath NODE_PATH "$1/lib/node_modules" 3 | } 4 | 5 | addEnvHooks "$hostOffset" addNodePath 6 | -------------------------------------------------------------------------------- /rust/overlay.nix: -------------------------------------------------------------------------------- 1 | rust-overlay: final: prev: { 2 | rustVersions = final.callPackage ./default.nix { 3 | inherit rust-overlay; 4 | }; 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "overlang-scripts", 3 | "module": "gen.ts", 4 | "type": "module", 5 | "devDependencies": { 6 | "@types/bun": "latest" 7 | }, 8 | "peerDependencies": { 9 | "typescript": "^5.0.0" 10 | }, 11 | "dependencies": { 12 | "@sinclair/typebox": "^0.32.20" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gen.ts: -------------------------------------------------------------------------------- 1 | import nodejs from "./nodejs/gen"; 2 | import assert from "node:assert"; 3 | 4 | const versionsJSONData = await nodejs(); 5 | // newline appended to satisfy biome 6 | const versionsJSON = `${JSON.stringify(versionsJSONData, null, "\t")}\n`; 7 | const written = await Bun.write("nodejs/versions.json", versionsJSON); 8 | assert.equal(written, versionsJSON.length, "full versions.json wasn't written"); 9 | -------------------------------------------------------------------------------- /biome.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://biomejs.dev/schemas/1.6.1/schema.json", 3 | "organizeImports": { 4 | "enabled": true 5 | }, 6 | "linter": { 7 | "enabled": true, 8 | "rules": { 9 | "recommended": true, 10 | "style": { 11 | "useNumberNamespace": "off" 12 | } 13 | } 14 | }, 15 | "vcs": { 16 | "enabled": true, 17 | "clientKind": "git", 18 | "useIgnoreFile": true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Why 2 | === 3 | 4 | 5 | 6 | What changed 7 | ============ 8 | 9 | 10 | 11 | Test plan 12 | ========= 13 | 14 | 15 | -------------------------------------------------------------------------------- /.github/workflows/update.yml: -------------------------------------------------------------------------------- 1 | name: update overlays 2 | run-name: update overlays 3 | on: 4 | schedule: 5 | - cron: "0 8 * * *" 6 | 7 | jobs: 8 | update-overlays: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - name: Install Nix 13 | uses: DeterminateSystems/nix-installer-action@main 14 | - name: Use Magic Nix Cache 15 | uses: DeterminateSystems/magic-nix-cache-action@main 16 | - name: Run update script 17 | exec: nix run .#update-overlays 18 | -------------------------------------------------------------------------------- /python/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | nixpkgs-python, 4 | system, 5 | }: let 6 | python-pkgs = nixpkgs-python.packages.${system}; 7 | 8 | isPythonVersion = version: let 9 | semver-parts = lib.splitString "." version; 10 | 11 | is-v3-release = (lib.elemAt semver-parts 0) == "3"; 12 | is-three-version-parts = builtins.length semver-parts == 3; 13 | is-3-0-0 = semver-parts == ["3" "0"]; 14 | in 15 | is-3-0-0 || is-v3-release && is-three-version-parts; 16 | 17 | versions = lib.filterAttrs (version: _: isPythonVersion version) python-pkgs; 18 | in 19 | versions 20 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // Enable latest features 4 | "lib": ["ESNext"], 5 | "target": "ESNext", 6 | "module": "ESNext", 7 | "moduleDetection": "force", 8 | "jsx": "react-jsx", 9 | "allowJs": true, 10 | 11 | // Bundler mode 12 | "moduleResolution": "bundler", 13 | "allowImportingTsExtensions": true, 14 | "verbatimModuleSyntax": true, 15 | "noEmit": true, 16 | 17 | // Best practices 18 | "strict": true, 19 | "skipLibCheck": true, 20 | "noFallthroughCasesInSwitch": true, 21 | 22 | // Some stricter flags (disabled by default) 23 | "noUnusedLocals": false, 24 | "noUnusedParameters": false, 25 | "noPropertyAccessFromIndexSignature": false 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ruby/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | nixpkgs-ruby, 4 | system, 5 | }: let 6 | isRubyVersion = version: let 7 | version-part = builtins.elemAt (lib.splitString "-" version); 8 | 9 | is-ruby = version-part 0 == "ruby"; 10 | 11 | is-star-alias = lib.hasSuffix "*" version; 12 | is-other-alias = lib.pipe (version-part 1) [ 13 | (lib.splitString ".") 14 | builtins.length 15 | (len: len != 3) 16 | ]; 17 | is-alias = is-star-alias || is-other-alias; 18 | 19 | is-not-supported = lib.hasPrefix "1." (version-part 1); 20 | in 21 | is-ruby && !is-alias && !is-not-supported; 22 | 23 | versions = lib.pipe nixpkgs-ruby.packages.${system} [ 24 | (lib.filterAttrs (version: _: isRubyVersion version)) 25 | lib.attrsToList 26 | (builtins.map ({ 27 | name, 28 | value, 29 | }: { 30 | inherit value; 31 | name = lib.removePrefix "ruby-" name; 32 | })) 33 | builtins.listToAttrs 34 | ]; 35 | in 36 | versions 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Replit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: checks 2 | run-name: checks 3 | on: 4 | - pull_request 5 | 6 | jobs: 7 | nix-fmt: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Install Nix 12 | uses: DeterminateSystems/nix-installer-action@main 13 | - name: Use Magic Nix Cache 14 | uses: DeterminateSystems/magic-nix-cache-action@main 15 | - name: nix fmt 16 | run: | 17 | nix fmt 18 | diff=$(git ls-files -m --exclude-standard --deduplicate) 19 | if [[ -n "$diff" ]]; then 20 | echo "not formatted" >2 21 | exit 1 22 | fi 23 | 24 | biome-format: 25 | runs-on: ubuntu-latest 26 | steps: 27 | - uses: actions/checkout@v3 28 | - name: Install Nix 29 | uses: DeterminateSystems/nix-installer-action@main 30 | - name: Use Magic Nix Cache 31 | uses: DeterminateSystems/magic-nix-cache-action@main 32 | - name: biome format --check 33 | run: | 34 | nix develop -c biome format . 35 | if [[ "$?" -ne 0 ]]; then 36 | echo "not formatted" >2 37 | exit 1 38 | fi 39 | -------------------------------------------------------------------------------- /rust/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | extend, 3 | lib, 4 | rust-overlay, 5 | symlinkJoin, 6 | system, 7 | }: let 8 | pkgs = extend rust-overlay.overlays.default; 9 | 10 | mkDistribution = toolchain: 11 | toolchain.default.overrideAttrs (prev: { 12 | passthru = 13 | prev.passthru 14 | // { 15 | components = let 16 | component-names = [ 17 | "cargo" 18 | "clippy" 19 | "clippy-preview" 20 | "llvm-tools" 21 | "llvm-tools-preview" 22 | "rls" 23 | "rls-preview" 24 | "rust" 25 | "rust-analysis" 26 | "rust-analyzer" 27 | "rust-analyzer-preview" 28 | "rust-docs" 29 | "rust-src" 30 | "rust-std" 31 | "rustc" 32 | "rustc-dev" 33 | "rustfmt" 34 | "rustfmt-preview" 35 | ]; 36 | in 37 | lib.getAttrs component-names toolchain; 38 | 39 | profiles = lib.getAttrs ["complete" "default" "minimal"] toolchain; 40 | 41 | withComponents = components: 42 | symlinkJoin { 43 | name = "rust-toolchain-with-components"; 44 | paths = lib.getAttrs components toolchain; 45 | }; 46 | }; 47 | }); 48 | 49 | stable = lib.mapAttrs (version: mkDistribution) (lib.attrsets.removeAttrs pkgs.rust-bin.stable ["latest"]); 50 | beta = lib.mapAttrs (version: mkDistribution) (lib.attrsets.removeAttrs pkgs.rust-bin.beta ["latest"]); 51 | nightly = lib.mapAttrs (version: mkDistribution) (lib.attrsets.removeAttrs pkgs.rust-bin.nightly ["latest"]); 52 | in { 53 | inherit stable beta nightly; 54 | } 55 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs = { 3 | nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 4 | 5 | flake-compat.url = "github:edolstra/flake-compat"; 6 | flake-utils.url = "github:numtide/flake-utils"; 7 | 8 | nixpkgs-python = { 9 | url = "github:cachix/nixpkgs-python"; 10 | inputs.nixpkgs.follows = "nixpkgs"; 11 | inputs.flake-compat.follows = "flake-compat"; 12 | inputs.flake-utils.follows = "flake-utils"; 13 | }; 14 | 15 | rust-overlay = { 16 | url = "github:oxalica/rust-overlay"; 17 | inputs.nixpkgs.follows = "nixpkgs"; 18 | inputs.flake-utils.follows = "flake-utils"; 19 | }; 20 | 21 | nixpkgs-ruby = { 22 | url = "github:bobvanderlinden/nixpkgs-ruby"; 23 | inputs.nixpkgs.follows = "nixpkgs"; 24 | inputs.flake-compat.follows = "flake-compat"; 25 | inputs.flake-utils.follows = "flake-utils"; 26 | }; 27 | }; 28 | 29 | outputs = inputs @ { 30 | nixpkgs, 31 | flake-utils, 32 | ... 33 | }: 34 | { 35 | overlays = { 36 | nodejs = import ./nodejs/overlay.nix; 37 | python = import ./python/overlay.nix inputs.nixpkgs-python; 38 | rust = import ./rust/overlay.nix inputs.rust-overlay; 39 | ruby = import ./ruby/overlay.nix inputs.nixpkgs-ruby; 40 | }; 41 | } 42 | // flake-utils.lib.eachDefaultSystem (system: let 43 | pkgs = import nixpkgs { 44 | inherit system; 45 | }; 46 | in { 47 | devShell = pkgs.mkShell { 48 | packages = [ 49 | pkgs.alejandra 50 | pkgs.biome 51 | pkgs.bun 52 | pkgs.nodePackages_latest.typescript-language-server 53 | ]; 54 | }; 55 | 56 | formatter = pkgs.alejandra; 57 | 58 | packages.update-overlays = pkgs.writeShellScriptBin "update-overlays" '' 59 | ${pkgs.bun}/bin/bun ./gen.ts 60 | ''; 61 | 62 | packages.nodejsVersions = pkgs.callPackage ./nodejs {}; 63 | packages.pythonVersions = pkgs.callPackage ./python {inherit (inputs) nixpkgs-python;}; 64 | packages.rustVersions = pkgs.callPackage ./rust {inherit (inputs) rust-overlay;}; 65 | packages.rubyVersions = pkgs.callPackage ./ruby {inherit (inputs) nixpkgs-ruby;}; 66 | }); 67 | } 68 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore 2 | 3 | # Logs 4 | 5 | logs 6 | _.log 7 | npm-debug.log_ 8 | yarn-debug.log* 9 | yarn-error.log* 10 | lerna-debug.log* 11 | .pnpm-debug.log* 12 | 13 | # Caches 14 | 15 | .cache 16 | 17 | # Diagnostic reports (https://nodejs.org/api/report.html) 18 | 19 | report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 20 | 21 | # Runtime data 22 | 23 | pids 24 | _.pid 25 | _.seed 26 | *.pid.lock 27 | 28 | # Directory for instrumented libs generated by jscoverage/JSCover 29 | 30 | lib-cov 31 | 32 | # Coverage directory used by tools like istanbul 33 | 34 | coverage 35 | *.lcov 36 | 37 | # nyc test coverage 38 | 39 | .nyc_output 40 | 41 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 42 | 43 | .grunt 44 | 45 | # Bower dependency directory (https://bower.io/) 46 | 47 | bower_components 48 | 49 | # node-waf configuration 50 | 51 | .lock-wscript 52 | 53 | # Compiled binary addons (https://nodejs.org/api/addons.html) 54 | 55 | build/Release 56 | 57 | # Dependency directories 58 | 59 | node_modules/ 60 | jspm_packages/ 61 | 62 | # Snowpack dependency directory (https://snowpack.dev/) 63 | 64 | web_modules/ 65 | 66 | # TypeScript cache 67 | 68 | *.tsbuildinfo 69 | 70 | # Optional npm cache directory 71 | 72 | .npm 73 | 74 | # Optional eslint cache 75 | 76 | .eslintcache 77 | 78 | # Optional stylelint cache 79 | 80 | .stylelintcache 81 | 82 | # Microbundle cache 83 | 84 | .rpt2_cache/ 85 | .rts2_cache_cjs/ 86 | .rts2_cache_es/ 87 | .rts2_cache_umd/ 88 | 89 | # Optional REPL history 90 | 91 | .node_repl_history 92 | 93 | # Output of 'npm pack' 94 | 95 | *.tgz 96 | 97 | # Yarn Integrity file 98 | 99 | .yarn-integrity 100 | 101 | # dotenv environment variable files 102 | 103 | .env 104 | .env.development.local 105 | .env.test.local 106 | .env.production.local 107 | .env.local 108 | 109 | # parcel-bundler cache (https://parceljs.org/) 110 | 111 | .parcel-cache 112 | 113 | # Next.js build output 114 | 115 | .next 116 | out 117 | 118 | # Nuxt.js build / generate output 119 | 120 | .nuxt 121 | dist 122 | 123 | # Gatsby files 124 | 125 | # Comment in the public line in if your project uses Gatsby and not Next.js 126 | 127 | # https://nextjs.org/blog/next-9-1#public-directory-support 128 | 129 | # public 130 | 131 | # vuepress build output 132 | 133 | .vuepress/dist 134 | 135 | # vuepress v2.x temp and cache directory 136 | 137 | .temp 138 | 139 | # Docusaurus cache and generated files 140 | 141 | .docusaurus 142 | 143 | # Serverless directories 144 | 145 | .serverless/ 146 | 147 | # FuseBox cache 148 | 149 | .fusebox/ 150 | 151 | # DynamoDB Local files 152 | 153 | .dynamodb/ 154 | 155 | # TernJS port file 156 | 157 | .tern-port 158 | 159 | # Stores VSCode versions used for testing VSCode extensions 160 | 161 | .vscode-test 162 | 163 | # yarn v2 164 | 165 | .yarn/cache 166 | .yarn/unplugged 167 | .yarn/build-state.yml 168 | .yarn/install-state.gz 169 | .pnp.* 170 | 171 | # IntelliJ based IDEs 172 | .idea 173 | 174 | # Finder (MacOS) folder config 175 | .DS_Store 176 | 177 | result 178 | .direnv 179 | -------------------------------------------------------------------------------- /nodejs/gen.ts: -------------------------------------------------------------------------------- 1 | import { type Static, Type } from "@sinclair/typebox"; 2 | import { Value } from "@sinclair/typebox/value"; 3 | 4 | const MIN_NODE_MAJOR_VERSION = 18; 5 | 6 | type ParsedVersion = [number, number, number]; 7 | 8 | const NodeIndexVersion = Type.Object({ 9 | version: Type.String(), 10 | date: Type.String(), 11 | files: Type.Array(Type.String()), 12 | v8: Type.String(), 13 | lts: Type.Union([Type.String(), Type.Boolean()]), 14 | security: Type.Boolean(), 15 | 16 | // the earliest versions don't have these fields 17 | npm: Type.Optional(Type.String()), 18 | uv: Type.Optional(Type.String()), 19 | zlib: Type.Optional(Type.String()), 20 | openssl: Type.Optional(Type.String()), 21 | modules: Type.Optional(Type.String()), 22 | }); 23 | 24 | const NodeIndexJson = Type.Array(NodeIndexVersion); 25 | 26 | const VersionsJson = Type.Record(Type.String(), Type.String()); 27 | 28 | const NODE_INDEX_URL = "https://nodejs.org/download/release/index.json"; 29 | 30 | export default async function versionsJSON(): Promise { 31 | const nodejsIndexResp = await fetch(NODE_INDEX_URL); 32 | if (!nodejsIndexResp.ok) { 33 | throw new Error( 34 | `Failed to fetch node.js release index from ${NODE_INDEX_URL}: ${nodejsIndexResp.statusText}`, 35 | ); 36 | } 37 | 38 | const nodejsIndexJson = await nodejsIndexResp.json(); 39 | if (!Value.Check(NodeIndexJson, nodejsIndexJson)) { 40 | const errors = [...Value.Errors(NodeIndexJson, nodejsIndexJson)]; 41 | throw new Error( 42 | `malformed response for nodejs index from ${NODE_INDEX_URL}`, 43 | { 44 | cause: errors, 45 | }, 46 | ); 47 | } 48 | 49 | const versionsJson = await nodejsIndexJson 50 | .filter(releaseFilter) 51 | .reduce>( 52 | (registryPromise, release) => 53 | getVersionSum(release.version).then((shasum) => 54 | registryPromise.then((registry) => { 55 | registry[release.version.substring(1)] = shasum; 56 | 57 | return registry; 58 | }), 59 | ), 60 | Promise.resolve({} as typeof VersionsJson), 61 | ); 62 | 63 | return versionsJson; 64 | } 65 | 66 | const getVersionURL = (version: string) => 67 | `https://nodejs.org/download/release/${version}`; 68 | 69 | async function getVersionSum(version: string): Promise { 70 | const versionURL = getVersionURL(version); 71 | 72 | const shasumFileURL = `${versionURL}/SHASUMS256.txt`; 73 | const shasumFileResp = await fetch(shasumFileURL); 74 | if (!shasumFileResp.ok) { 75 | throw new Error( 76 | `Failed to fetch SHASUMS256.txt from ${shasumFileURL}: ${shasumFileResp.statusText}`, 77 | ); 78 | } 79 | 80 | // match `deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef node-v99.99.99.tar.xz` 81 | const sourceHashReg = 82 | /^([a-fA-F0-9]{64})\s+node-(v\d{1,2}\.\d{1,2}\.\d{1,2})\.tar\.xz$/; 83 | 84 | const shasumFileText = await shasumFileResp.text(); 85 | const shasums = shasumFileText.split("\n").flatMap((line) => { 86 | const matches = line.match(sourceHashReg); 87 | if (!matches) { 88 | return []; 89 | } 90 | 91 | // sanity check 92 | const fileVersion = matches[2]; 93 | if (fileVersion !== version) { 94 | throw new Error(`Version mismatch: ${fileVersion} !== ${version}`); 95 | } 96 | 97 | return [matches[1]]; 98 | }); 99 | 100 | if (shasums.length !== 1) { 101 | throw new Error(`no shasum found for ${version} in ${shasumFileURL}`); 102 | } 103 | 104 | return shasums[0]; 105 | } 106 | 107 | function releaseFilter({ version }: Static): boolean { 108 | const parsed = version.substring(1).split(".").map(Number) as ParsedVersion; 109 | if (parsed.length !== 3) { 110 | throw new Error(`unexpected version ${version}`); 111 | } 112 | 113 | const [major] = parsed; 114 | return major >= MIN_NODE_MAJOR_VERSION; 115 | } 116 | -------------------------------------------------------------------------------- /nodejs/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | buildPackages, 3 | callPackage, 4 | fetchurl, 5 | lib, 6 | llvmPackages, 7 | llvmPackages_15, 8 | overrideCC, 9 | python3, 10 | stdenv, 11 | }: let 12 | patches = lib.mapAttrs (_: fetchurl) { 13 | bypass-darwin-xcrun-node16 = { 14 | url = "https://raw.githubusercontent.com/NixOS/nixpkgs/nixos-23.11/pkgs/development/web/nodejs/bypass-darwin-xcrun-node16.patch"; 15 | hash = "sha256-z8QFSyXq0WuNheJIJyfN/SaVjjOVaHlEgT9H8Rt52Dg="; 16 | }; 17 | 18 | disable-darwin-v8-system-instrumentation = { 19 | url = "https://raw.githubusercontent.com/NixOS/nixpkgs/nixos-23.11/pkgs/development/web/nodejs/disable-darwin-v8-system-instrumentation.patch"; 20 | hash = "sha256-YlHUgJE2+gTNRICl5+S1QoBka+ySXB5ExdnjkbHj9/k="; 21 | }; 22 | 23 | disable-darwin-v8-system-instrumentation-node19 = { 24 | url = "https://raw.githubusercontent.com/NixOS/nixpkgs/nixos-23.11/pkgs/development/web/nodejs/disable-darwin-v8-system-instrumentation-node19.patch"; 25 | hash = "sha256-Q10WBoETfgNkiMKLDGTTmW6b0jbEaWZBKPjoQ3qVkNw="; 26 | }; 27 | 28 | node-npm-build-npm-package-logic = { 29 | url = "https://raw.githubusercontent.com/NixOS/nixpkgs/nixos-23.11/pkgs/development/web/nodejs/node-npm-build-npm-package-logic.patch"; 30 | hash = "sha256-whn2axmgKc1WM2cuNYNtb4zyxT9ibNaC0eEFhd1NDt4="; 31 | }; 32 | 33 | revert-arm64-pointer-auth = { 34 | url = "https://raw.githubusercontent.com/NixOS/nixpkgs/nixos-23.11/pkgs/development/web/nodejs/revert-arm64-pointer-auth.patch"; 35 | hash = "sha256-0tX41vi4vgGKiR+564KwHAy2pb260hnshqryUinEzyE="; 36 | }; 37 | 38 | trap-handler-backport = { 39 | url = "https://raw.githubusercontent.com/NixOS/nixpkgs/nixos-23.11/pkgs/development/web/nodejs/trap-handler-backport.patch"; 40 | hash = "sha256-gghfFTZdTaMOyaoC+5vg70+rpTAKLHngSj/oVTTElw0="; 41 | }; 42 | }; 43 | 44 | mkArgs = version: sha256: let 45 | major = lib.versions.major version; 46 | 47 | patches-18 = [ 48 | patches.bypass-darwin-xcrun-node16 49 | patches.disable-darwin-v8-system-instrumentation 50 | patches.node-npm-build-npm-package-logic 51 | patches.revert-arm64-pointer-auth 52 | patches.trap-handler-backport 53 | ]; 54 | 55 | patches-19 = [ 56 | patches.bypass-darwin-xcrun-node16 57 | patches.disable-darwin-v8-system-instrumentation-node19 58 | patches.revert-arm64-pointer-auth 59 | ]; 60 | 61 | patches-20 = [ 62 | patches.bypass-darwin-xcrun-node16 63 | patches.disable-darwin-v8-system-instrumentation-node19 64 | patches.node-npm-build-npm-package-logic 65 | patches.revert-arm64-pointer-auth 66 | ]; 67 | 68 | patches-21 = [ 69 | patches.bypass-darwin-xcrun-node16 70 | patches.disable-darwin-v8-system-instrumentation-node19 71 | patches.node-npm-build-npm-package-logic 72 | ]; 73 | 74 | version-patches = 75 | if major == "21" 76 | then patches-21 77 | else if major == "20" 78 | then patches-20 79 | else if major == "19" 80 | then patches-19 81 | else if major == "18" 82 | then patches-18 83 | else builtins.throw "unrecognized major version ${builtins.toString major}"; 84 | in { 85 | inherit sha256 version; 86 | patches = version-patches; 87 | }; 88 | 89 | mkOverrides = version: data: let 90 | major = lib.versions.major version; 91 | 92 | stdenv15 = overrideCC buildPackages.llvmPackages_15.stdenv (buildPackages.llvmPackages_15.stdenv.cc.override { 93 | inherit (buildPackages.llvmPackages) libcxx; 94 | }); 95 | 96 | actual-stdenv = 97 | if major == "18" && lib.versionAtLeast (lib.getVersion buildPackages.stdenv.cc.cc) "16" 98 | then stdenv15 99 | else stdenv; 100 | in { 101 | python = python3; 102 | stdenv = actual-stdenv; 103 | buildPackages = buildPackages // {stdenv = actual-stdenv;}; 104 | }; 105 | in 106 | lib.mapAttrs 107 | (version: data: 108 | (callPackage ./build-node.nix (mkOverrides version data) (mkArgs version data)).overrideAttrs (old: { 109 | buildPhase = '' 110 | echo "$(clang --version)" 111 | echo "$(which clang)" 112 | 113 | ${old.buildPhase or ""} 114 | ''; 115 | })) 116 | (builtins.fromJSON (builtins.readFile ./versions.json)) 117 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "flake-compat": { 4 | "locked": { 5 | "lastModified": 1696426674, 6 | "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", 7 | "owner": "edolstra", 8 | "repo": "flake-compat", 9 | "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "edolstra", 14 | "repo": "flake-compat", 15 | "type": "github" 16 | } 17 | }, 18 | "flake-utils": { 19 | "inputs": { 20 | "systems": "systems" 21 | }, 22 | "locked": { 23 | "lastModified": 1710146030, 24 | "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", 25 | "owner": "numtide", 26 | "repo": "flake-utils", 27 | "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", 28 | "type": "github" 29 | }, 30 | "original": { 31 | "owner": "numtide", 32 | "repo": "flake-utils", 33 | "type": "github" 34 | } 35 | }, 36 | "nixpkgs": { 37 | "locked": { 38 | "lastModified": 1711231723, 39 | "narHash": "sha256-dARJQ8AJOv6U+sdRePkbcVyVbXJTi1tReCrkkOeusiA=", 40 | "owner": "nixos", 41 | "repo": "nixpkgs", 42 | "rev": "e1d501922fd7351da4200e1275dfcf5faaad1220", 43 | "type": "github" 44 | }, 45 | "original": { 46 | "owner": "nixos", 47 | "ref": "nixpkgs-unstable", 48 | "repo": "nixpkgs", 49 | "type": "github" 50 | } 51 | }, 52 | "nixpkgs-python": { 53 | "inputs": { 54 | "flake-compat": [ 55 | "flake-compat" 56 | ], 57 | "flake-utils": [ 58 | "flake-utils" 59 | ], 60 | "nixpkgs": [ 61 | "nixpkgs" 62 | ] 63 | }, 64 | "locked": { 65 | "lastModified": 1710929962, 66 | "narHash": "sha256-CuPuUyX1TmxJDDZFOZMr7kHTzA8zoSJaVw0+jDVo2fw=", 67 | "owner": "cachix", 68 | "repo": "nixpkgs-python", 69 | "rev": "a9e19aafbf75b8c7e5adf2d7319939309ebe0d77", 70 | "type": "github" 71 | }, 72 | "original": { 73 | "owner": "cachix", 74 | "repo": "nixpkgs-python", 75 | "type": "github" 76 | } 77 | }, 78 | "nixpkgs-ruby": { 79 | "inputs": { 80 | "flake-compat": [ 81 | "flake-compat" 82 | ], 83 | "flake-utils": [ 84 | "flake-utils" 85 | ], 86 | "nixpkgs": [ 87 | "nixpkgs" 88 | ] 89 | }, 90 | "locked": { 91 | "lastModified": 1712986883, 92 | "narHash": "sha256-uLXukCAjJ0Ews9eMMxH00JcxYWeA/fsjaHn47s/ilgU=", 93 | "owner": "bobvanderlinden", 94 | "repo": "nixpkgs-ruby", 95 | "rev": "605170bed96a011b5264c9c3d124be79b016ce93", 96 | "type": "github" 97 | }, 98 | "original": { 99 | "owner": "bobvanderlinden", 100 | "repo": "nixpkgs-ruby", 101 | "type": "github" 102 | } 103 | }, 104 | "root": { 105 | "inputs": { 106 | "flake-compat": "flake-compat", 107 | "flake-utils": "flake-utils", 108 | "nixpkgs": "nixpkgs", 109 | "nixpkgs-python": "nixpkgs-python", 110 | "nixpkgs-ruby": "nixpkgs-ruby", 111 | "rust-overlay": "rust-overlay" 112 | } 113 | }, 114 | "rust-overlay": { 115 | "inputs": { 116 | "flake-utils": [ 117 | "flake-utils" 118 | ], 119 | "nixpkgs": [ 120 | "nixpkgs" 121 | ] 122 | }, 123 | "locked": { 124 | "lastModified": 1713233539, 125 | "narHash": "sha256-dPGrCy5ttx6E3bUOmDynY/cAotRqvoIAimZlbv+Zr1w=", 126 | "owner": "oxalica", 127 | "repo": "rust-overlay", 128 | "rev": "847bc25ebab8dc72a86d2b1f0c088740eebbb1b8", 129 | "type": "github" 130 | }, 131 | "original": { 132 | "owner": "oxalica", 133 | "repo": "rust-overlay", 134 | "type": "github" 135 | } 136 | }, 137 | "systems": { 138 | "locked": { 139 | "lastModified": 1681028828, 140 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 141 | "owner": "nix-systems", 142 | "repo": "default", 143 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 144 | "type": "github" 145 | }, 146 | "original": { 147 | "owner": "nix-systems", 148 | "repo": "default", 149 | "type": "github" 150 | } 151 | } 152 | }, 153 | "root": "root", 154 | "version": 7 155 | } 156 | -------------------------------------------------------------------------------- /nodejs/versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "21.7.2": "b4b1e2a07e96f85f6ce34a2fbfea348691aefe5cb219aa6951e23ccc991f9e2f", 3 | "21.7.1": "1272b6e129d564dbde17527b844210b971c20a70ae729268186b7cb9d990a64b", 4 | "21.7.0": "e41eefe1e59624ee7f312c38f8f7dfc11595641acb2293d21176f03d2763e9d4", 5 | "21.6.2": "191294d445d1e6800359acc8174529b1e18e102147dc5f596030d3dce96931e5", 6 | "21.6.1": "7a82f356d1dcba5d766f0e1d4c750e2e18d6290b710b7d19a8725241e7af1f60", 7 | "21.6.0": "20265bfcfa73c8b46b32378641d38b009dfc980eb28192c3d5ab7f6986fdb1e3", 8 | "21.5.0": "afd7d4713573cd814f7e4df320de8d5c8e147b4101bc9fbbe2a6d52eb5f8b072", 9 | "21.4.0": "7a80f6527654602d7358c5be2eefc4f80a64c8901630a83977b073c34f25479c", 10 | "21.3.0": "ab4172ec827f770c6c3b4b6f30824104137eda474848e84d55ed55b341e67725", 11 | "21.2.0": "d57c9cea394764fa1d9af51e52c7449f71193e9d44c4a81fbedec653ec827707", 12 | "21.1.0": "91ac72e4444c5e5ab4b448030a61ffa95acd35d34a9d31d2d220ee2bed01b925", 13 | "21.0.0": "bc56192b951ad183506dca9acf7a4d0c02591140b7fc8f25661375199266f3f2", 14 | "20.12.1": "6840d490ba4d1d51655e0fbe1209956a15db405510d7ea166bad98a8c9d37a4e", 15 | "20.12.0": "76e5346cebfd581528f699f764f4d1a6e87cb818b696708f235ddcb625a0f78d", 16 | "20.11.1": "77813edbf3f7f16d2d35d3353443dee4e61d5ee84d9e3138c7538a3c0ca5209e", 17 | "20.11.0": "31807ebeeeb049c53f1765e4a95aed69476a4b696dd100cb539ab668d7950b40", 18 | "20.10.0": "32eb256eebd8cacd5574e6631e54b42be7ec8ebe25ad47a8ca685403bad15535", 19 | "20.9.0": "a23d96810abf0455426b349d47ce5310f33095b7bc0571b9cc510f481c3a4519", 20 | "20.8.1": "f799c66f6a6386bb8ac2c75a378f740c455e97f1fe964393dd39c9f9f6efbc70", 21 | "20.8.0": "412be847ae6df61010ba9da3cc3e6be5b67aa002e354e919f59ec8360371704c", 22 | "20.7.0": "3fcfdcd05c461517480596596674df85b35cfce597dd0ae33f5416fc4df12bea", 23 | "20.6.1": "3aec5e728daa38800c343b129221d3488064a2529a39bb5467bc55be226c6a2b", 24 | "20.6.0": "9efb5cba7a8f4b18d38b0d7d37a9b30ded73390c84e380cf4de89a9d30a7d6fa", 25 | "20.5.1": "439c71aa2f38c2861657bfa538e99191a571258066cbfd4548586049c8134190", 26 | "20.5.0": "cb32756958def1c04e069a79b71b52ca61ed1590c17f2cfa1ee3af641f72e058", 27 | "20.4.0": "09bd0b73c526b63c029d5ddfd885d10962e7ad87c975b94583c1f8ce90ee5348", 28 | "20.3.1": "12a82db306697959b4389b351a5f97848986b1313f9901b0e0b3d8cf4f3f9991", 29 | "20.3.0": "1ba8d49423ed3a75729066bb3ea26493ee9cb7d6568ef948597fc9ef454f7435", 30 | "20.2.0": "22523df2316c35569714ff1f69b053c2e286ced460898417dee46945efcdf989", 31 | "20.1.0": "600f9e11860995814b9122b1ac5318f6ad564274784deed98d8a9206649436b5", 32 | "20.0.0": "7450e7579568f7d1cb398185cfce472da2837b2aa36c59620b22ce4b977b5cb5", 33 | "19.9.0": "c7fce9d46ca6ce0d8990433cbf601bb9279c0eaed8705b357018cf50be9bed29", 34 | "19.8.1": "2411e58e1d4644c4d4a82bcf3061b95e672c9f214de017d42f032cfae07461cb", 35 | "19.8.0": "3b7c07e2780920718c1ac7d24b67335f048dd9c3dd695691f41da80f4ea349a6", 36 | "19.7.0": "511847f724ea405f85e25803cbcf8b131b14cd06b2d7046698bd2760c404bfc3", 37 | "19.6.1": "7710e6c2851c956be4926fc2540678f3fddf8e6d3826ea3aa9b8c28d6ea89a9b", 38 | "19.6.0": "519c6d542a9f996f00c1a3d3b2e5cf52b7db998d95f6ced5a893d16a03de33ea", 39 | "19.5.0": "281317bdc7ba8952138bf8f0f5f076495f79f86e851a659be1f983dec33ca577", 40 | "19.4.0": "020541d670f528bd03ba0b92a1d0c46d6850982175a72f2aa557aefeda31b261", 41 | "19.3.0": "d3189574ef9849c713822e7f31de7a1b9dd8a2c6b5fc78ddb811aaa259a22b1e", 42 | "19.2.0": "0956b0ff01f2f6383827e916a6048159ce2bdb05217f654a8fff54e8116dc17e", 43 | "19.1.0": "4ea9ba1f992815fb823b022a62b61f536121f970fe88c6395c7e3af4e9cf46a0", 44 | "19.0.1": "ece5c28ceb4763f5e7f276f8c9251b3621e1fa6e45c942e757c4d151f8bf016d", 45 | "19.0.0": "0b72d207a5815f1ce7b247b33cbf9a2c86f6d01253fa3990c9744e25d975050d", 46 | "18.20.1": "c6d867a9f25e6354810effb8201f8147a15b28000e50790fda00d1ca15f49b8a", 47 | "18.20.0": "04c86779a2cc7eefdfcf379a9d85883aa1d3b1dc8909b6221b163684817856a4", 48 | "18.19.1": "090f96a2ecde080b6b382c6d642bca5d0be4702a78cb555be7bf02b20bd16ded", 49 | "18.19.0": "f52b41af20596a9abd8ed75241837ec43945468221448bbf841361e2091819b6", 50 | "18.18.2": "7249e2f0af943ec38599504f4b2a2bd31fb938787291b6ccca6c8badf01e3b56", 51 | "18.18.1": "c3c95047ec0c2b2063a5ea4b4f71ee807f6075d1dbeae4f3207cda4b9ae782f6", 52 | "18.18.0": "e4d4dbac3634d99f892f00db47da78f98493c339582e8a95fb2dd59f5cfe0f90", 53 | "18.17.1": "f215cf03d0f00f07ac0b674c6819f804c1542e16f152da04980022aeccf5e65a", 54 | "18.17.0": "80c0faadf5ea39c213ccb9aa5c2432977a0f1b5a0b766852abd0de06f2770406", 55 | "18.16.1": "e8404f8c8d89fdfdf7e95bbbc6066bd0e571acba58f54492599b615fbeefe272", 56 | "18.16.0": "33d81a233e235a509adda4a4f2209008d04591979de6b3f0f67c1c906093f118", 57 | "18.15.0": "8e44d65018ff973284195c23186469a0ea4082e97ec4200e5f5706d5584daa37", 58 | "18.14.2": "fbc364dd25fee2cacc0f2033db2d86115fc07575310ea0e64408b8170d09c685", 59 | "18.14.1": "eec353438266fd0aef53a9446be10b32ee6e74d08e32dd5454b382ff6793da04", 60 | "18.14.0": "42ef9dd31993d5c8e82b0ab0969135093e6a296efa27b1be9afc04ac00f0267a", 61 | "18.13.0": "fd4ac562e01d172896e3a959bd59552dbf647331c90d726f8d3471683dd3da68", 62 | "18.12.1": "4fa406451bc52659a290e52cfdb2162a760bd549da4b8bbebe6a29f296d938df", 63 | "18.12.0": "73a7f01e2999eb197763ced666a6cd544ad580eaefb73e0a849603b3e804f42e", 64 | "18.11.0": "8b9643dc6fce79c1e99379db0ce64e43601e2e2d7389015fe8985cc4ccd0ce17", 65 | "18.10.0": "ad711b54e2be4a7d24f37c73fb2801adeaf6d26d298d431be98d6abc0202e89f", 66 | "18.9.1": "f381963d43568ba699915c88629dc6da4a1963804dcd37b2e6e1d10d923dd5d9", 67 | "18.9.0": "c75cc89afead976791900accde02a7b1e7e762702f0f6fa68eaacb01984d9654", 68 | "18.8.0": "2b5d9825d05ede6614f1668a8d97d774fe92ebc81088ec5fdf58184dce3c86b9", 69 | "18.7.0": "8834a33c92dfe6ba8903e6715caeaa25dff4657e703c54cd06ec113493e2c3c2", 70 | "18.6.0": "5f8b0c33a12fcaec9643b4367a5daa94314bf26f9b75b5f431c4f14b37bc054c", 71 | "18.5.0": "368b5694e380b05d436369484754659b2f040cfe13fed011ebab5e5198f1a030", 72 | "18.4.0": "94d6f19a970361f8c8ad17450604095389f51ca6a00dcde59c21f373e95abbb5", 73 | "18.3.0": "3f694a81626e5057cda57898e771d213cfc5a649855f4cf1c6f6cd150c530625", 74 | "18.2.0": "2305b15ebf5547474e905b5002f9ba99c7eeef01d7394dfe6f3846cc6bcad66d", 75 | "18.1.0": "e8b0cc20089e0d7726bc0e921d247f8831263bdba6b5f102bd95ea0f63300b7e", 76 | "18.0.0": "344d0e6540b524c69a979ff5c3e78cda7254fd72c03699926beb0b8558b8ce75" 77 | } 78 | -------------------------------------------------------------------------------- /nodejs/build-node.nix: -------------------------------------------------------------------------------- 1 | # taken from https://github.com/NixOS/nixpkgs/blob/cf1128c17a8a94bea4c12487a865a8e231d931e7/pkgs/development/web/nodejs/nodejs.nix 2 | { 3 | lib, 4 | stdenv, 5 | fetchurl, 6 | openssl, 7 | python, 8 | zlib, 9 | libuv, 10 | util-linux, 11 | http-parser, 12 | bash, 13 | pkg-config, 14 | which, 15 | buildPackages, 16 | # for `.pkgs` attribute 17 | callPackage, 18 | # Updater dependencies 19 | writeScript, 20 | coreutils, 21 | gnugrep, 22 | jq, 23 | curl, 24 | common-updater-scripts, 25 | nix, 26 | runtimeShell, 27 | gnupg, 28 | darwin, 29 | xcbuild, 30 | procps, 31 | icu, 32 | }: { 33 | enableNpm ? true, 34 | version, 35 | sha256, 36 | patches ? [], 37 | } @ args: let 38 | inherit (darwin.apple_sdk.frameworks) CoreServices ApplicationServices; 39 | 40 | isCross = stdenv.hostPlatform != stdenv.buildPlatform; 41 | 42 | majorVersion = lib.versions.major version; 43 | minorVersion = lib.versions.minor version; 44 | 45 | pname = 46 | if enableNpm 47 | then "nodejs" 48 | else "nodejs-slim"; 49 | 50 | useSharedHttpParser = !stdenv.isDarwin && lib.versionOlder "${majorVersion}.${minorVersion}" "11.4"; 51 | 52 | sharedLibDeps = {inherit openssl zlib libuv;} // (lib.optionalAttrs useSharedHttpParser {inherit http-parser;}); 53 | 54 | sharedConfigureFlags = 55 | lib.concatMap (name: [ 56 | "--shared-${name}" 57 | "--shared-${name}-libpath=${lib.getLib sharedLibDeps.${name}}/lib" 58 | /* 59 | * Closure notes: we explicitly avoid specifying --shared-*-includes, 60 | * as that would put the paths into bin/nodejs. 61 | * Including pkg-config in build inputs would also have the same effect! 62 | */ 63 | ]) (builtins.attrNames sharedLibDeps) 64 | ++ [ 65 | "--with-intl=system-icu" 66 | "--openssl-use-def-ca-store" 67 | ]; 68 | 69 | copyLibHeaders = 70 | map 71 | (name: "${lib.getDev sharedLibDeps.${name}}/include/*") 72 | (builtins.attrNames sharedLibDeps); 73 | 74 | extraConfigFlags = lib.optionals (!enableNpm) ["--without-npm"]; 75 | self = stdenv.mkDerivation { 76 | inherit pname version; 77 | 78 | src = fetchurl { 79 | url = "https://nodejs.org/dist/v${version}/node-v${version}.tar.xz"; 80 | inherit sha256; 81 | }; 82 | 83 | strictDeps = true; 84 | 85 | env = lib.optionalAttrs (stdenv.isDarwin && stdenv.isx86_64) { 86 | # Make sure libc++ uses `posix_memalign` instead of `aligned_alloc` on x86_64-darwin. 87 | # Otherwise, nodejs would require the 11.0 SDK and macOS 10.15+. 88 | NIX_CFLAGS_COMPILE = "-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=101300"; 89 | }; 90 | 91 | CC_host = "cc"; 92 | CXX_host = "c++"; 93 | depsBuildBuild = [buildPackages.stdenv.cc openssl libuv zlib icu]; 94 | 95 | # NB: technically, we do not need bash in build inputs since all scripts are 96 | # wrappers over the corresponding JS scripts. There are some packages though 97 | # that use bash wrappers, e.g. polaris-web. 98 | buildInputs = 99 | lib.optionals stdenv.isDarwin [CoreServices ApplicationServices] 100 | ++ [zlib libuv openssl http-parser icu bash]; 101 | 102 | nativeBuildInputs = 103 | [which pkg-config python] 104 | ++ lib.optionals stdenv.isDarwin [xcbuild]; 105 | 106 | outputs = ["out" "libv8"]; 107 | setOutputFlags = false; 108 | moveToDev = false; 109 | 110 | configureFlags = let 111 | inherit (stdenv.hostPlatform) gcc isAarch32; 112 | in 113 | sharedConfigureFlags 114 | ++ lib.optionals (lib.versionOlder version "19") [ 115 | "--without-dtrace" 116 | ] 117 | ++ (lib.optionals isCross [ 118 | "--cross-compiling" 119 | "--dest-cpu=${let 120 | platform = stdenv.hostPlatform; 121 | in 122 | if platform.isAarch32 123 | then "arm" 124 | else if platform.isAarch64 125 | then "arm64" 126 | else if platform.isMips32 && platform.isLittleEndian 127 | then "mipsel" 128 | else if platform.isMips32 && !platform.isLittleEndian 129 | then "mips" 130 | else if platform.isMips64 && platform.isLittleEndian 131 | then "mips64el" 132 | else if platform.isPower && platform.is32bit 133 | then "ppc" 134 | else if platform.isPower && platform.is64bit 135 | then "ppc64" 136 | else if platform.isx86_64 137 | then "x86_64" 138 | else if platform.isx86_32 139 | then "x86" 140 | else if platform.isS390 && platform.is64bit 141 | then "s390x" 142 | else if platform.isRiscV && platform.is64bit 143 | then "riscv64" 144 | else throw "unsupported cpu ${stdenv.hostPlatform.uname.processor}"}" 145 | ]) 146 | ++ (lib.optionals (isCross && isAarch32 && lib.hasAttr "fpu" gcc) [ 147 | "--with-arm-fpu=${gcc.fpu}" 148 | ]) 149 | ++ (lib.optionals (isCross && isAarch32 && lib.hasAttr "float-abi" gcc) [ 150 | "--with-arm-float-abi=${gcc.float-abi}" 151 | ]) 152 | ++ extraConfigFlags; 153 | 154 | configurePlatforms = []; 155 | 156 | dontDisableStatic = true; 157 | 158 | enableParallelBuilding = true; 159 | 160 | # Don't allow enabling content addressed conversion as `nodejs` 161 | # checksums it's image before conversion happens and image loading 162 | # breaks: 163 | # $ nix build -f. nodejs --arg config '{ contentAddressedByDefault = true; }' 164 | # $ ./result/bin/node 165 | # Check failed: VerifyChecksum(blob). 166 | __contentAddressed = false; 167 | 168 | passthru.interpreterName = "nodejs"; 169 | 170 | passthru.pkgs = callPackage ../../node-packages/default.nix { 171 | nodejs = self; 172 | }; 173 | 174 | setupHook = ./setup-hook.sh; 175 | 176 | pos = builtins.unsafeGetAttrPos "version" args; 177 | 178 | inherit patches; 179 | 180 | doCheck = lib.versionAtLeast version "16"; # some tests fail on v14 181 | 182 | # Some dependencies required for tools/doc/node_modules (and therefore 183 | # test-addons, jstest and others) target are not included in the tarball. 184 | # Run test targets that do not require network access. 185 | checkTarget = lib.concatStringsSep " " [ 186 | "build-js-native-api-tests" 187 | "build-node-api-tests" 188 | "tooltest" 189 | "cctest" 190 | ]; 191 | 192 | # Do not create __pycache__ when running tests. 193 | checkFlags = ["PYTHONDONTWRITEBYTECODE=1"]; 194 | 195 | postInstall = '' 196 | HOST_PATH=$out/bin patchShebangs --host $out 197 | 198 | ${lib.optionalString enableNpm '' 199 | mkdir -p $out/share/bash-completion/completions 200 | ln -s $out/lib/node_modules/npm/lib/utils/completion.sh \ 201 | $out/share/bash-completion/completions/npm 202 | for dir in "$out/lib/node_modules/npm/man/"*; do 203 | mkdir -p $out/share/man/$(basename "$dir") 204 | for page in "$dir"/*; do 205 | ln -rs $page $out/share/man/$(basename "$dir") 206 | done 207 | done 208 | ''} 209 | 210 | # install the missing headers for node-gyp 211 | cp -r ${lib.concatStringsSep " " copyLibHeaders} $out/include/node 212 | 213 | # assemble a static v8 library and put it in the 'libv8' output 214 | mkdir -p $libv8/lib 215 | pushd out/Release/obj.target 216 | find . -path "./torque_*/**/*.o" -or -path "./v8*/**/*.o" | sort -u >files 217 | ${ 218 | if stdenv.buildPlatform.isGnu 219 | then '' 220 | ar -cqs $libv8/lib/libv8.a @files 221 | '' 222 | else '' 223 | # llvm-ar supports response files, so take advantage of it if it’s available. 224 | if [ "$(basename $(readlink -f $(command -v ar)))" = "llvm-ar" ]; then 225 | ar -cqs $libv8/lib/libv8.a @files 226 | else 227 | cat files | while read -r file; do 228 | ar -cqS $libv8/lib/libv8.a $file 229 | done 230 | fi 231 | '' 232 | } 233 | popd 234 | 235 | # copy v8 headers 236 | cp -r deps/v8/include $libv8/ 237 | 238 | # create a pkgconfig file for v8 239 | major=$(grep V8_MAJOR_VERSION deps/v8/include/v8-version.h | cut -d ' ' -f 3) 240 | minor=$(grep V8_MINOR_VERSION deps/v8/include/v8-version.h | cut -d ' ' -f 3) 241 | patch=$(grep V8_PATCH_LEVEL deps/v8/include/v8-version.h | cut -d ' ' -f 3) 242 | mkdir -p $libv8/lib/pkgconfig 243 | cat > $libv8/lib/pkgconfig/v8.pc << EOF 244 | Name: v8 245 | Description: V8 JavaScript Engine 246 | Version: $major.$minor.$patch 247 | Libs: -L$libv8/lib -lv8 -pthread -licui18n -licuuc 248 | Cflags: -I$libv8/include 249 | EOF 250 | ''; 251 | 252 | passthru.updateScript = import ./update.nix { 253 | inherit writeScript coreutils gnugrep jq curl common-updater-scripts gnupg nix runtimeShell; 254 | inherit lib; 255 | inherit majorVersion; 256 | }; 257 | 258 | meta = with lib; { 259 | description = "Event-driven I/O framework for the V8 JavaScript engine"; 260 | homepage = "https://nodejs.org"; 261 | changelog = "https://github.com/nodejs/node/releases/tag/v${version}"; 262 | license = licenses.mit; 263 | maintainers = with maintainers; [goibhniu gilligan cko marsam]; 264 | platforms = platforms.linux ++ platforms.darwin; 265 | mainProgram = "node"; 266 | knownVulnerabilities = optional (versionOlder version "18") "This NodeJS release has reached its end of life. See https://nodejs.org/en/about/releases/."; 267 | 268 | # Node.js build system does not have separate host and target OS 269 | # configurations (architectures are defined as host_arch and target_arch, 270 | # but there is no such thing as host_os and target_os). 271 | # 272 | # We may be missing something here, but it doesn’t look like it is 273 | # possible to cross-compile between different operating systems. 274 | broken = stdenv.buildPlatform.parsed.kernel.name != stdenv.hostPlatform.parsed.kernel.name; 275 | }; 276 | 277 | passthru.python = python; # to ensure nodeEnv uses the same version 278 | }; 279 | in 280 | self 281 | --------------------------------------------------------------------------------