Skip to content

Instantly share code, notes, and snippets.

@pveierland
Created August 22, 2022 17:11
Show Gist options
  • Save pveierland/f2a58cebbbabc640b80bf3569dd12ee6 to your computer and use it in GitHub Desktop.
Save pveierland/f2a58cebbbabc640b80bf3569dd12ee6 to your computer and use it in GitHub Desktop.
nix-yarn-devshell
use flake
NODE_DIR="${PWD}/.direnv/node"
NODE_MODULES_DIR="${PWD}/node_modules"
export NODE_OPTIONS="--max_old_space_size=65536"
export NODE_PATH="${NODE_DIR}:${NODE_MODULES_DIR}"
export NPM_CONFIG_PREFIX="${NODE_DIR}"
export PATH="${NODE_DIR}/bin:${NODE_MODULES_DIR}/.bin:${PATH}"
NODE_INSTALL_HASH=`cat flake.lock yarn.lock | md5sum | cut -f 1 -d " "`
NODE_INSTALL_MARKER="${PWD}/.direnv/node-install"
if [[ ! -e "${NODE_INSTALL_MARKER}" || ( `cat ${NODE_INSTALL_MARKER}` != ${NODE_INSTALL_HASH} ) ]]; then
( yarn install )
echo "${NODE_INSTALL_HASH}" > "${NODE_INSTALL_MARKER}"
fi
{
description = "yarn development shell";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = (import nixpkgs { inherit system; }).pkgs;
in
{
devShell.${system} = pkgs.mkShell
{
nativeBuildInputs = with pkgs; [
nodejs
yarn
];
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment