Files
matomo-bootstrap/flake.nix
Kevin Veen-Birkenbach 5e5b6c8933
Some checks failed
CI / test (push) Has been cancelled
fix(nix/e2e): keep Playwright install output off stdout
- Build matomo-bootstrap with setuptools/wheel in Nix
- Run playwright install via a dedicated pythonPlaywright env and redirect logs to stderr
- Add Nix-based E2E path: nix runner service + persistent nix/home volumes + host networking
- Add E2E test that runs bootstrap via `nix run` and asserts token-only stdout

https://chatgpt.com/share/694ab489-7028-800f-8398-a19a99faffd0
2025-12-23 17:44:41 +01:00

102 lines
2.6 KiB
Nix

{
description = "matomo-bootstrap";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
in
{
packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python312;
in
rec {
matomo-bootstrap = python.pkgs.buildPythonApplication {
pname = "matomo-bootstrap";
version = "1.0.0"; # keep in sync with pyproject.toml
pyproject = true;
src = self;
nativeBuildInputs = with python.pkgs; [
setuptools
wheel
];
propagatedBuildInputs = with python.pkgs; [
playwright
];
doCheck = false;
meta = with pkgs.lib; {
description = "Headless bootstrap tooling for Matomo (installation + API token provisioning)";
homepage = "https://github.com/kevinveenbirkenbach/matomo-bootstrap";
license = licenses.mit;
mainProgram = "matomo-bootstrap";
};
};
default = matomo-bootstrap;
}
);
apps = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python312;
pythonPlaywright = python.withPackages (ps: [
ps.playwright
]);
matomo = self.packages.${system}.matomo-bootstrap;
playwright-install = pkgs.writeShellApplication {
name = "matomo-bootstrap-playwright-install";
runtimeInputs = [ pythonPlaywright ];
text = ''
# Install Playwright browsers.
# IMPORTANT: Do not print anything to stdout (tests expect token-only stdout).
exec ${pythonPlaywright}/bin/python -m playwright install chromium 1>&2
'';
};
in
{
matomo-bootstrap = {
type = "app";
program = "${matomo}/bin/matomo-bootstrap";
};
matomo-bootstrap-playwright-install = {
type = "app";
program = "${playwright-install}/bin/matomo-bootstrap-playwright-install";
};
default = self.apps.${system}.matomo-bootstrap;
}
);
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python312;
in
{
default = pkgs.mkShell {
packages = with pkgs; [
python
python.pkgs.ruff
];
};
}
);
};
}