cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.04k stars 303 forks source link

Add support for specifying node versions that aren't available in nixpkgs #1382

Open dudeofawesome opened 1 month ago

dudeofawesome commented 1 month ago

It would be very useful to be able to specify node versions that aren't available in nixpkgs, such as versions that aren't supported anymore, or patch versions that were never included in nixpkgs.

Something like the support for Ruby versions would be perfect.

pan93412 commented 3 weeks ago

You can add the source to your devenv.yaml file, which is more general for your use case. If you want to use a Node.js version greater than or equal to 10, you can leverage Nixhub to find the exact Nixpkgs commit and add it to the inputs section: https://www.nixhub.io/packages/nodejs. For example:

# devenv.yaml
inputs:
  nix-nodejs:
    # Node.js 14.17.5
    url: nixpkgs/6cc260cfd60f094500b79e279069b499806bf6d8#nodejs-14_x
# devenv.nix
{ inputs, pkgs }:

let
    nodejs-pkgs = import inputs.nix-nodejs { inherit (pkgs) system; };
in
{
    # omitting

    language.nodejs.package = nodejs-pkgs.nodejs;
}

For older Node.js versions, I don't see anyone maintaining a repository for these ancient versions. In this case, it might be better to maintain your Node.js flake.