This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
{ system, inputs, pkgs, ... }:
|
||||
pkgs.lib.optionalAttrs (system == "x86_64-linux") (let
|
||||
lib = inputs.nixpkgs.lib;
|
||||
fakePackage = pkgs.writeShellScriptBin "affine-chatgpt" "exit 0";
|
||||
mkSystem = enabled: (lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
(import ../../nixos/module/hectic/service/affine-chatgpt.nix {})
|
||||
{
|
||||
system.stateVersion = "26.05";
|
||||
hectic.services.affine-chatgpt = { enable = enabled; package = fakePackage; };
|
||||
}
|
||||
];
|
||||
}).config;
|
||||
cfg = mkSystem true;
|
||||
disabledCfg = mkSystem false;
|
||||
app = cfg.systemd.services.affine-chatgpt;
|
||||
hostCfg = (lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
(import ../../nixos/module/hectic/service/affine-chatgpt.nix {})
|
||||
(import ../../nixos/module/hectic/service/affine.nix { inherit inputs; flake = ../..; })
|
||||
../../nixos/system/hectic-lab/affine-chatgpt.nix
|
||||
{
|
||||
system.stateVersion = "26.05";
|
||||
hectic.services.affine = {
|
||||
enable = true;
|
||||
package = fakePackage;
|
||||
environmentFile = "/run/secrets/affine-test.env";
|
||||
};
|
||||
hectic.services.affine-chatgpt.package = fakePackage;
|
||||
}
|
||||
];
|
||||
}).config;
|
||||
in {
|
||||
affine-chatgpt-module =
|
||||
assert !(disabledCfg.systemd.services ? affine-chatgpt);
|
||||
assert cfg.users.users.affine-chatgpt.isSystemUser;
|
||||
assert app.serviceConfig.User == "affine-chatgpt";
|
||||
assert app.serviceConfig.Group == "affine-chatgpt";
|
||||
assert app.serviceConfig.Type == "simple";
|
||||
assert app.serviceConfig.StateDirectoryMode == "0700";
|
||||
assert lib.hasSuffix "--gateway-key-file /var/lib/affine-chatgpt/gateway-key" app.serviceConfig.ExecStart;
|
||||
assert app.unitConfig.ConditionPathExists == "/var/lib/affine-chatgpt/session/credentials.json";
|
||||
assert lib.hasInfix "serve --host 127.0.0.1 --port 3012" app.serviceConfig.ExecStart;
|
||||
assert app.serviceConfig.NoNewPrivileges;
|
||||
assert app.serviceConfig.ProtectSystem == "strict";
|
||||
assert !(cfg.systemd.services ? affine);
|
||||
assert !cfg.virtualisation.docker.enable;
|
||||
assert cfg.networking.firewall.allowedTCPPorts == [];
|
||||
assert hostCfg.hectic.services.affine-chatgpt.enable;
|
||||
assert lib.elem "affine-chatgpt.service" hostCfg.systemd.services.affine-native.wants;
|
||||
assert lib.elem "affine-chatgpt.service" hostCfg.systemd.services.affine-native.after;
|
||||
assert lib.hasInfix "serve --host 127.0.0.1 --port 3012" hostCfg.systemd.services.affine-chatgpt.serviceConfig.ExecStart;
|
||||
pkgs.runCommand "affine-chatgpt-module" {} ''touch "$out"'';
|
||||
})
|
||||
Reference in New Issue
Block a user