This commit is contained in:
lelgenio 2024-06-22 14:20:17 -03:00
parent 761288fb81
commit 406d664697

123
flake.nix
View file

@ -51,63 +51,6 @@
packages.default = my-crate;
nixosModules.default =
{ pkgs, config, ... }:
let
cfg = config.services.warthunder-leak-counter;
in
{
options.services.warthunder-leak-counter = {
enable = lib.mkEnableOption "Enable Warthunder Leak Counter";
staticDir = lib.mkOption {
default = toString ./static;
type = lib.types.str;
};
port = lib.mkOption {
type = lib.types.port;
default = 6263;
};
};
config = lib.mkIf cfg.enable {
systemd.services.warthunder-leak-counter = {
script = lib.getExe my-crate;
environment = {
WARTHUNDER_LEAK_SERVE_PORT = toString cfg.port;
WARTHUNDER_LEAK_STATIC_DIR = cfg.staticDir;
};
after = [ "network.target" ];
wantedBy = [ "network.target" ];
};
};
};
packages.nixosConfigurations.test-server = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
self.nixosModules.${system}.default
(nixpkgs + "/nixos/modules/virtualisation/qemu-vm.nix")
(
{ config, ... }:
{
services.warthunder-leak-counter.enable = true;
users.users.root.password = "root";
networking.firewall.enable = false;
virtualisation.forwardPorts = [
{
from = "host";
host.port = 8888;
guest.port = config.services.warthunder-leak-counter.port;
}
];
system.stateVersion = "24.05";
}
)
];
};
devShells.default = pkgs.mkShell {
inherit (commonArgs) buildInputs;
@ -128,5 +71,69 @@
);
};
}
);
)
// {
nixosModules.default =
{
pkgs,
lib,
config,
...
}:
let
cfg = config.services.warthunder-leak-counter;
in
{
options.services.warthunder-leak-counter = {
enable = lib.mkEnableOption "Enable Warthunder Leak Counter";
staticDir = lib.mkOption {
default = toString ./static;
type = lib.types.str;
};
port = lib.mkOption {
type = lib.types.port;
default = 6263;
};
};
config = lib.mkIf cfg.enable {
systemd.services.warthunder-leak-counter = {
script = lib.getExe self.packages.${pkgs.system}.default;
environment = {
WARTHUNDER_LEAK_SERVE_PORT = toString cfg.port;
WARTHUNDER_LEAK_STATIC_DIR = cfg.staticDir;
};
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
};
};
};
nixosConfigurations.test-server = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.default
(nixpkgs + "/nixos/modules/virtualisation/qemu-vm.nix")
(
{ config, ... }:
{
services.warthunder-leak-counter.enable = true;
users.users.root.password = "root";
networking.firewall.enable = false;
virtualisation.forwardPorts = [
{
from = "host";
host.port = 8888;
guest.port = config.services.warthunder-leak-counter.port;
}
];
system.stateVersion = "24.05";
}
)
];
};
};
}