diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..894571b --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k=" + +use devenv diff --git a/.gitignore b/.gitignore index 01d9ebb..e8c6064 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,10 @@ web/web.config .env docker-compose.override.yaml + +!/phpstan.neon +!/tests/Architecture/** +.devenv* +devenv.local.nix +.direnv +.pre-commit-config.yaml diff --git a/build.yaml b/build.yaml index 151acf1..e2c7b7a 100644 --- a/build.yaml +++ b/build.yaml @@ -45,6 +45,10 @@ git: ignore: - '!/phpstan.neon' - '!/tests/Architecture/**' + - .devenv* + - devenv.local.nix + - .direnv + - .pre-commit-config.yaml experimental: createGitHubActionsConfiguration: true diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..1c84c63 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,116 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1732585607, + "owner": "cachix", + "repo": "devenv", + "rev": "a520f05c40ebecaf5e17064b27e28ba8e70c49fb", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716977621, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1731797254, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1732021966, + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "3308484d1a443fc5bc92012435d79e80458fe43c", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..84792ae --- /dev/null +++ b/devenv.nix @@ -0,0 +1,92 @@ +{ pkgs, ... }: + +let + drupal = { + docroot = "web"; + theme = { + name = "opdavies"; + path = "${drupal.docroot}/themes/custom/${drupal.theme.name}"; + }; + }; +in +{ + packages = with pkgs; [ git ]; + + dotenv.disableHint = true; + + languages = { + javascript = { + enable = true; + npm.enable = true; + }; + + php = { + enable = true; + version = "8.2"; + + ini = '' + memory_limit = 256M + ''; + + fpm.pools.web = { + listen = "127.0.0.1:9000"; + + settings = { + "pm" = "dynamic"; + "pm.max_children" = 75; + "pm.max_requests" = 500; + "pm.max_spare_servers" = 20; + "pm.min_spare_servers" = 5; + "pm.start_servers" = 10; + }; + }; + }; + }; + + services = { + caddy = { + enable = true; + + config = '' + { + http_port 8080 + } + + localhost:8080 { + root * ${drupal.docroot} + encode gzip + php_fastcgi localhost:9000 + file_server + } + ''; + }; + + mysql = { + enable = true; + initialDatabases = [ { name = "app"; } ]; + }; + }; + + processes = { + tailwind.exec = '' + cd ${drupal.theme.path} + watchexec --exts css,twig tailwindcss --config assets/tailwind.config.ts \ + --output dist/tailwind.css + ''; + }; + + enterShell = '' + if [[ ! -d vendor ]]; then + composer install + fi + + if [[ ! -d ${drupal.theme.path}/node_modules ]]; then + cd "${drupal.theme.path}" \ + && npm clean-install + fi + ''; + + enterTest = '' + phpunit --testdox + ''; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..116a2ad --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling + +# If you're using non-OSS software, you can set allowUnfree to true. +# allowUnfree: true + +# If you're willing to use a package that's vulnerable +# permittedInsecurePackages: +# - "openssl-1.1.1w" + +# If you have more than one devenv you can merge them +#imports: +# - ./backend diff --git a/web/themes/custom/opdavies/flake.lock b/web/themes/custom/opdavies/flake.lock deleted file mode 100644 index e99f60b..0000000 --- a/web/themes/custom/opdavies/flake.lock +++ /dev/null @@ -1,27 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1712192574, - "narHash": "sha256-LbbVOliJKTF4Zl2b9salumvdMXuQBr2kuKP5+ZwbYq4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "f480f9d09e4b4cf87ee6151eba068197125714de", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/web/themes/custom/opdavies/flake.nix b/web/themes/custom/opdavies/flake.nix deleted file mode 100644 index 84f207d..0000000 --- a/web/themes/custom/opdavies/flake.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - - outputs = { nixpkgs, ... }: - let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - - inherit (pkgs) just mkShell nodejs; - in { - devShells.${system}.default = mkShell { buildInputs = [ just nodejs ]; }; - }; -} diff --git a/web/themes/custom/opdavies/justfile b/web/themes/custom/opdavies/justfile deleted file mode 100644 index a7d0c58..0000000 --- a/web/themes/custom/opdavies/justfile +++ /dev/null @@ -1,9 +0,0 @@ -_default: - just --list - -build-css *args: - npx tailwind --config assets/tailwind.config.ts \ - --output dist/tailwind.css {{ args }} - -clean: - rm -fr node_modules dist/*