tmpmail/flake.nix

56 lines
1.7 KiB
Nix
Raw Permalink Normal View History

2023-07-17 22:05:21 +02:00
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }:
2023-07-17 22:26:04 +02:00
flake-utils.lib.eachDefaultSystem (system:
2023-07-17 22:05:21 +02:00
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustVersion = pkgs.rust-bin.stable.latest.default;
rustPlatform = pkgs.makeRustPlatform {
cargo = rustVersion;
rustc = rustVersion;
};
myRustBuild = rustPlatform.buildRustPackage {
pname = "tmpmail";
version = "0.1.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};
in {
defaultPackage = myRustBuild;
devShell = pkgs.mkShell {
buildInputs =
[ (rustVersion.override { extensions = [ "rust-src" ]; }) ];
};
2023-07-17 22:21:30 +02:00
}
2023-07-17 22:26:04 +02:00
) // {
2023-07-17 22:21:30 +02:00
nixosModules.default = { config, lib, pkgs, ... }:
with lib;
let cfg = config.mawalu.services.norbert;
in
2023-07-17 22:05:21 +02:00
{
options.mawalu.services.rail = {
enable = mkEnableOption "Enable the rail tmpmail server";
};
config = mkIf cfg.enable {
systemd.services.rail = {
wantedBy = [ "multi-user.target" ];
serviceConfig = let pkg = self.defaultPackage.${pkgs.system};
2023-07-17 22:05:21 +02:00
in {
Restart = "on-failure";
ExecStart = "${pkg}/bin/tmpmail";
DynamicUser = "yes";
AmbientCapabilities = ["CAP_NET_BIND_SERVICE"];
};
};
};
};
2023-07-17 22:21:30 +02:00
};
2023-07-17 22:05:21 +02:00
}