Initial commit

This commit is contained in:
Nikos Papadakis 2024-01-15 16:32:45 +02:00
commit af6c75800f
Signed by untrusted user who does not match committer: nikos
GPG key ID: 78871F9905ADFF02
4 changed files with 108 additions and 0 deletions

5
.editorconfig Normal file
View file

@ -0,0 +1,5 @@
root = true
[*.nix]
indent_style = space
indent_size = 2

10
.envrc Normal file
View file

@ -0,0 +1,10 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi
nix_direnv_watch_file flake.nix
nix_direnv_watch_file flake.lock
if ! use flake . --impure
then
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
core/
.direnv
.devenv
flake.lock

89
flake.nix Normal file
View file

@ -0,0 +1,89 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
};
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
};
outputs = { self, nixpkgs, devenv, systems, ... } @ inputs:
let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
in
{
packages = forEachSystem (system: {
devenv-up = self.devShells.${system}.default.config.procfileScript;
});
devShells = forEachSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
config = self.devShells.${system}.default.config;
in
{
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
packages = [ pkgs.wp-cli ];
languages.php = {
enable = true;
fpm.pools.wp = {
settings = {
"pm" = "dynamic";
"pm.max_children" = 75;
"pm.start_servers" = 10;
"pm.min_spare_servers" = 5;
"pm.max_spare_servers" = 20;
"pm.max_requests" = 500;
};
};
};
services.mysql = {
enable = true;
package = pkgs.mariadb_110;
ensureUsers = [
{
name = "wordpress";
password = "wordpress";
ensurePermissions = { "wordpress.*" = "ALL PRIVILEGES"; };
}
];
initialDatabases = [{ name = "wordpress"; }];
};
services.caddy = {
enable = true;
virtualHosts.":8000" = {
extraConfig = ''
root * ${config.env.DEVENV_ROOT}/core
php_fastcgi unix/${config.languages.php.fpm.pools.wp.socket}
file_server
'';
};
};
# scripts.install_wp.exec = ''
# set -e
# if ! [ -d ./data ]; then
# wp core download --path=data
# wp config create --path=data --dbname=wp --dbuser=dev --dbhost=127.0.0.1
# wp db create --path=data --defaults
# wp core install --path=data --url=localhost --title=WordPressDev --admin_user=admin --admin_password=admin --admin_email=admin@wp.local
# else
# echo "WordPress already installed. To force re-install remove the data directory"
# fi
# '';
}
];
};
});
};
}