Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/nix-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Nix Environment

on:
pull_request:
push:
branches:
- master

jobs:
nix-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive

- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Evaluate default.nix
run: nix-instantiate default.nix

- name: Test Nix shellHook runs automatically
run: |
nix-shell --run "
echo 'ShellHook completed successfully' &&
uv --version &&
test -d .venv && echo 'Virtual environment exists' || (echo 'Virtual environment not found' && exit 1)
"

- name: Start pokeapi in Nix environment
run: |
nix-shell --run "
make install-base &&
make setup &&
make build-db
"

- name: Test pokeapi serves correctly
run: |
nix-shell --run "
nohup make serve &
sleep 3 &&
curl -Ss http://localhost:8000/api/v2/pokemon/1/ | grep -q 'bulbasaur'
"
29 changes: 7 additions & 22 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
with import <nixpkgs> { };
pkgs.mkShell {
name = "onix-shellder";
venvDir = "./.venv";
buildInputs = [
python313Packages.python
python313Packages.venvShellHook

# Required dependencies
mkShell {
packages = [
uv

# Python
python313Packages.black

# misc
# non-Python system libraries your project needs
taglib
openssl
git
Expand All @@ -21,16 +14,8 @@ pkgs.mkShell {
zlib
];

# Runs after creating the virtual environment
postVenvCreation = ''
shellHook = ''
unset SOURCE_DATE_EPOCH
pip install -r requirements.txt
uv sync --locked --all-extras --dev
'';

postShellHook = ''
unset SOURCE_DATE_EPOCH
# use z shell, run exit to get back to default bash
zsh -l
'';

}
}
Loading