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

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
.editorconfig .editorconfig
.gitattributes .gitattributes
data/
recipes/README.txt recipes/README.txt
vendor/ vendor/
web/ web/

92
flake.lock generated
View file

@ -1,24 +1,106 @@
{ {
"nodes": { "nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1743550720,
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1745234285, "lastModified": 1744868846,
"narHash": "sha256-GfpyMzxwkfgRVN0cTGQSkTC0OHhEkv3Jf6Tcjm//qZ0=", "narHash": "sha256-5RJTdUHDmj12Qsv7XOhuospjAjATNiTMElplWnJE9Hs=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c11863f1e964833214b767f4a369c6e6a7aba141", "rev": "ebe4301cbd8f81c4f8d3244b3632338bbeb6d49c",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixos-unstable", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs-lib": {
"locked": {
"lastModified": 1743296961,
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"process-compose": {
"locked": {
"lastModified": 1740324671,
"narHash": "sha256-djc+wRG9L70jlW95Ck4GKr7nTPp1drfsXshJkYZAd9s=",
"owner": "Platonic-Systems",
"repo": "process-compose-flake",
"rev": "2a17e49b8a5d32278ed77e4a881f992472be18a1",
"type": "github"
},
"original": {
"owner": "Platonic-Systems",
"repo": "process-compose-flake",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs" "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"process-compose": "process-compose",
"services": "services",
"systems": "systems"
}
},
"services": {
"locked": {
"lastModified": 1745109634,
"narHash": "sha256-RO63ip09eIbLw2j1VV0xwtoRomQgopdp9v+VIYQ6AII=",
"owner": "juspay",
"repo": "services-flake",
"rev": "f308c7ed80043474d06b85fe55d1f1381421872a",
"type": "github"
},
"original": {
"owner": "juspay",
"repo": "services-flake",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
} }
} }
}, },

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 = outputs =
{ nixpkgs, ... }: inputs:
let inputs.flake-parts.lib.mkFlake { inherit inputs; } {
system = "x86_64-linux"; systems = import inputs.systems;
pkgs = import nixpkgs { inherit system; };
php = pkgs.php83; imports = [
phpPackages = pkgs.php83Packages; inputs.process-compose.flakeModule
in ];
{
devShells.${system}.default = pkgs.mkShellNoCC { perSystem =
packages = [ {
php config,
phpPackages.composer 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;
};
}; };
} }