56 lines
1.7 KiB
Nix
56 lines
1.7 KiB
Nix
|
{
|
||
|
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, ... }:
|
||
|
flake-utils.lib.eachDefaultSystem (system:
|
||
|
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" ]; }) ];
|
||
|
};
|
||
|
nixosModules.default = { config, lib, pkgs, ... }:
|
||
|
with lib;
|
||
|
let cfg = config.mawalu.services.norbert;
|
||
|
in
|
||
|
{
|
||
|
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.packages.${pkgs.system}.default;
|
||
|
in {
|
||
|
Restart = "on-failure";
|
||
|
ExecStart = "${pkg}/bin/tmpmail";
|
||
|
DynamicUser = "yes";
|
||
|
AmbientCapabilities = ["CAP_NET_BIND_SERVICE"];
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
|
||
|
}
|
||
|
);
|
||
|
}
|