53 lines
2.5 KiB
Nix
53 lines
2.5 KiB
Nix
{ system, inputs, pkgs, ... }:
|
|
pkgs.lib.optionalAttrs (system == "x86_64-linux") (let
|
|
lib = inputs.nixpkgs.lib;
|
|
revision = "b4c8548c09da21b2898443559a5b846f0ccf5dd8";
|
|
mkSystem = version: sourceRevision: lib.nixosSystem {
|
|
inherit system;
|
|
modules = [
|
|
(import ../../nixos/system/hectic-lab/affine.nix { domain = "example.test"; })
|
|
{
|
|
system.stateVersion = "26.05";
|
|
nixpkgs.overlays = [ (_: _: {
|
|
hectic.affine-frontend-static = pkgs.runCommand "affine-static-test" {
|
|
inherit version;
|
|
passthru.revision = sourceRevision;
|
|
} ''mkdir -p "$out"'';
|
|
}) ];
|
|
}
|
|
];
|
|
};
|
|
cfg = (mkSystem "0.27.4" revision).config;
|
|
mismatchedCfg = (mkSystem "0.27.5" revision).config;
|
|
mismatchedRevisionCfg = (mkSystem "0.27.4" "different-source").config;
|
|
main = cfg.systemd.services.affine;
|
|
frontend = cfg.systemd.services.affine-frontend;
|
|
in {
|
|
affine-frontend-module =
|
|
assert frontend.requires == [ "affine.service" ];
|
|
assert frontend.after == [ "affine.service" ];
|
|
assert frontend.partOf == [ "affine.service" ];
|
|
assert frontend.reloadIfChanged;
|
|
assert !frontend.restartIfChanged;
|
|
assert frontend.serviceConfig.Type == "oneshot";
|
|
assert frontend.serviceConfig.RemainAfterExit;
|
|
assert frontend.serviceConfig.ExecStart == frontend.serviceConfig.ExecReload;
|
|
assert lib.hasInfix "affine-frontend-compose.yaml up --detach --no-deps --force-recreate affine" frontend.serviceConfig.ExecStart;
|
|
assert frontend.serviceConfig.ExecStop == lib.replaceStrings
|
|
[ " up --detach --wait" ] [ " up --detach --no-deps --force-recreate affine" ] main.serviceConfig.ExecStart;
|
|
assert lib.hasSuffix "affine-compose.yaml up --detach --wait" main.serviceConfig.ExecStart;
|
|
assert lib.hasSuffix "affine-compose.yaml down" main.serviceConfig.ExecStop;
|
|
assert !lib.hasInfix "affine-frontend-compose.yaml" main.serviceConfig.ExecStart;
|
|
assert cfg.services.nginx.virtualHosts."affine.example.test".locations."/".proxyPass == "http://127.0.0.1:3010";
|
|
assert !(cfg.systemd.services ? affine-native);
|
|
assert lib.any (check:
|
|
check.message == "AFFiNE frontend assets and the deployed backend image must use the same release." &&
|
|
!check.assertion
|
|
) mismatchedCfg.assertions;
|
|
assert lib.any (check:
|
|
check.message == "AFFiNE frontend source revision must match the pinned 0.27.4 backend." &&
|
|
!check.assertion
|
|
) mismatchedRevisionCfg.assertions;
|
|
pkgs.runCommand "affine-frontend-module" {} ''touch "$out"'';
|
|
})
|