Add services

This commit is contained in:
Oliver Davies 2025-04-23 20:48:20 +01:00
parent e79dba543f
commit ce93771d7f
3 changed files with 164 additions and 20 deletions

View file

@ -1,21 +1,82 @@
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
process-compose.url = "github:Platonic-Systems/process-compose-flake";
services.url = "github:juspay/services-flake";
systems.url = "github:nix-systems/default";
};
outputs =
{ nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
php = pkgs.php83;
phpPackages = pkgs.php83Packages;
in
{
devShells.${system}.default = pkgs.mkShellNoCC {
packages = [
php
phpPackages.composer
];
};
imports = [
inputs.process-compose.flakeModule
];
perSystem =
{
config,
lib,
pkgs,
...
}:
let
php = pkgs.php83;
phpPackages = pkgs.php83Packages;
databasePort = 3306;
webPort = 8000;
in
with lib;
{
process-compose."default" = {
imports = [
inputs.services.processComposeModules.default
];
services = {
mysql."mysql1" = {
enable = true;
initialDatabases = [
{ name = "drupal_nix_flake_example"; }
];
settings.mysqld.port = toString databasePort;
};
};
settings.processes = {
php = {
command = pkgs.writeShellApplication {
name = "php-local-server";
text = "${getExe php} -S 127.0.0.1:${toString webPort} -t web";
};
depends_on."mysql1".condition = "process_healthy";
};
};
};
devShells.default = pkgs.mkShell {
inputsFrom = [
config.process-compose."default".services.outputs.devShell
];
nativeBuildInputs = [
php
phpPackages.composer
];
};
formatter = pkgs.nixfmt-rfc-style;
};
};
}