Skip to content

Instantly share code, notes, and snippets.

@drupol
Created August 11, 2022 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drupol/ac3dc9f89cc606a668773cb54b996857 to your computer and use it in GitHub Desktop.
Save drupol/ac3dc9f89cc606a668773cb54b996857 to your computer and use it in GitHub Desktop.
Flake for NodeJS dev
{
description = "The NodeJS development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, flake-utils, nixpkgs }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
permittedInsecurePackages = [
"nodejs-10.24.1"
];
};
};
makeNodeEnv = name: node: pkgs.buildEnv {
inherit name;
paths = [
node
pkgs.yarn
] ++ [
pkgs.gh
pkgs.sqlite
pkgs.git
pkgs.gnumake
];
};
derivations = rec
{
default = derivations.node14;
node10 = makeNodeEnv "node-10" pkgs.nodejs-10_x;
node12 = makeNodeEnv "node-12" pkgs.nodejs-12_x;
node14 = makeNodeEnv "node-14" pkgs.nodejs-14_x;
node16 = makeNodeEnv "node-16" pkgs.nodejs-16_x;
node17 = makeNodeEnv "node-17" pkgs.nodejs-17_x;
node18 = makeNodeEnv "node-18" pkgs.nodejs-18_x;
};
in
{
packages = derivations;
devShells = builtins.mapAttrs
(
name: env: pkgs.mkShellNoCC {
inherit name;
buildInputs = [
env
];
}
)
derivations;
}
);
}
@alper
Copy link

alper commented Feb 7, 2024

Too much going on here. Can't it be just simply one version? How do you call this?

@drupol
Copy link
Author

drupol commented Feb 7, 2024

Hey !

I forgot about this gist :)

The idea behind this flake was to offer to my colleague the possibility to switch from one version of Node version quickly.
That's the reason why there are many entries.

@alper
Copy link

alper commented Feb 7, 2024

Thanks for the reply. Every time I want to setup a gist it's a frantic google around for examples and this came up.

@drupol
Copy link
Author

drupol commented Feb 7, 2024

Oh really ?! How come?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment