@ -3,10 +3,8 @@
;; SPDX-License-Identifier: GPL-3.0-or-later
;; SPDX-License-Identifier: GPL-3.0-or-later
( define-module ( rosenthal services child-error )
( define-module ( rosenthal services child-error )
# :use-module ( ice-9 match )
# :use-module ( guix records )
# :use-module ( guix records )
# :use-module ( guix gexp )
# :use-module ( guix gexp )
# :use-module ( guix packages )
# :use-module ( gnu home services )
# :use-module ( gnu home services )
# :use-module ( gnu home services shepherd )
# :use-module ( gnu home services shepherd )
# :use-module ( gnu packages admin )
# :use-module ( gnu packages admin )
@ -37,16 +35,12 @@
home-socks2http-configuration
home-socks2http-configuration
home-socks2http-service-type ) )
home-socks2http-service-type ) )
;; Child-error: services for packages not available in Guix, currently this
;; means some Go and Rust apps I build locally but don't want to package.
;;
;;
;; Clash
;; Clash
;;
;;
( define-configuration/no-serialization clash-configuration
( define-configuration clash-configuration
( clash
( clash
( file-like clash-bin )
( file-like clash-bin )
"The clash package." )
"The clash package." )
@ -58,7 +52,8 @@
"Where to store data." )
"Where to store data." )
( config
( config
( file-like ( plain-file "empty" "" ) )
( file-like ( plain-file "empty" "" ) )
"Clash configuration file." ) )
"Clash configuration file." )
( no-serialization ) )
( define %clash-accounts
( define %clash-accounts
( list ( user-group ( name "clash" ) ( system? #t ) )
( list ( user-group ( name "clash" ) ( system? #t ) )
@ -70,8 +65,8 @@
( shell ( file-append shadow "/sbin/nologin" ) ) ) ) )
( shell ( file-append shadow "/sbin/nologin" ) ) ) ) )
( define clash-activation
( define clash-activation
( match-lambda
( match-record- lambda <clash-configuration>
( ( $ <clash-configuration> clash log-file data-directory config )
( clash log-file data-directory config )
# ~ ( begin
# ~ ( begin
( use-modules ( guix build utils ) )
( use-modules ( guix build utils ) )
( let ( ( config-dest ( string-append # $data-directory "/config.yaml" ) )
( let ( ( config-dest ( string-append # $data-directory "/config.yaml" ) )
@ -80,11 +75,11 @@
( chown # $data-directory ( passwd:uid user ) ( passwd:gid user ) )
( chown # $data-directory ( passwd:uid user ) ( passwd:gid user ) )
( if ( file-exists? config-dest )
( if ( file-exists? config-dest )
( delete-file config-dest ) )
( delete-file config-dest ) )
( symlink # $config config-dest ) ) ) ) ) )
( symlink # $config config-dest ) ) ) ) )
( define clash-shepherd-service
( define clash-shepherd-service
( match-lambda
( match-record- lambda <clash-configuration>
( ( $ <clash-configuration> clash log-file data-directory config )
( clash log-file data-directory config )
( list ( shepherd-service
( list ( shepherd-service
( documentation "Run clash." )
( documentation "Run clash." )
( provision ' ( clash ) )
( provision ' ( clash ) )
@ -95,7 +90,7 @@
# :user "clash"
# :user "clash"
# :group "clash"
# :group "clash"
# :log-file # $log-file ) )
# :log-file # $log-file ) )
( stop # ~ ( make-kill-destructor ) ) ) ) ) ) )
( stop # ~ ( make-kill-destructor ) ) ) ) ) )
( define clash-service-type
( define clash-service-type
( service-type
( service-type
@ -110,16 +105,15 @@
( default-value ( clash-configuration ) )
( default-value ( clash-configuration ) )
( description "Run Clash." ) ) )
( description "Run Clash." ) ) )
;;
;;
;; Cloudflare Tunnel
;; Cloudflare Tunnel
;;
;;
( define-configuration/no-serialization cloudflare-tunnel-configuration
( define-configuration cloudflare-tunnel-configuration
( cloudflared
( cloudflared
( packag e cloudflared )
( file-lik e cloudflared )
"The cloudflared executable." )
"The cloudflared executable." )
;; Tunnel options
;; Tunnel options
@ -151,15 +145,13 @@ headers. This can expose sensitive information in your logs.")
"Create an experimental post-quantum secure tunnel." )
"Create an experimental post-quantum secure tunnel." )
( extra-options
( extra-options
( list-of-strings ' ( ) )
( list-of-strings ' ( ) )
"List of extra options." ) )
"List of extra options." )
( no-serialization ) )
( define cloudflare-tunnel-shepherd-service
( define cloudflare-tunnel-shepherd-service
( match-lambda
( match-record-lambda <cloudflare-tunnel-configuration>
( ( $ <cloudflare-tunnel-configuration> cloudflared metrics
( cloudflared metrics log-level log-file extra-tunnel-options
log-level log-file
token http2-origin? post-quantum? extra-options )
extra-tunnel-options
token http2-origin? post-quantum?
extra-options )
( list ( shepherd-service
( list ( shepherd-service
( documentation "Run cloudflared." )
( documentation "Run cloudflared." )
( provision ' ( cloudflare-tunnel ) )
( provision ' ( cloudflare-tunnel ) )
@ -185,7 +177,7 @@ headers. This can expose sensitive information in your logs.")
# :log-file # $log-file
# :log-file # $log-file
# :environment-variables
# :environment-variables
( list ( format #f "TUNNEL_TOKEN=~a" # $token ) ) ) )
( list ( format #f "TUNNEL_TOKEN=~a" # $token ) ) ) )
( stop # ~ ( make-kill-destructor ) ) ) ) ) ) )
( stop # ~ ( make-kill-destructor ) ) ) ) ) )
( define cloudflare-tunnel-service-type
( define cloudflare-tunnel-service-type
( service-type
( service-type
@ -202,13 +194,14 @@ headers. This can expose sensitive information in your logs.")
;;
;;
( define-configuration/no-serialization cloudflare-warp-configuration
( define-configuration cloudflare-warp-configuration
( cloudflare-warp
( cloudflare-warp
( file-like cloudflare-warp-bin )
( file-like cloudflare-warp-bin )
"The Cloudflare Warp package." ) )
"The Cloudflare Warp package." )
( no-serialization ) )
( define ( cloudflare-warp-shepherd-service config )
( define cloudflare-warp-shepherd-service
( match-record config <cloudflare-warp-configuration>
( match-record-lambda <cloudflare-warp-configuration>
( cloudflare-warp )
( cloudflare-warp )
( list ( shepherd-service
( list ( shepherd-service
( documentation "Run warp-svc." )
( documentation "Run warp-svc." )
@ -234,16 +227,18 @@ headers. This can expose sensitive information in your logs.")
;; Miniflux
;; Miniflux
;;
;;
( define-configuration/no-serialization miniflux-configuration
( define-configuration miniflux-configuration
( miniflux
( miniflux
( packag e miniflux )
( file-lik e miniflux )
"The miniflux package." )
"The miniflux package." )
( log-file
( log-file
( string "/var/log/miniflux.log" )
( string "/var/log/miniflux.log" )
"Where the logs go." )
"Where the logs go." )
( options
( options
( alist ' ( ) )
( alist ' ( ) )
"Association list of miniflux configuration options." ) )
"Association list of miniflux configuration options." )
( no-serialization ) )
( define %miniflux-accounts
( define %miniflux-accounts
( list ( user-account
( list ( user-account
@ -258,8 +253,8 @@ headers. This can expose sensitive information in your logs.")
( name "miniflux" )
( name "miniflux" )
( create-database? #t ) ) ) )
( create-database? #t ) ) ) )
( define ( miniflux-shepherd-service config )
( define miniflux-shepherd-service
( match-record config <miniflux-configuration>
( match-record-lambda <miniflux-configuration>
( miniflux log-file options )
( miniflux log-file options )
( let ( ( config-file ( mixed-text-file
( let ( ( config-file ( mixed-text-file
"miniflux.conf"
"miniflux.conf"
@ -298,17 +293,18 @@ headers. This can expose sensitive information in your logs.")
;;
;;
( define-configuration/no-serialization home-wakapi-configuration
( define-configuration home-wakapi-configuration
( wakapi
( wakapi
( file-like wakapi-bin )
( file-like wakapi-bin )
"The wakapi package." )
"The wakapi package." )
( config
( config
( yaml-config ' ( ) )
( yaml-config ' ( ) )
"Association list of Wakapi configurations." ) )
"Association list of Wakapi configurations." )
( no-serialization ) )
( define home-wakapi-shepherd-service
( define home-wakapi-shepherd-service
( match-lambda
( match-record- lambda <home-wakapi-configuration>
( ( $ <home-wakapi-configuration> wakapi config )
( wakapi config )
( let ( ( config-file ( mixed-text-file
( let ( ( config-file ( mixed-text-file
"wakapi.yaml"
"wakapi.yaml"
# ~ ( string-append # $@ ( serialize-yaml-config config ) "\n" ) ) ) )
# ~ ( string-append # $@ ( serialize-yaml-config config ) "\n" ) ) ) )
@ -318,7 +314,7 @@ headers. This can expose sensitive information in your logs.")
( start # ~ ( make-forkexec-constructor
( start # ~ ( make-forkexec-constructor
( list # $ ( file-append wakapi "/bin/wakapi" )
( list # $ ( file-append wakapi "/bin/wakapi" )
"-config" # $config-file ) ) )
"-config" # $config-file ) ) )
( stop # ~ ( make-kill-destructor ) ) ) ) ) ) ) )
( stop # ~ ( make-kill-destructor ) ) ) ) ) ) )
( define home-wakapi-service-type
( define home-wakapi-service-type
( service-type
( service-type
@ -347,8 +343,8 @@ headers. This can expose sensitive information in your logs.")
"HTTP proxy address to serve." )
"HTTP proxy address to serve." )
( no-serialization ) )
( no-serialization ) )
( define ( home-socks2http-shepherd-service config )
( define home-socks2http-shepherd-service
( match-record config <home-socks2http-configuration>
( match-record-lambda <home-socks2http-configuration>
( socks2http socks-address http-address )
( socks2http socks-address http-address )
( list ( shepherd-service
( list ( shepherd-service
( documentation "Run socks2http." )
( documentation "Run socks2http." )