Improve web development setup

Group kinds of projects in files.
Hide info for customers via git crypt.
Solve todo to auto generate permissions for databases.
This commit is contained in:
Daniel Siepmann 2023-03-08 08:35:20 +01:00
parent 1be9c42770
commit 3fbb26a6f6
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
9 changed files with 38 additions and 36 deletions

1
.gitattributes vendored
View file

@ -5,4 +5,5 @@ home/files/rclone.conf filter=git-crypt diff=git-crypt
home/files/typo3-configuration/client-specific/** filter=git-crypt diff=git-crypt
home/packages/custom/dmenu-scripts/customer-issue.sh filter=git-crypt diff=git-crypt
systems/hikari/files/hosts filter=git-crypt diff=git-crypt
systems/hikari/web-development/projects/customer.nix filter=git-crypt diff=git-crypt
shells/** filter=git-crypt diff=git-crypt

View file

@ -32,8 +32,6 @@ See: https://github.com/NixOS/nixos-hardware
TODOs
-----
* Auto generate permissions for all the databases.
* Add docker-compose / podman-compose for Elasticsearch, proxy, solr.
* Add xdebug setup for fpm.

View file

@ -1,17 +1,24 @@
{ pkgs, config, lib, ... }:
{
let
mysqlEnsurePermissionsForDevUser = builtins.listToAttrs (
map (databaseName: {
name = "${databaseName}.*";
value = "ALL PRIVILEGES";
})
config.custom.web-development.databases
);
in {
imports = [
./lib/mkcert.nix
./domains/mailhog.localhost.nix
./domains/tea-docs.typo3.localhost.nix
./domains/daniel-siepmann.localhost.nix
./domains/monorepo.reuter.localhost.nix
./projects/private.nix
./projects/service-wrapper.nix
./projects/typo3.nix
./projects/customer.nix
];
@ -21,6 +28,19 @@
rootPath = lib.mkOption {
type = lib.types.path;
default = "/var/projects";
description = ''
The root folder where web development happens.
All Projects need to be placed within this folder.
'';
};
databases = lib.mkOption {
type = lib.types.listOf lib.types.string;
default = [];
example = lib.literalExpression "[namespace_project namespace2_project1]";
description = ''
A list of all necessary databases.
Used to create the databases and grant permissions.
'';
};
};
@ -67,18 +87,14 @@
# INITIALLY once change dev user to be identified by password
# alter user dev@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD('dev');
name = "dev";
ensurePermissions = {
# TODO: Auto build from defined databases?!
"own_danielsiepmann.*" = "ALL PRIVILEGES";
"reuter_reuter.*" = "ALL PRIVILEGES";
};
ensurePermissions = mysqlEnsurePermissionsForDevUser;
}
];
ensureDatabases = [
"testing" # Used by TYPO3 functional tests
"testing_at" # Used by TYPO3 Acceptance tests
];
] ++ config.custom.web-development.databases;
settings = {
mysqld = {
@ -94,7 +110,7 @@
};
systemd.tmpfiles.rules = [
# Would be cool to improve this somehow.
# TODO: Improve linking TYPO3 global configuration
# Current issues: The link is created once against nix store.
# Changes are not reflected until reboot?
"C ${config.custom.web-development.rootPath}/own/typo3-configuration - - - - ${config.users.users.daniels.home}/.local/share/typo3-configuration"

View file

@ -1,17 +0,0 @@
{
pkgs
,lib
,config
, ...
}:
let
phps = import <phps>;
in import ./../lib/create-typo3.nix {
inherit config lib pkgs;
domain = "monorepo.reuter.localhost";
relativeDocumentRoot = "company/customers/reuter/monorepo";
databaseName = "reuter_reuter";
phpPackage = phps.packages.x86_64-linux.php73;
}

View file

@ -11,6 +11,12 @@
let
documentRoot = "${config.custom.web-development.rootPath}/${relativeDocumentRoot}";
in {
custom.web-development = {
databases = [databaseName];
};
services = {
httpd.virtualHosts.${domain} = {
@ -98,7 +104,5 @@ in {
};
};
mysql.ensureDatabases = [databaseName];
};
}

Binary file not shown.