From fbb6b500ea981b3fe7603288f0496cc3333245bf Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 16 Mar 2023 09:43:31 -0300 Subject: queue.scm: Split postfix-service-type into {local,internet}-postfix-service-type Also add those to `Makefile` as separate targets. BONUS: better naming of Guix targets in `Makefile`. Instead of `all-{packages,services}`, it is now `guix-{packages,services}`, as there are other packages being built that do not belong to Guix, and maybe more services in the future. --- Makefile | 20 ++++++++---- src/org/euandre/queue.scm | 83 ++++++++++++++++++++++++++++++++++------------- tests/internet-system.scm | 33 +++++++++++++++++++ tests/local-system.scm | 25 ++++++++++++++ tests/test-system.scm | 36 -------------------- 5 files changed, 131 insertions(+), 66 deletions(-) create mode 100644 tests/internet-system.scm create mode 100644 tests/local-system.scm delete mode 100644 tests/test-system.scm diff --git a/Makefile b/Makefile index 31686c0..9cdb2db 100644 --- a/Makefile +++ b/Makefile @@ -4,18 +4,24 @@ all: EuAndreh.key guix nix -guix: all-packages all-services +guix: guix-packages guix-services -nix: - nix-build build.nix - -all-packages: +guix-packages: guix build -v3 -Lsrc/ -K \ -f src/org/euandre/packages.scm \ -f src/org/euandre/queue.scm \ -all-services: - guix system -v3 -Lsrc/ -K build tests/test-system.scm +guix-services-local: + guix system -v3 -Lsrc/ -K build tests/local-system.scm + +guix-services-internet: + guix system -v3 -Lsrc/ -K build tests/internet-system.scm + +guix-services: guix-services-local guix-services-internet + +nix: + nix-build build.nix + refresh: sh scripts/paku -rg diff --git a/src/org/euandre/queue.scm b/src/org/euandre/queue.scm index 3fe4db2..2485b97 100644 --- a/src/org/euandre/queue.scm +++ b/src/org/euandre/queue.scm @@ -120,7 +120,8 @@ postfix-etc-files postfix-setuid-programs postfix-shepherd-service - postfix-service-type + local-postfix-service-type + internet-postfix-service-type dovecot2-service-type @@ -1012,6 +1013,7 @@ milter_default_action = accept (group setgid-group))) '())))) +;; FIXME: parameterize /var/mail (define (postfix-activation config) (match-record config (queue-directory) @@ -1144,32 +1146,67 @@ max_age: 604800 (cyrus-service-configuration (name "smtpd.conf")))) +(define local-postfix-service-extensions + (list + (service-extension etc-service-type + postfix-etc-files) + (service-extension account-service-type + postfix-accounts) + (service-extension setuid-program-service-type + postfix-setuid-programs) + (service-extension activation-service-type + postfix-activation) + (service-extension profile-service-type + (compose list postfix-configuration-postfix)) + (service-extension shepherd-root-service-type + postfix-shepherd-service))) + +(define local-postfix-service-type + (service-type + (name 'postfix) + (extensions local-postfix-service-extensions) + (default-value (postfix-configuration)) + (description + " + Run the Postfix MTA. + + This is the top-level system service for Postfix. + + It includes: + - populating /etc/postfix/ with read-only configuration files; + - the user and groups used by Postfix when handling email delivery; + - the special setgid binaries for daily usage, such as \"sendmail\"; + - the Shepherd service for starting, stopping and *reloading* the + service without restarting it; + - the activation script for creating the required directories and + configuring them with the correct permissions; + - the binaries in the system profile so that one doesn't need to explicilty + include the package when the service is already enabled. + + An extension to the log-rotation service isn't included: the default + rottlog configuration already includes /var/log/maillog in its routine, + so it is kept out. + + The defaults of provide sane default values for + most things, such as group names, data and queue directories, etc. When + used as-is, it creates a Postfix server that sends email from local users + of the domain provided by \"/etc/hostname\"."))) -(define postfix-service-type +(define internet-postfix-service-type (service-type (name 'postfix) (extensions - (list - (service-extension etc-service-type - postfix-etc-files) - (service-extension account-service-type - postfix-accounts) - (service-extension setuid-program-service-type - postfix-setuid-programs) - (service-extension activation-service-type - postfix-activation) - (service-extension mail-aliases-service-type - postfix-aliases) - (service-extension profile-service-type - (compose list postfix-configuration-postfix)) - (service-extension shepherd-root-service-type - postfix-shepherd-service) - (service-extension nginx-service-type - postfix-nginx-locations) - (service-extension certbot-service-type - postfix-certificates) - (service-extension cyrus-sasl-service-type - postfix-sasl-services))) + (append + local-postfix-service-extensions + (list + (service-extension mail-aliases-service-type + postfix-aliases) + (service-extension nginx-service-type + postfix-nginx-locations) + (service-extension certbot-service-type + postfix-certificates) + (service-extension cyrus-sasl-service-type + postfix-sasl-services)))) (default-value (postfix-configuration)) (description " diff --git a/tests/internet-system.scm b/tests/internet-system.scm new file mode 100644 index 0000000..1267911 --- /dev/null +++ b/tests/internet-system.scm @@ -0,0 +1,33 @@ +(use-modules + ((org euandre queue) #:prefix queue:) + (gnu)) +(use-package-modules) +(use-service-modules + certbot + mail) + +(operating-system + (host-name "a-internet-test-host") + (services + (append + (list + (service queue:shadow-group-service-type) + (service queue:dkimproxyout-service-type) + (service queue:cyrus-sasl-service-type) + (service queue:dovecot2-service-type) + (service queue:internet-postfix-service-type) + (service certbot-service-type (certbot-configuration)) + (service mail-aliases-service-type '())) + %base-services)) + (bootloader + (bootloader-configuration + (bootloader grub-bootloader))) + (file-systems + (append + (list + (file-system + (mount-point "/") + (type "btrfs") + (device + (uuid "2c66de32-dde7-ea35-750a-a1ca47a58d45" 'btrfs)))) + %base-file-systems))) diff --git a/tests/local-system.scm b/tests/local-system.scm new file mode 100644 index 0000000..abf09a8 --- /dev/null +++ b/tests/local-system.scm @@ -0,0 +1,25 @@ +(use-modules + ((org euandre queue) #:prefix queue:) + (gnu)) +(use-package-modules) +(use-service-modules) + +(operating-system + (host-name "a-local-test-host") + (services + (append + (list + (service queue:local-postfix-service-type)) + %base-services)) + (bootloader + (bootloader-configuration + (bootloader grub-bootloader))) + (file-systems + (append + (list + (file-system + (mount-point "/") + (type "btrfs") + (device + (uuid "2c66de32-dde7-ea35-750a-a1ca47a58d45" 'btrfs)))) + %base-file-systems))) diff --git a/tests/test-system.scm b/tests/test-system.scm deleted file mode 100644 index d49541c..0000000 --- a/tests/test-system.scm +++ /dev/null @@ -1,36 +0,0 @@ -(use-modules - ((org euandre queue) #:prefix queue:) - (gnu)) -(use-package-modules - ssh) -(use-service-modules - certbot - mail - networking - ssh) - -(operating-system - (host-name "a-test-host") - (services - (append - (list - (service queue:shadow-group-service-type) - (service queue:dkimproxyout-service-type) - (service queue:cyrus-sasl-service-type) - (service queue:dovecot2-service-type) - (service queue:postfix-service-type) - (service certbot-service-type (certbot-configuration)) - (service mail-aliases-service-type '())) - %base-services)) - (bootloader - (bootloader-configuration - (bootloader grub-bootloader))) - (file-systems - (append - (list - (file-system - (mount-point "/") - (type "btrfs") - (device - (uuid "2c66de32-dde7-ea35-750a-a1ca47a58d45" 'btrfs)))) - %base-file-systems))) -- cgit v1.2.3