Add devenv

This commit is contained in:
Oliver Davies 2024-11-26 18:00:00 +00:00
parent 195c5b44a7
commit 87359835aa
9 changed files with 237 additions and 49 deletions

3
.envrc Normal file
View file

@ -0,0 +1,3 @@
source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k="
use devenv

7
.gitignore vendored
View file

@ -40,3 +40,10 @@ web/web.config
.env .env
docker-compose.override.yaml docker-compose.override.yaml
!/phpstan.neon
!/tests/Architecture/**
.devenv*
devenv.local.nix
.direnv
.pre-commit-config.yaml

View file

@ -45,6 +45,10 @@ git:
ignore: ignore:
- '!/phpstan.neon' - '!/phpstan.neon'
- '!/tests/Architecture/**' - '!/tests/Architecture/**'
- .devenv*
- devenv.local.nix
- .direnv
- .pre-commit-config.yaml
experimental: experimental:
createGitHubActionsConfiguration: true createGitHubActionsConfiguration: true

116
devenv.lock Normal file
View file

@ -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
}

92
devenv.nix Normal file
View file

@ -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
'';
}

15
devenv.yaml Normal file
View file

@ -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

View file

@ -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
}

View file

@ -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 ]; };
};
}

View file

@ -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/*