Created
August 22, 2022 17:11
-
-
Save pveierland/f2a58cebbbabc640b80bf3569dd12ee6 to your computer and use it in GitHub Desktop.
nix-yarn-devshell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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