This commit is contained in:
mtgmonkey 2025-06-10 07:06:37 -04:00
parent fbe76946dc
commit 98d0188530
3 changed files with 71 additions and 162 deletions

View file

@ -23,13 +23,33 @@
cp . $out/src
'';
};
port = 8920;
source = "${pkgs.callPackage pkg}/src";
module = {
in {
packages.${system}.default = pkg;
nixosModules.${system}.default = {
lib,
config,
...
}: {
options = {
services.jank-client = {
enable = lib.mkEnableOption "jank client";
package = lib.mkOption {
description = "jank client package";
default = pkgs.callPackage pkg;
type = lib.types.package;
};
port = lib.mkOption {
description = "port to bind to";
default = 8080;
type = lib.types.int;
};
};
};
config = lib.mkIf config.services.jank-client.enable {
environment.systemPackages = [
(lib.getExe
config.services.jank-client.package)
];
virtualisation.docker = {
enable = true;
autoPrune.enable = true;
@ -38,7 +58,7 @@
virtualisation.oci-containers.containers."jank-client-jank" = {
image = "compose2nix/jank-client-jank";
ports = [
"${port}:8080/tcp"
"${config.services.jank-client.port}:8080/tcp"
];
log-driver = "journald";
extraOptions = [
@ -86,7 +106,7 @@
TimeoutSec = 300;
};
script = ''
cd ${source}
cd ${config.services.jank-client.package}/src
docker build -t compose2nix/jank-client-jank .
'';
};
@ -97,31 +117,6 @@
wantedBy = ["multi-user.target"];
};
};
in {
packages.${system}.default = pkg;
nixosModules.${system}.default = {
lib,
config,
module,
...
}: {
options = {
services.jank-client = {
enable = lib.mkEnableOption "jank client";
package = lib.mkOption {
description = "jank client package";
default = pkgs.callPackage pkg;
type = lib.types.package;
};
};
};
config = lib.mkIf config.services.jank-client.enable {
environment.systemPackages = [
(lib.getExe
config.services.jank-client.package)
];
inherit module;
};
};
};
}

View file

@ -1,85 +0,0 @@
# Auto-generated using compose2nix v0.3.1.
{
pkgs,
lib,
port,
...
}: {
# Runtime
virtualisation.docker = {
enable = true;
autoPrune.enable = true;
};
virtualisation.oci-containers.backend = "docker";
# Containers
virtualisation.oci-containers.containers."jank-client-jank" = {
image = "compose2nix/jank-client-jank";
ports = [
"${port}:8080/tcp"
];
log-driver = "journald";
extraOptions = [
"--network-alias=jank"
"--network=jank-client_default"
];
};
systemd.services."docker-jank-client-jank" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
RestartMaxDelaySec = lib.mkOverride 90 "1m";
RestartSec = lib.mkOverride 90 "100ms";
RestartSteps = lib.mkOverride 90 9;
};
after = [
"docker-network-jank-client_default.service"
];
requires = [
"docker-network-jank-client_default.service"
];
partOf = [
"docker-compose-jank-client-root.target"
];
wantedBy = [
"docker-compose-jank-client-root.target"
];
};
# Networks
systemd.services."docker-network-jank-client_default" = {
path = [pkgs.docker];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStop = "docker network rm -f jank-client_default";
};
script = ''
docker network inspect jank-client_default || docker network create jank-client_default
'';
partOf = ["docker-compose-jank-client-root.target"];
wantedBy = ["docker-compose-jank-client-root.target"];
};
# Builds
systemd.services."docker-build-jank-client-jank" = {
path = [pkgs.docker pkgs.git];
serviceConfig = {
Type = "oneshot";
TimeoutSec = 300;
};
script = ''
cd /home/mtgmonkey/JankClient
docker build -t compose2nix/jank-client-jank .
'';
};
# Root service
# When started, this will automatically create all resources and start
# the containers. When stopped, this will teardown all resources.
systemd.targets."docker-compose-jank-client-root" = {
unitConfig = {
Description = "Root target generated by compose2nix.";
};
wantedBy = ["multi-user.target"];
};
}

1
result
View file

@ -1 +0,0 @@
/nix/store/2ry4rsr3bp9p0b7bgdwy1yh2iksc4vaz-jank-client