Created
September 20, 2022 23:17
-
-
Save djm/9b1394a1a18aebb00832f1aff31e95ab to your computer and use it in GitHub Desktop.
YunoJuno Nix Developer Environment
This file contains hidden or 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
export OP_ACCOUNT=yunojuno.1password.com | |
# Create .env.local if it does not exist | |
if [ ! -f .env.local ] | |
then | |
echo "Creating .env.local" | |
cat <<EOF > .env.local | |
# Place secret env variables from 1Password and custom overrides here | |
# | |
# Any variables here will override ones set in .env.native.dist | |
# | |
# Use "task get-env-1p" to load 1Pass env variables into this file | |
# | |
# Use "task reload-env" to set environment variables after updating | |
EOF | |
fi | |
# Create a .env file by merging .env.local into .env.native.dist | |
./scripts/merge_env | |
# Allow unfree packages in nix | |
export NIXPKGS_ALLOW_UNFREE=1 | |
# Read shell.nix and setup the Nix shell environment. | |
use nix shell.nix | |
# Read the .env file and load the environment variables within. | |
dotenv |
This file contains hidden or 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
# YunoJuno's Dev Environment | |
# ========================== | |
# | |
# We base our developer environment on Nix, the functional package | |
# manager and its sister package nix-shell which allows for per- | |
# directory "virtual environments". | |
# | |
# We use `nix-shell` alongside `direnv`, so that the environment | |
# gets loaded as soon as you enter the directory with your shell. | |
# | |
# We choose to use the rolling Nix Channel named `nixpgks-unstable`, | |
# as we stay fairly up-to-date with new versions of Python & NodeJS. | |
# Read more about Channels here: https://nixos.wiki/wiki/Nix_channels | |
# | |
# | |
# Re-pinning | |
# ---------- | |
# | |
# Re-pinning is the act of updating which version of a specific | |
# channel (tree of packages) we are relying on at a given moment | |
# in time. If you require the Python & NodeJS versions to bump, | |
# re-pinning is what you want. The process is simple: | |
# | |
# 1. Visit https://status.nixos.org/ | |
# 2. Check the `nixpkgs-unstable`. | |
# 3. Update the `fetchTarball` URL below with new commit. | |
# 4. Create a pull request, and mention new Py/JS versions. | |
# | |
# If you need to find out which exact version of a package is defined | |
# at which exact commit in the channel, use https://lazamar.co.uk/nix-versions/ | |
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/6e2536f1b09863e984f0479ea4b162e4fe86493d.tar.gz") {} | |
, lib ? pkgs.lib | |
, stdenv ? pkgs.stdenv | |
, frameworks ? pkgs.darwin.apple_sdk.frameworks | |
}: | |
pkgs.mkShell { | |
nativeBuildInputs = [ | |
# For graph tooling | |
pkgs.graphviz | |
# Dev-env tooling | |
pkgs.go-task | |
# Python deps | |
pkgs.python310 | |
pkgs.python310Packages.pip | |
pkgs.poetry | |
pkgs.pre-commit | |
# Node deps | |
pkgs.nodejs-16_x | |
pkgs.yarn | |
# for many deps | |
pkgs.pkg-config | |
# for psycopg2-binary | |
pkgs.openssl | |
pkgs.postgresql | |
# for lxml | |
pkgs.libxml2.dev | |
pkgs.libxslt.dev | |
# for pikepdf | |
pkgs.qpdf | |
# for node-canvas (build from src) | |
pkgs.cairo.dev | |
pkgs.pango.dev | |
pkgs.libpng.dev | |
pkgs.libjpeg.dev | |
pkgs.librsvg.dev | |
pkgs.giflib | |
] ++ lib.optional stdenv.isDarwin [ | |
pkgs.xcodebuild | |
frameworks.CoreText # for node-canvas | |
]; | |
shellHook = '' | |
set -e | |
# Force poetry to install locally. | |
mkdir -p ./.poetry-venv/ | |
export POETRY_VIRTUALENVS_PATH=$(pwd)/.poetry-venv/ | |
echo "" | |
echo "" | |
echo "__ __ _ " | |
echo "\ \ / / | | " | |
echo " \ \_/ / _ _ __ ___ | |_ _ _ __ ___ " | |
echo " \ / | | | '_ \ / _ \ _ | | | | | '_ \ / _ \ " | |
echo " | || |_| | | | | (_) | |__| | |_| | | | | (_) |" | |
echo " |_| \__,_|_| |_|\___/ \____/ \__,_|_| |_|\___/ " | |
echo " ============================================= " | |
echo " ========== Development Environment ========== " | |
echo " ====== [`python --version`, Node `node --version`] ======= " | |
echo "" | |
# Show Python update message if the poetry.lock has changed since | |
# the last installation completed successfully. | |
if ! sha1sum -c poetry.lock.sha1 --status --strict > /dev/null 2>&1 | |
then | |
echo -e " Python deps: \e[31mNeed update\e[0m, run 'task install-python-env'" | |
else | |
echo -e " Python deps: \e[32mUp-to-date\e[0m" | |
fi | |
# Install Node update message if the yarn.lock has changed since | |
# the last installation completed successfully. | |
if ! sha1sum -c yarn.lock.sha1 --status --strict > /dev/null 2>&1 | |
then | |
echo -e " JavaScript deps: \e[31mNeed update\e[0m, run 'task install-js-env'" | |
else | |
echo -e " JavaScript deps: \e[32mUp-to-date\e[0m" | |
fi | |
echo -e " Run \e[36mtask\e[0m to see available commands " | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment