From 1d71bef76c8660bd408989ffca94b80c7b3ecc8c Mon Sep 17 00:00:00 2001 From: Cody A Price Date: Mon, 15 Jul 2024 13:36:16 -0500 Subject: [PATCH] support nix users --- .envrc | 33 ++++++++++++++++------------- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 34 ++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 14 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc index 4293e14b1f..ce8830f801 100644 --- a/.envrc +++ b/.envrc @@ -1,20 +1,25 @@ -# Check if nvm is installed, install if not -if [ ! -d "$NVM_DIR" ] || [ ! -s "$NVM_DIR/nvm.sh" ]; then - echo "nvm is not installed. Installing nvm..." - - # Install nvm - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash -fi +# if using nixos, run `use flake` +if has nix; then + use flake +else + # Check if nvm is installed, install if not + if [ ! -d "$NVM_DIR" ] || [ ! -s "$NVM_DIR/nvm.sh" ]; then + echo "nvm is not installed. Installing nvm..." + + # Install nvm + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash + fi -# ensure nvm is in the path -export NVM_DIR="$HOME/.nvm" -export PATH="$NVM_DIR:$PATH" + # ensure nvm is in the path + export NVM_DIR="$HOME/.nvm" + export PATH="$NVM_DIR:$PATH" -# load nvm -\. $NVM_DIR/nvm.sh + # load nvm + \. $NVM_DIR/nvm.sh -# install node version from .nvmrc -nvm install + # install node version from .nvmrc + nvm install +fi # enable pnpm in corepack corepack enable pnpm diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..6bd818c149 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704842529, + "narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..fb4403fbe2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "ngrok docs"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + node-toolchain = with pkgs; [ + nodejs + nodePackages.pnpm + ]; + in + { + devShell = pkgs.mkShell { + shellHook = '' + export PATH="$PATH:$(git rev-parse --show-toplevel)/node_modules/.bin" + ''; + buildInputs = with pkgs; [ + node-toolchain + ]; + }; + }); +}