deploy config
This commit is contained in:
parent
da40e48b19
commit
d0a7e7ec88
10 changed files with 231 additions and 39 deletions
118
flake.nix
118
flake.nix
|
@ -3,6 +3,11 @@
|
|||
nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
crane = {
|
||||
url = "github:ipetkov/crane";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
@ -10,6 +15,7 @@
|
|||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
crane,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
|
@ -17,22 +23,110 @@
|
|||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
inherit (pkgs) lib;
|
||||
|
||||
craneLib = crane.mkLib pkgs;
|
||||
|
||||
commonArgs = {
|
||||
src = craneLib.cleanCargoSource ./.;
|
||||
strictDeps = true;
|
||||
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||
buildInputs = with pkgs; [ openssl ];
|
||||
};
|
||||
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
|
||||
my-crate = craneLib.buildPackage (
|
||||
commonArgs
|
||||
// {
|
||||
src = ./.; # Allow access to assets, like ./templates
|
||||
inherit cargoArtifacts;
|
||||
meta.mainProgram = "warthunder-leak-counter";
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
rustc
|
||||
cargo
|
||||
rustfmt
|
||||
rust-analyzer
|
||||
clippy
|
||||
cargo-feature
|
||||
cargo-watch
|
||||
pkg-config
|
||||
openssl
|
||||
curl
|
||||
checks = {
|
||||
my-crate-fmt = craneLib.cargoFmt { inherit (commonArgs) src; };
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
nativeBuildInputs =
|
||||
with pkgs;
|
||||
(
|
||||
[
|
||||
rustc
|
||||
cargo
|
||||
rustfmt
|
||||
rust-analyzer
|
||||
clippy
|
||||
cargo-feature
|
||||
cargo-watch
|
||||
curl
|
||||
]
|
||||
++ commonArgs.nativeBuildInputs
|
||||
);
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue