Created
October 7, 2024 16:36
-
-
Save russelldavies/d96c5f44437f03e6cf73558763cd74c2 to your computer and use it in GitHub Desktop.
Invoice Ninja flake
This file contains 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
:80 { | |
root invoiceninja/public | |
encode gzip | |
php_fastcgi unix/fpm.sock | |
file_server | |
} |
This file contains 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
{ | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | |
flake-utils.url = "github:numtide/flake-utils"; | |
}; | |
outputs = { nixpkgs, flake-utils, ... }: | |
flake-utils.lib.eachDefaultSystem (system: | |
let | |
pkgs = nixpkgs.legacyPackages.${system}; | |
in | |
{ | |
devShells.default = pkgs.mkShell { | |
packages = with pkgs; [ | |
mysql | |
caddy | |
php | |
php82Extensions.bcmath | |
php82Extensions.ctype | |
php82Extensions.imagick | |
php82Extensions.soap | |
php82Extensions.gd | |
php82Extensions.mbstring | |
php82Extensions.tokenizer | |
php82Extensions.xml | |
php82Extensions.curl | |
php82Extensions.zip | |
php82Extensions.gmp | |
php82Extensions.mysqli | |
php82Extensions.intl | |
iconv | |
]; | |
shellHook = '' | |
MYSQL_BASEDIR=${pkgs.mariadb} | |
MYSQL_HOME="$PWD/mysql" | |
MYSQL_DATADIR="$MYSQL_HOME/data" | |
MYSQL_UNIX_PORT="$MYSQL_HOME/mysql.sock" | |
MYSQL_PID_FILE="$MYSQL_HOME/mysql.pid" | |
alias mysql="mysql -u root --socket=$MYSQL_UNIX_PORT" | |
if [ ! -d "$MYSQL_HOME" ]; then | |
# Make sure to use normal authentication method otherwise we can only | |
# connect with unix account. But users do not actually exists in nix. | |
mysql_install_db --no-defaults --auth-root-authentication-method=normal \ | |
--datadir="$MYSQL_DATADIR" --basedir="$MYSQL_BASEDIR" | |
fi | |
# Starts the daemon | |
# - Don't load mariadb global defaults in /etc with `--no-defaults` | |
# - Disable networking with `--skip-networking` and only use the socket so | |
# multiple instances can run at once | |
if [ ! -f $MYSQL_PID_FILE ]; then | |
mysqld --no-defaults --skip-networking --datadir="$MYSQL_DATADIR" --pid-file="$MYSQL_PID_FILE" \ | |
--socket="$MYSQL_UNIX_PORT" 2> "$MYSQL_HOME/mysql.log" & | |
fi | |
if [ ! -f fpm.sock ]; then | |
php-fpm -y fpm.conf -p $PWD -g $PWD/fpm.pid | |
fi | |
if [ ! -f caddy.pid ]; then | |
caddy start --pidfile $PWD/caddy.pid | |
fi | |
finish() | |
{ | |
caddy stop | |
pkill -F fpm.pid | |
mysqladmin -u root --socket="$MYSQL_UNIX_PORT" shutdown | |
} | |
trap finish EXIT | |
''; | |
}; | |
}); | |
} |
This file contains 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
[global] | |
error_log = /dev/stderr | |
[www] | |
listen = fpm.sock | |
pm = dynamic | |
pm.max_children = 5 | |
pm.min_spare_servers = 1 | |
pm.max_spare_servers = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment