Update nix shell config

This commit is contained in:
Yan Lin 2025-05-16 19:35:03 +02:00
parent 67cd160015
commit 01a9b1ac4d
3 changed files with 19 additions and 21 deletions

View file

@ -2,8 +2,6 @@ services:
homepage:
image: nginx:alpine
container_name: homepage
ports:
- "9000:80"
volumes:
- ./dist:/usr/share/nginx/html
restart: unless-stopped

View file

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import <nixpkgs> {}, isDev ? true, restartRemote ? false, remoteHost ? "hetzner" }:
pkgs.mkShell {
packages = with pkgs; [
@ -7,19 +7,31 @@ pkgs.mkShell {
python312Packages.virtualenv
];
shellHook = ''
shellHook = let
venvPath = "$HOME/venv/homepage";
in ''
export PIP_REQUIRE_VIRTUALENV=1
export VENV_PATH=$HOME/venv/homepage
export VENV_PATH=${venvPath}
if [ ! -d $VENV_PATH ]; then
python -m venv $VENV_PATH
fi
source $VENV_PATH/bin/activate
pip install -r requirements.txt
pip install watchdog
${if isDev then ''
pip install watchdog
python watch.py
'' else ''
python parser/md.py
python generate.py
python parser/md.py
python generate.py
python watch.py
rsync -avP --delete ./dist/ ${remoteHost}:/root/homepage/dist
rsync -avP ./docker-compose.yml ${remoteHost}:/root/homepage/
${if restartRemote then ''
ssh ${remoteHost} "cd /root/homepage && docker compose down && docker compose up -d"
'' else ""}
''}
'';
}

12
sync.sh
View file

@ -1,12 +0,0 @@
#!/bin/bash
REMOTE_HOST=hetzner
python parser/md.py
python generate.py
rsync -avP --delete ./dist/ ${REMOTE_HOST}:/root/homepage/dist
rsync -avP ./docker-compose.yml ${REMOTE_HOST}:/root/homepage/
if [ "$1" = "--restart" ]; then
ssh ${REMOTE_HOST} "cd /root/homepage && docker compose down && docker compose up -d"
fi