← Retour au blog
tech 14 September 2026

Building a Guix Service from Scratch: A Beginner's Guide

Learn how to create a custom Guix service, even as a beginner. Follow our step-by-step guide to set up a Caddy reverse proxy on Guix.

Article inspired by the original source
Writing a Guix service from scratch, as a beginner ↗ aloysberger.com

Introduction

If you're looking to customize your Guix experience, creating your own service is an essential step. Whether you're a tech entrepreneur or a curious developer, understanding how to build a Guix service gives you total control over your infrastructure.

Why Create a Guix Service?

Guix is a software distribution that allows fine-grained package and service management. However, not all software is available by default. For example, Caddy, a popular reverse proxy server, requires manual configuration. Creating a custom service allows you to tailor Guix exactly to your needs.

Prerequisites

Before starting, ensure you have Guix installed and configured. While you don't need to be a Scheme expert, a basic understanding is recommended. Also, make sure the Caddy package is available on your Guix instance.

Step 1: Prepare the Configuration File

The first step is to create a configuration file for your service. This file will define how the service should operate and what parameters it should use. For Caddy, this may include domain and security configurations.

``scheme (service (name 'caddy) (extensions (list (service-extension shepherd-root-service-type (compose list caddy-shepherd-service))))) ``

Step 2: Create a System User

For security reasons, it is advised to create a dedicated system user to run the Caddy service. This limits permissions and reduces potential risks.

``scheme (system-user (name "caddy") (home-directory "/var/lib/caddy") (shell "/bin/false") (system? #t)) ``

Step 3: Configure Shepherd

Shepherd is the default service manager for Guix. To get Caddy running as a service, you'll need to configure Shepherd to properly start and stop the service.

``scheme (define caddy-shepherd-service (shepherd-service (provision '(caddy)) (start #~(make-forkexec-constructor (list #$(file-append caddy "/bin/caddy") "run"))) (stop #~(make-kill-destructor)) (respawn? #t))) ``

Step 4: Test and Deploy

Once everything is set up, test your service. Use guix system reconfigure to apply the changes. Check that Caddy starts correctly and your sites are functional.

Conclusion

Creating a Guix service is not just a technical exercise, it's a gateway to fully customizing your software environment. Whether you're developing for fun or work, mastering this aspect of Guix can transform your infrastructure approach.

Let's discuss your project in 15 minutes.

Guix custom service Caddy Shepherd Scheme
Deepthix newsletter · 100% AI · every Monday 8am

An AI agent reads tech for you.

Our AI agent scans ~200 sources per week and ships the best articles to your inbox Monday 8am. Free. One click to unsubscribe.

Visit the newsletter page →

Want to automate your operations?

Let's talk about your project in 15 minutes.

Book a call