You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.1 KiB
Nix
79 lines
2.1 KiB
Nix
{
|
|
inputs = {
|
|
utils.url = "github:numtide/flake-utils";
|
|
naersk.url = "github:nix-community/naersk";
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
};
|
|
|
|
outputs = { self, utils, naersk, nixpkgs }:
|
|
utils.lib.eachSystem [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
] (system:
|
|
let
|
|
pkgs = (import nixpkgs) {
|
|
inherit system;
|
|
};
|
|
|
|
naersk' = pkgs.callPackage naersk {};
|
|
|
|
in {
|
|
packages = {
|
|
default = naersk'.buildPackage {
|
|
nativeBuildInputs = [];
|
|
src = ./.;
|
|
};
|
|
};
|
|
}
|
|
) // {
|
|
nixosModule = {config, lib, pkgs, ... }:
|
|
with lib;
|
|
let cfg = config.ashe.services.contact_rs;
|
|
|
|
in {
|
|
options.ashe.services.contact_rs = {
|
|
enable = mkEnableOption "Enables the rust contact service";
|
|
|
|
port = mkOption rec {
|
|
type = types.int;
|
|
default = 8000;
|
|
example = default;
|
|
description = "The port for this service to listen on";
|
|
|
|
};
|
|
|
|
domain = mkOption rec {
|
|
type = types.str;
|
|
default = "contact.tempest.dev";
|
|
example = default;
|
|
description = "The domain name for the contact server";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services."ashe.contact_rs" = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = let pkg = self.packages.${pkgs.system}.default;
|
|
in {
|
|
Restart = "on-failure";
|
|
ExecStart = "${pkg}/bin/contact-rs ${cfg.configFile}";
|
|
DynamicUser = "yes";
|
|
PrivateTmp = "yes";
|
|
Environment = [
|
|
"PORT=${toString cfg.port}"
|
|
];
|
|
};
|
|
};
|
|
|
|
services.nginx.virtualHosts.${cfg.domain} = {
|
|
locations."/" = { proxyPass = "http://127.0.0.1:${toString cfg.port}"; };
|
|
forceSSL = true;
|
|
enableACME = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|