Compare commits

...

2 Commits

Author SHA1 Message Date
c9e398eb7f add aarch64-linux as supported System
Signed-off-by: Florian Brandes <florian.brandes@posteo.de>
2024-07-27 18:17:51 +02:00
d3055a9e8b nixfmt
Signed-off-by: Florian Brandes <florian.brandes@posteo.de>
2024-07-27 18:14:12 +02:00
6 changed files with 76 additions and 40 deletions

View File

@@ -1,8 +1,11 @@
{ pkgs ? import <nixpkgs> { }, lib ? pkgs.lib, }:
{
pkgs ? import <nixpkgs> { },
lib ? pkgs.lib,
}:
pkgs.python3Packages.buildPythonPackage rec {
pname = "smtprd-ng";
version = "0.2.0";
version = "0.3.0";
pyproject = true;
src = lib.cleanSource ./.;
@@ -21,10 +24,8 @@ pkgs.python3Packages.buildPythonPackage rec {
meta = {
description = "SMTP forwarding relay daemon with signing and encryption";
homepage =
"https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z3gWc1qgaeZaoGwL4WTstLNoqjayM";
homepage = "https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z3gWc1qgaeZaoGwL4WTstLNoqjayM";
license = lib.licenses.agpl3Only;
maintainers = [ lib.maintainers.gador ];
};
}

View File

@@ -1,10 +1,24 @@
{ pkgs, lib, config, inputs, ... }:
{
pkgs,
lib,
config,
inputs,
...
}:
let req = pkgs.concatText "req" [ ./requirements.txt ./requirements-dev.txt ];
in {
let
req = pkgs.concatText "req" [
./requirements.txt
./requirements-dev.txt
];
in
{
# https://devenv.sh/packages/
packages = [ pkgs.file pkgs.swig4 pkgs.openssl ];
packages = [
pkgs.file
pkgs.swig4
pkgs.openssl
];
# https://devenv.sh/languages/
languages.nix.enable = true;
@@ -19,6 +33,7 @@ in {
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks = {
nixfmt.enable = true;
nixfmt.package = pkgs.nixfmt-rfc-style;
# remove unused imports
autoflake.enable = true;
# formatter
@@ -31,6 +46,5 @@ in {
pylint.enable = true;
detect-private-keys.enable = true;
detect-private-keys.excludes = [ "tests/" ];
};
}

View File

@@ -7,15 +7,33 @@
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks, }:
let supportedSystems = [ "x86_64-linux" "aarch64-darwin" ];
in {
outputs =
{
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
}:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
in
{
nixosModules.smtprd-ng = import ./module.nix;
overlays.default = import ./overlay.nix { inherit self; };
} // flake-utils.lib.eachSystem supportedSystems (system:
let pkgs = import nixpkgs { inherit system; };
in {
packages = { smtprd-ng = pkgs.callPackage ./. { }; };
}
// flake-utils.lib.eachSystem supportedSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages = {
smtprd-ng = pkgs.callPackage ./. { };
};
packages.default = self.packages.${system}.smtprd-ng;
@@ -24,12 +42,12 @@
src = ./.;
hooks = {
nixfmt.enable = true;
nixfmt.package = pkgs.nixfmt-rfc-style;
autoflake.enable = true;
black.enable = true;
isort.enable = true;
isort.settings.flags = "--profile black";
pylint.enable =
false; # doesn't work correctly with module imports in flake
pylint.enable = false; # doesn't work correctly with module imports in flake
detect-private-keys.enable = true;
detect-private-keys.excludes = [ "tests/" ];
};
@@ -41,5 +59,6 @@
type = "app";
program = "${self.packages.${system}.smtprd-ng}/bin/smtprd-ng";
};
});
}
);
}

View File

@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.smtprd-ng;
@@ -13,23 +18,23 @@ let
hostname = cfg.client.hostname;
port = cfg.client.port;
username = cfg.client.username;
password_file = if cfg.client.password_file != "" then
"/run/credentials/smtprd-ng.service/password_file"
else
"";
password_file =
if cfg.client.password_file != "" then "/run/credentials/smtprd-ng.service/password_file" else "";
sender = cfg.client.sender;
use_tls = cfg.client.use_tls;
start_tls = cfg.client.start_tls;
smime_cert = cfg.client.smime_cert;
smime_cert_private = if cfg.client.smime_cert_private != "" then
"/run/credentials/smtprd-ng.service/smime_cert_private"
else
"";
smime_cert_private =
if cfg.client.smime_cert_private != "" then
"/run/credentials/smtprd-ng.service/smime_cert_private"
else
"";
};
emails = cfg.emails;
};
confFile = pkgs.writeText "config.ini" cfgText;
in {
in
{
options.services.smtprd-ng = {
enable = mkEnableOption "smtprd-ng";
@@ -148,10 +153,10 @@ in {
message = "Use either TLS or STARTTLS, not both.";
}
{
assertion = cfg.client.smime_cert == null || (cfg.client.smime_cert
!= null && cfg.client.smime_cert_private != null);
message =
"If a S/MIME certificate should be used to sign messages, the private key to this certificate must be supplied.";
assertion =
cfg.client.smime_cert == null
|| (cfg.client.smime_cert != null && cfg.client.smime_cert_private != null);
message = "If a S/MIME certificate should be used to sign messages, the private key to this certificate must be supplied.";
}
{
assertion = cfg.emails != null;

View File

@@ -1,4 +1 @@
{ self }:
_final: prev: {
smtprd-ng = self.packages.${prev.system}.smtprd-ng;
}
{ self }: _final: prev: { smtprd-ng = self.packages.${prev.system}.smtprd-ng; }

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "smtprd-ng"
version = "0.2.0"
version = "0.3.0"
description = "SMTP forwarding relay daemon with signing and encryption"
authors = [{ name = "Florian Brandes", email = "dev@mail.flo-the.dev" }]
classifiers = [