diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..222f694 --- /dev/null +++ b/.envrc @@ -0,0 +1,10 @@ +# Direnv configuration for automatic shell activation +# Install direnv: nix profile install nixpkgs#direnv +# Then run: direnv allow + +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSqjKdZqGQ3g/3p3g/dh99fQ=" +fi + +use flake + diff --git a/.gitignore b/.gitignore index 7b2434c..c66805e 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,8 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +# nix +result +result-* +.direnv/ diff --git a/README.md b/README.md index 29cdb6f..8fad158 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ I. I. ## Table of Contents - [Local Deployment](#local-deployment) ---! -Welcome to TripSit's Main Website, brought to you by THC. +Welcome to TripSit's Main Website, Harm Reduction Through Education. This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). @@ -39,10 +39,10 @@ The preferred way to have full control (and perhaps more resources) is local dev 1) Git clone the repo 2) Install dependencies with `npm install` ---- -> [!WARNKNG] + +> [!WARNING] > WINDOWS USERS MIGHT HAVE TO ADJUST DEPENDENCIES LOCALLY AS WITH TRY INSTALLING NVM THROUGH WINGET > IF PROBLEMS OCCUR ---- + Then you have two choices: #### Docker Deployment @@ -65,4 +65,4 @@ If you cannot run docker for whatever reason, or you're in codespace. But it worked on my system (tm) when im running on an ubuntu vps, so give it a shot. -Also now works on windows as of 2/1/2025 on my machine (tm), if fails try WSL first before NVM \ No newline at end of file +Also now works on windows as of 2/1/2025 on my machine (tm), if fails try WSL first before NVM diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..34d6f67 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1766473571, + "narHash": "sha256-5G1NDO2PulBx1RoaA6U1YoUDX0qZslpPxv+n5GX6Qto=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "76701a179d3a98b07653e2b0409847499b2a07d3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.11", + "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 0000000..f92344b --- /dev/null +++ b/flake.nix @@ -0,0 +1,89 @@ +{ + description = "Development environment for website project"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + nodejs = pkgs.nodejs_22; + devTools = with pkgs; [ + nodejs + nodePackages.npm + nodePackages.typescript + docker + docker-compose + postgresql_16 + pgadmin4 + neovim + git + curl + wget + bashInteractive + coreutils + ]; + in + { + devShells.default = pkgs.mkShell { + buildInputs = devTools; + + # Isolated environment - only packages from this flake are available + # Uncomment to make the shell pure (no access to system packages (FOR NIX USERS) + # pure = true; + + shellHook = '' + echo " Website Development Environment" + echo "Node.js version: $(node --version)" + echo "npm version: $(npm --version)" + echo "Neovim version: $(nvim --version | head -n1)" + echo "Docker version: $(docker --version 2>/dev/null || echo 'Docker daemon not running')" + echo "PostgreSQL version: $(postgres --version 2>/dev/null || echo 'PostgreSQL not started')" + echo "" + echo "Available commands:" + echo " npm install - Install dependencies" + echo " npm run dev - Start development server" + echo " npm run lint - Run linter" + echo " npm run website - Build and run Docker container" + echo " npm run logs - View Docker container logs" + echo "" + echo "Database commands:" + echo " pg_ctl start - Start PostgreSQL server" + echo " pg_ctl stop - Stop PostgreSQL server" + echo " pgadmin4 - Launch pgAdmin web interface" + echo "" + echo " Tip: Run 'check-nix-env' to verify you're in the Nix environment" + echo "" + + # Helper function to check if in Nix environment + check-nix-env() { + if [ -n "$IN_NIX_SHELL" ]; then + echo "You ARE in the Nix development environment" + echo " IN_NIX_SHELL=$IN_NIX_SHELL" + else + echo "You are NOT in the Nix development environment" + echo " Run 'nix develop' to enter it" + fi + } + + # Set NODE_OPTIONS for debugging if needed + export NODE_OPTIONS="--inspect" + + # Uncomment the lines below if you want automatic LazyVim setup + # if [ ! -d ~/.config/nvim ]; then + # echo "Setting up LazyVim..." + # git clone https://github.com/LazyVim/starter ~/.config/nvim + # fi + ''; + + NODE_ENV = "development"; + }; + } + ); +} +