### Auto Start Container (Quadlet Nix) Source: https://seiarotg.github.io/quadlet-nix/nixos-options When enabled, this container is automatically started on boot. Maps to the Quadlet option `autoStart`. Type is boolean, default is true. ```nix false ``` -------------------------------- ### Configure Rootless Podman Containers via Home Manager with Quadlet-Nix Source: https://seiarotg.github.io/quadlet-nix/introduction This example shows how to set up rootless Podman containers using Quadlet-Nix integrated with Home Manager on NixOS. It involves adding both the Home Manager and Quadlet NixOS modules to your system configuration. This setup enables managing Podman resources in a rootless environment, leveraging Home Manager for user-specific configurations. ```nix { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; quadlet-nix.url = "github:SEIAROTg/quadlet-nix"; }; outputs = { nixpkgs, quadlet-nix, home-manager, ... }@attrs: { nixosConfigurations.machine = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./configuration.nix home-manager.nixosModules.home-manager # to enable podman & podman systemd generator quadlet-nix.nixosModules.quadlet ]; }; }; } ``` -------------------------------- ### Configure Start With Pod Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `StartWithPod`. If a pod is defined, this option determines if the container starts with the pod. Default is null (container starts independently). ```nix { StartWithPod = true; } ``` -------------------------------- ### Configure Start With Pod in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `StartWithPod`. If a pod is defined, this option determines if the container should start with the pod. It accepts a null or boolean value. ```nix StartWithPod = true; ``` -------------------------------- ### Enable Automatic Build on Boot Source: https://seiarotg.github.io/quadlet-nix/print When enabled, the image build is automatically started on boot. This is a boolean option that defaults to true. ```text When enabled, this build is automatically started on boot. _Type:_ boolean _Default:_ `true` ``` -------------------------------- ### Quadlet Nix: Automatic Build on Boot Source: https://seiarotg.github.io/quadlet-nix/home-manager-options A boolean setting to automatically start image builds on boot. Defaults to true. ```nix buildOnBoot = false; ``` -------------------------------- ### Enable Automatic Pod Start Source: https://seiarotg.github.io/quadlet-nix/print When enabled, this pod is automatically started on boot. This is a boolean option that defaults to true. ```nix { PodAutoStart = true; } ``` -------------------------------- ### Enable Automatic Network Start Source: https://seiarotg.github.io/quadlet-nix/print When enabled, this network is automatically started on boot. This is a boolean option that defaults to true. ```nix { NetworkAutoStart = true; } ``` -------------------------------- ### Configure Container Start with Pod in Quadlet Source: https://seiarotg.github.io/quadlet-nix/nixos-options Determines if a container should start automatically with its pod using the StartWithPod option. This maps to the StartWithPod quadlet option. This is relevant when a container is defined within a pod. It accepts a boolean value or null. ```nix # Example of setting StartWithPod in a Nix expression (conceptual) let quadletConfig = { StartWithPod = true; }; in # ... use quadletConfig in your Nix build ... ``` -------------------------------- ### Configure Container Health Check Start Period Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Sets the initial period during which container health checks are performed. This maps to the `HealthStartPeriod` quadlet option and the `--health-start-period` command-line argument. It accepts null or a string, with a default of null. Example: "1m". ```nix HealthStartPeriod = "1m"; ``` -------------------------------- ### Enable Quoting/Escaping Source: https://seiarotg.github.io/quadlet-nix/print Enables appropriate quoting and escaping for configurations. Defaults to false to avoid breaking existing setups, but will be required in the future. This is a boolean option. ```text Enables appropriate quoting / escaping. Not enabled by default to avoid breaking existing configurations. In the future this will be required. _Type:_ boolean _Default:_ `false` ``` -------------------------------- ### Systemd Service Configuration Example Source: https://seiarotg.github.io/quadlet-nix/index This snippet shows how Quadlet-Nix configures systemd services for containers, including dependencies and service requirements. It highlights the use of `unitConfig.Requires` and `unitConfig.After` to manage service startup order relative to other services like the database. ```nix containers = { database = { # ... }; server = { # ... unitConfig.Requires = [ containers.database.ref "network-online.target" ]; unitConfig.After = [ containers.database.ref "network-online.target" ]; }; }; }; ``` -------------------------------- ### Install Raw Quadlet Files with Dependencies Source: https://seiarotg.github.io/quadlet-nix/index Shows how to use `rawConfig` to define Quadlet containers, networks, and pods directly. This bypasses most Nix options but allows defining dependencies like networks and pods. ```nix { config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) networks pods; in { containers = { nginx.rawConfig = '' [Container] Image=docker.io/library/nginx:latest Network=podman Network=${networks.internal.ref} Pod=${pods.foo.ref} [Service] TimeoutStartSec=60 ''; }; networks = { internal.networkConfig.subnets = [ "10.0.123.1/24" ]; }; pods = { foo = { }; }; }; } ``` -------------------------------- ### Configure Container Health Check Startup Command Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Defines the command to execute for container health checks. This maps to the `HealthStartupCmd` quadlet option and the `--health-startup-cmd` command-line argument. It accepts null or a string, with a default of null. Example: "/usr/bin/command". ```nix HealthStartupCmd = "/usr/bin/command"; ``` -------------------------------- ### Configure Ulimits Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `Ulimit` and the command line argument `--ulimit`. It sets resource limits for the container. Example: [ "nofile=1000:10000" ] ```nix { Ulimit = [ "nofile=1000:10000" ]; } ``` -------------------------------- ### Install Raw Quadlet Files with Custom Networks and Pods Source: https://seiarotg.github.io/quadlet-nix/introduction Demonstrates using `rawConfig` to define Quadlet container configurations directly from Quadlet files. This method allows for advanced customization, including specifying networks and pods, overriding other Nix options. ```nix { config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) networks pods; in { containers = { nginx.rawConfig = '' [Container] Image=docker.io/library/nginx:latest Network=podman Network=${networks.internal.ref} Pod=${pods.foo.ref} [Service] TimeoutStartSec=60 '' ; }; networks = { internal.networkConfig.subnets = [ "10.0.123.1/24" ]; }; pods = { foo = { }; }; }; } ``` -------------------------------- ### Container Name Configuration Source: https://seiarotg.github.io/quadlet-nix/print Maps to the quadlet option `ContainerName` and the command-line argument `--name`. Accepts a null or string value, with a default of `null`. Example: `"name"`. ```Nix ``` -------------------------------- ### Configure Ulimits in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `Ulimit` and the command-line argument `--ulimit`. This option sets resource limits for the container. It accepts a list of strings. Example: `[ "nofile=1000:10000" ]`. ```nix Ulimit = [ "nofile=4096" "nproc=8192" ]; ``` -------------------------------- ### Set File Option and Argument Source: https://seiarotg.github.io/quadlet-nix/print Maps to the quadlet option `File` and the command-line argument `--file`. This option accepts a null or string value and defaults to null. An example path is `"/path/to/Containerfile"`. ```text Maps to quadlet option `File`and command line argument `--file`. _Type:_ null or string _Default:_ `null` _Example:_ `"/path/to/Containerfile"` ``` -------------------------------- ### Configure Root Filesystem Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `Rootfs` and the command line argument `--rootfs`. It specifies an alternative root filesystem for the container. Example: "/var/lib/rootfs". ```nix { Rootfs = "/var/lib/rootfs"; } ``` -------------------------------- ### Configure Retry Attempts Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `Retry` and the command line argument `--retry`. It specifies the number of times to retry starting the container on failure. Example: 5. ```nix { Retry = 5; } ``` -------------------------------- ### Enable Init Process Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `RunInit` and the command line argument `--init`. It enables the use of an init process (like tini) to manage container processes. ```nix { RunInit = true; } ``` -------------------------------- ### Provide Raw Quadlet Configuration Text Source: https://seiarotg.github.io/quadlet-nix/home-manager-options The `Raw` option allows providing the entire quadlet configuration as a raw string. Using this option will cause all other options contributing to quadlet files to be ignored, except for `autoStart`. It accepts a null or string value. ```nix Raw = "[Container]\nImage=docker.io/library/nginx:latest\nPort=8080:80\n"; ``` -------------------------------- ### Configure Container Health Check Startup Success Count Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Defines the number of successful health checks required for a container to be considered started. This maps to the `HealthStartupSuccess` quadlet option and the `--health-startup-success` command-line argument. It accepts a null or signed integer, with a default of null. Example: 2. ```nix HealthStartupSuccess = 2; ``` -------------------------------- ### Build Container Image from Git Repository (Nix) Source: https://seiarotg.github.io/quadlet-nix/print Configures building a container image from a Git repository. It fetches the repository, sets the build file path to a specific work directory within the repository, and defines the image tag. The example shows building an Alpine Linux image. It also notes the alternative of using a Git URL directly for `workdir`. ```nix { config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) builds; src = builtins.fetchGit { url = "https://github.com/alpinelinux/docker-alpine.git"; rev = "4dc13cbc7caffe03c98aa99f28e27c2fb6f7e74d"; }; in { containers.example.containerConfig = { image = builds.alpine.ref; entrypoint = "/bin/sh"; exec = "-c 'echo 123'"; }; containers.example.serviceConfig.RemainAfterExit = true; builds.alpine.buildConfig = { tag = "alpine:3.22"; workdir = "${src}/x86_64"; }; }; } ``` -------------------------------- ### Configure Working Directory in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `WorkingDir` and the command-line argument `--workdir`. This option sets the working directory for the container's entrypoint. It accepts a null or string value. Example: `"$HOME"`. ```nix WorkingDir = "/app"; ``` -------------------------------- ### Configure Container Log Options Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Sets logging options for the container's log driver. This maps to the `LogOpt` quadlet option and the `--log-opt` command-line argument. It accepts a list of strings, with a default of an empty list. Example: [ "path=/var/log/mykube.json" ]. ```nix LogOpt = [ "path=/var/log/mykube.json" ]; ``` -------------------------------- ### Raw Quadlet Configuration (Quadlet Nix) Source: https://seiarotg.github.io/quadlet-nix/nixos-options Allows providing raw quadlet configuration text. If used, all other Quadlet options contributing to quadlet files are ignored, except for `autoStart`. Type is null or string. ```nix '' [Unit] Description=My raw service [Service] ExecStart=/usr/bin/my-app '' ``` -------------------------------- ### Configure Volume Mounts in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `Volume` and the command-line argument `--volume`. This option mounts host directories or volumes into the container. It accepts a list of strings. Example: `[ "/source:/dest" ]`. ```nix Volume = [ "/data:/app/data:rw" ]; ``` -------------------------------- ### Integrate with pkgs.dockerTools using Quadlet Source: https://seiarotg.github.io/quadlet-nix/index Demonstrates how to use `pkgs.dockerTools` to build a container image and then reference it in a Quadlet container configuration. This allows using Nix to build container images. ```nix { pkgs, ... }: let image = pkgs.dockerTools.buildImage { # ... }; in { virtualisation.quadlet.containers = { foo.containerConfig.image = "docker-archive:${image}"; }; } See: https://docs.podman.io/en/v5.5.0/markdown/podman-run.1.html#image ``` -------------------------------- ### Set AuthFile Option and Argument Source: https://seiarotg.github.io/quadlet-nix/print Maps to the quadlet option `AuthFile` and the command-line argument `--authfile`. This option accepts a null or string value and defaults to null. An example path is `"/etc/registry/auth.json"`. ```text Maps to quadlet option `AuthFile`and command line argument `--authfile`. _Type:_ null or string _Default:_ `null` _Example:_ `"/etc/registry/auth.json"` ``` -------------------------------- ### Add Additional Podman Arguments Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Inserts additional command-line arguments after `podman run`. This maps to the `PodmanArgs` quadlet option. It accepts a list of strings, with a default of an empty list. Example: [ "--add-host foobar" ]. ```nix PodmanArgs = [ "--add-host foobar" ]; ``` -------------------------------- ### Configure Raw Quadlet Configuration in Quadlet Source: https://seiarotg.github.io/quadlet-nix/nixos-options Allows providing raw Quadlet configuration text using the Raw option. Using this option overrides all other options that contribute to Quadlet files. The autoStart option is not affected. It accepts a string containing the raw configuration or null. ```nix # Example of setting Raw configuration in a Nix expression (conceptual) let rawConfig = "[Service]\nExecStart=/usr/bin/my-app\n"; quadletConfig = { Raw = rawConfig; }; in # ... use quadletConfig in your Nix build ... ``` -------------------------------- ### Set Arch Option and Argument Source: https://seiarotg.github.io/quadlet-nix/print Maps to the quadlet option `Arch` and the command-line argument `--arch`. This option accepts a null or string value and defaults to null. An example value is `"aarch64"`. ```text Maps to quadlet option `Arch`and command line argument `--arch`. _Type:_ null or string _Default:_ `null` _Example:_ `"aarch64"` ``` -------------------------------- ### Configure Container Health Check Startup Timeout Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Sets the timeout for container health checks during startup. This maps to the `HealthStartupTimeout` quadlet option and the `--health-startup-timeout` command-line argument. It accepts null or a string, with a default of null. Example: "1m33s". ```nix HealthStartupTimeout = "1m33s"; ``` -------------------------------- ### Enable RunInit in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `RunInit` and the command-line argument `--init`. This option enables the use of an init process within the container. It accepts a null or boolean value. ```nix RunInit = true; ``` -------------------------------- ### Set Device Option and Argument Source: https://seiarotg.github.io/quadlet-nix/print Maps to the quadlet option `Device` and the command-line argument `--opt device=...`. This option accepts a null or string value and defaults to null. An example value is "tmpfs". ```text Maps to quadlet option `Device`and command line argument `--opt device=...`. _Type:_ null or string _Default:_ `null` _Example:_ `"tmpfs"` ``` -------------------------------- ### Define Container Mounts Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Specifies volume mounts for the container. This maps to the `Mount` quadlet option and the `--mount` command-line argument. It accepts a list of strings, with a default of an empty list. Example: [ "type=..." ]. ```nix Mount = [ "type=..." ]; ``` -------------------------------- ### Configure Container Health Check Startup Interval Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Sets the interval between container health check executions during startup. This maps to the `HealthStartupInterval` quadlet option and the `--health-startup-interval` command-line argument. It accepts null or a string, with a default of null. Example: "1m". ```nix HealthStartupInterval = "1m"; ``` -------------------------------- ### Integrate pkgs.dockerTools with Quadlet (Nix) Source: https://seiarotg.github.io/quadlet-nix/print Demonstrates how to use `pkgs.dockerTools.buildImage` to create a container image and then reference it within Quadlet configuration. This allows leveraging Nix's build capabilities for creating container images that can be used by Podman via Quadlet. The image is referenced using the `docker-archive` transport. ```nix { pkgs, ... }: let image = pkgs.dockerTools.buildImage { # ... }; in { virtualisation.quadlet.containers = { foo.containerConfig.image = "docker-archive:${image}"; }; } ``` -------------------------------- ### Configure Reload Signal Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `ReloadSignal`. It specifies a signal to send for reloading the service, used with `ExecReload`. Example: "SIGHUP". ```nix { ReloadSignal = "SIGHUP"; } ``` -------------------------------- ### Set Image Option and Argument Source: https://seiarotg.github.io/quadlet-nix/print Maps to the quadlet option `Image` and the command-line argument `--opt image=...`. This option accepts a null or string value and defaults to null. An example value is `"quay.io/centos/centos:latest"`. ```text Maps to quadlet option `Image`and command line argument `--opt image=...`. _Type:_ null or string _Default:_ `null` _Example:_ `"quay.io/centos/centos:latest"` ``` -------------------------------- ### Provide Raw Quadlet Configuration Source: https://seiarotg.github.io/quadlet-nix/print Allows providing raw Quadlet configuration text. When used, all other options contributing to Quadlet files are ignored. `autoStart` is not affected. Accepts a string value or null. ```text Raw= "your raw config here" ``` -------------------------------- ### Configure Reload Command Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `ReloadCmd`. It specifies a command to execute for reloading the service, used with `ExecReload`. Example: "/usr/bin/command". ```nix { ReloadCmd = "/usr/bin/command"; } ``` -------------------------------- ### Set User Option and Argument Source: https://seiarotg.github.io/quadlet-nix/print Maps to the quadlet option `User` and the command-line argument `--opt uid=...`. This option accepts a null, signed integer, or string value and defaults to null. An example value is `123`. ```text Maps to quadlet option `User`and command line argument `--opt uid=...`. _Type:_ null or signed integer or string _Default:_ `null` _Example:_ `123` ``` -------------------------------- ### Specify Container Image Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Specifies the container image to use. This maps to the `Image` quadlet option. It accepts null or a string, with a default of null. Example: "docker.io/library/nginx:latest". ```nix Image = "docker.io/library/nginx:latest"; ``` -------------------------------- ### Provide Raw Quadlet Configuration (Nix) Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Allows providing raw quadlet configuration text. Using this option will ignore all other options that contribute to quadlet files. `autoStart` is not affected. This option expects a string. ```nix raw_config = "[Service]\nExecStart=/usr/bin/my-app"; ``` -------------------------------- ### Configure Quadlet Volumes with Bind Mounts Source: https://seiarotg.github.io/quadlet-nix/introduction Demonstrates how to configure volumes for Quadlet containers using bind mounts. This allows host directories to be mounted into containers, facilitating data persistence and configuration sharing. ```nix { config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) volumes; in { containers.nginx.containerConfig.image = "docker.io/library/nginx:latest"; containers.nginx.containerConfig.volumes = [ "${volumes.nginx-config.ref}:/etc/nginx" ]; volumes.nginx-config.volumeConfig = { type = "bind"; device = "/path/to/host/directory"; }; }; } ``` -------------------------------- ### Nix Expression for Systemd Service Dependencies Source: https://seiarotg.github.io/quadlet-nix/introduction This Nix expression defines systemd service dependencies for a container, ensuring it starts after the database and network are online. It utilizes references to other container services. ```nix containers = { database = { # ... }; server = { # ... unitConfig.Requires = [ containers.database.ref "network-online.target" ]; unitConfig.After = [ containers.database.ref "network-online.target" ]; }; }; } ``` -------------------------------- ### Enable Quadlet and Configure User for Rootless Containers (Nix) Source: https://seiarotg.github.io/quadlet-nix/print Enables Quadlet for Podman and configures a user for rootless container management. This includes setting up user linger for auto-start before login and enabling auto subuid/subgid ranges for multi-user environments. The example defines a simple echo-server container. ```nix { # ... # to enable podman & podman systemd generator virtualisation.quadlet.enable = true; users.users.alice = { # ... # required for auto start before user login linger = true; # required for rootless container with multiple users autoSubUidGidRange = true; }; home-manager.users.alice = { pkgs, config, ... }: { # ... imports = [ inputs.quadlet-nix.homeManagerModules.quadlet ]; virtualisation.quadlet.containers = { echo-server = { autoStart = true; serviceConfig = { RestartSec = "10"; Restart = "always"; }; containerConfig = { image = "docker.io/mendhak/http-https-echo:31"; publishPorts = [ "127.0.0.1:8080:8080" ]; userns = "keep-id"; }; }; }; }; } ``` -------------------------------- ### Integrate Quadlet with pkgs.dockerTools Source: https://seiarotg.github.io/quadlet-nix/introduction Shows how to use `pkgs.dockerTools.buildImage` to create a container image and then use that image with Quadlet. This allows leveraging Nix's build capabilities for creating container images. ```nix { pkgs, ... }: let image = pkgs.dockerTools.buildImage { # ... }; in { virtualisation.quadlet.containers = { foo.containerConfig.image = "docker-archive:${image}"; }; } See: https://docs.podman.io/en/v5.5.0/markdown/podman-run.1.html#image ``` -------------------------------- ### Configure Timezone Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `Timezone` and the command line argument `--tz`. It sets the timezone inside the container. Example: "local". ```nix { Timezone = "local"; } ``` -------------------------------- ### Set Reload Signal in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `ReloadSignal`. This option specifies the signal to be sent during a reload operation. It accepts a null or string value. Example: `"SIGHUP"`. ```nix ReloadSignal = "SIGTERM"; ``` -------------------------------- ### Set Raw Quadlet Configuration Source: https://seiarotg.github.io/quadlet-nix/print Provides the raw quadlet configuration text. Using this option ignores all other configuration options for quadlet files, except for `autoStart`. The type is null or string. ```nix { RawQuadletConfig = "some_raw_config_text"; } ``` -------------------------------- ### Configure Podman Build Volume Mounts Source: https://seiarotg.github.io/quadlet-nix/nixos-options This option maps to the quadlet option `Volume` and the command line argument `--volume`. It specifies volume mounts for the container build process. Accepts a list of strings, each in the format "/source:/dest[:options]". ```Nix { # Maps to quadlet option `Volume` and command line argument `--volume`. quadletVolume = [ "/source:/dest" ]; } ``` -------------------------------- ### Specify Container Image Source: https://seiarotg.github.io/quadlet-nix/print Defines the container image to be used. Maps to the Quadlet option `Image` and the command-line argument `Image`. Accepts a string value or null, for example: `docker.io/library/nginx:latest`. ```text Image="docker.io/library/nginx:latest" ``` -------------------------------- ### Configure Secrets Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `Secret` and the command line argument `--secret`. It mounts secrets into the container. Example: [ "secret[,opt=opt …]" ] ```nix { Secret = [ "secret[,opt=opt …]" ]; } ``` -------------------------------- ### Build Quadlet Container Image from Git Repository Source: https://seiarotg.github.io/quadlet-nix/introduction Illustrates building a container image for Quadlet using a git repository as the source. The `pkgs.fetchGit` function is used to clone the repository, and the build configuration specifies the working directory and tag for the image. ```nix { config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) builds; src = builtins.fetchGit { url = "https://github.com/alpinelinux/docker-alpine.git"; rev = "4dc13cbc7caffe03c98aa99f28e27c2fb6f7e74d"; }; in { containers.example.containerConfig = { image = builds.alpine.ref; entrypoint = "/bin/sh"; exec = "-c 'echo 123'"; }; containers.example.serviceConfig.RemainAfterExit = true; builds.alpine.buildConfig = { tag = "alpine:3.22"; workdir = "${src}/x86_64"; }; }; } Alternatively, git integration of Podman can be used through `workdir = "https://github.com/nginx/docker-nginx.git"`. However, it will be users' responsibility to make binaries such as `git` available to the build service via `PATH`. ``` -------------------------------- ### Configure Retry Delay Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `RetryDelay` and the command line argument `--retry-delay`. It specifies the delay between retry attempts. Example: "5s". ```nix { RetryDelay = "5s"; } ``` -------------------------------- ### Publish Network Ports Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `PublishPort` and the command line argument `--publish`. It specifies which ports to publish and their mappings. Example: [ "50-59" ] ```nix { PublishPort = [ "50-59" ]; } ``` -------------------------------- ### Configure Image Builds Source: https://seiarotg.github.io/quadlet-nix/print Defines settings for image builds. This option expects an attribute set of submodules and defaults to an empty attribute set `{ }`. ```text Image builds _Type:_ attribute set of (submodule) _Default:_ `{ }` ``` -------------------------------- ### Configure Podman Build File Path Source: https://seiarotg.github.io/quadlet-nix/nixos-options This option maps to the quadlet option `File` and the command line argument `--file`. It specifies the path to a Containerfile or Dockerfile to be used for building the image. Accepts a string representing the file path. ```Nix { # Maps to quadlet option `File` and command line argument `--file`. quadletFile = "/path/to/Containerfile"; } ``` -------------------------------- ### Configure Timezone in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `Timezone` and the command-line argument `--tz`. This option sets the timezone for the container. It accepts a null or string value. Example: `"local"`. ```nix Timezone = "Europe/Berlin"; ``` -------------------------------- ### Configure Podman Network Extra Arguments Source: https://seiarotg.github.io/quadlet-nix/nixos-options Provides additional command-line arguments to be inserted after `podman network create`. This maps to the `PodmanArgs` Quadlet option. It expects a list of strings, defaulting to an empty list. ```nix [ "--dns=192.168.55.1" ] ``` -------------------------------- ### Configure Stop Timeout in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `StopTimeout` and the command-line argument `--stop-timeout`. This option sets the timeout for stopping the container. It accepts a null or signed integer. Example: `20`. ```nix StopTimeout = 30; ``` -------------------------------- ### Set Reload Command in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `ReloadCmd`. This option defines an `ExecReload` command to be run when the service is reloaded. It can be a null, a string, or a list of strings. Example: `"/usr/bin/command"`. ```nix ReloadCmd = "/usr/bin/systemctl restart my-service"; ``` -------------------------------- ### Configure Systemd Unit Dependencies for Quadlet Source: https://seiarotg.github.io/quadlet-nix/introduction Illustrates how to set up extra dependencies for Quadlet services using systemd unit configurations. It notes that the `.ref` syntax is specific to Quadlet and not valid in regular systemd units. ```nix { config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) containers; in { ``` -------------------------------- ### Set Container Name Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Assigns a name to the container. This maps to the `ContainerName` quadlet option and the `--name` command-line argument. It accepts null or a string, with a default of null. Example: "name". ```nix ContainerName = "name"; ``` -------------------------------- ### Configure Container Hostname Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Sets the hostname for the container. This maps to the `HostName` quadlet option and the `--hostname` command-line argument. It accepts null or a string, with a default of null. Example: "new-host-name". ```nix HostName = "new-host-name"; ``` -------------------------------- ### Configure Raw Quadlet Text Source: https://seiarotg.github.io/quadlet-nix/print Allows providing raw quadlet configuration text directly. If used, all other options contributing to quadlet files are ignored, except for `autoStart`. This maps to the quadlet option `RawText`. ```nix "my-custom-quadlet-config" ``` -------------------------------- ### Configure Architecture Variant Source: https://seiarotg.github.io/quadlet-nix/print Maps to the Quadlet option `Variant` and the command-line argument `--variant`. This option specifies the architecture variant for the image. It accepts a string value or null, for example `arm/v7`. ```text Variant="arm/v7" ``` -------------------------------- ### Configure Stop Timeout Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `StopTimeout` and the command line argument `--stop-timeout`. It specifies the duration to wait for the container to stop before forcefully killing it. Example: 20. ```nix { StopTimeout = 20; } ``` -------------------------------- ### Add Global Command Line Arguments with Nix Source: https://seiarotg.github.io/quadlet-nix/nixos-options Provide additional command-line arguments to be inserted between `podman` and `volume create` using the `GlobalArgs` option. This option takes a list of strings. The default value is an empty list. ```nix globalArgs = [ "--log-level=debug" ]; ``` -------------------------------- ### Build Container Image from Containerfile using Quadlet Source: https://seiarotg.github.io/quadlet-nix/index Shows how to build a container image from an inlined `Containerfile` using Quadlet. The image is then used for an Nginx container. ```nix { pkgs, config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) builds; containerfile = pkgs.writeText "Containerfile" '' FROM docker.io/library/nginx:latest # ... ''; in { containers.nginx.containerConfig.image = builds.nginx.ref; builds.nginx.buildConfig.file = containerfile.outPath; }; } ``` -------------------------------- ### Configure UID Map in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `UIDMap` and the command-line argument `--uidmap`. This option maps UIDs from the host to the container. It accepts a list of strings. Example: `[ "0:10000:10" ]`. ```nix UIDMap = [ "0:100000:65536" ]; ``` -------------------------------- ### Configure Container Security Opt (Quadlet Nix) Source: https://seiarotg.github.io/quadlet-nix/nixos-options Sets security options for the container, mapping to the Quadlet option `SecurityOpt` and the Podman command-line argument `--security-opt`. Expects a list of strings. ```nix [ "label=type:container_runtime_t" ] ``` -------------------------------- ### Add Podman Command Line Arguments with Nix Source: https://seiarotg.github.io/quadlet-nix/nixos-options Provide additional command-line arguments to be appended after `podman pod create` using the `PodmanArgs` option. This option takes a list of strings. The default value is an empty list. ```nix podmanArgs = [ "--cpus=2" ]; ``` -------------------------------- ### Configure Sysctl Settings in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `Sysctl`. This option allows setting kernel parameters within the container. It accepts an attribute set of strings. Example: `{ name = "value"; }`. ```nix Sysctl = { "net.ipv4.ip_forward" = "1"; }; ``` -------------------------------- ### Set Options Argument Source: https://seiarotg.github.io/quadlet-nix/print Maps to the quadlet option `Options` and the command-line argument `--opt o=...`. This option accepts a null or string value and defaults to null. ```text Maps to quadlet option `Options`and command line argument `--opt o=...`. _Type:_ null or string _Default:_ `null` ``` -------------------------------- ### Configure Retry Delay in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `RetryDelay` and the command-line argument `--retry-delay`. This option specifies the delay between retries. It accepts a null or string value. Example: `"5s"`. ```nix RetryDelay = "10s"; ``` -------------------------------- ### Configure Podman Build Architecture Source: https://seiarotg.github.io/quadlet-nix/nixos-options This option maps to the quadlet option `Arch` and the command line argument `--arch`. It specifies the target architecture for the image build. Accepts a string representing the architecture (e.g., "aarch64"). ```Nix { # Maps to quadlet option `Arch` and command line argument `--arch`. quadletArch = "aarch64"; } ``` -------------------------------- ### Configure Retry Behavior in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `Retry` and the command-line argument `--retry`. This option sets the number of times an operation should be retried. It accepts a null or signed integer. Example: `5`. ```nix Retry = 3; ``` -------------------------------- ### Configure Podman Build DNS Options Source: https://seiarotg.github.io/quadlet-nix/nixos-options This option maps to the quadlet option `DNSOption` and the command line argument `--dns-option`. It allows specifying DNS options for the container. Accepts a list of strings, where each string is a DNS option. ```Nix { # Maps to quadlet option `DNSOption` and command line argument `--dns-option`. quadletDNSOption = [ "ndots:1" ]; } ``` -------------------------------- ### Configure Network Additional Podman Arguments Source: https://seiarotg.github.io/quadlet-nix/print Appends command-line arguments after 'podman network create', mapping to the Quadlet option `PodmanArgs`. This option accepts a list of strings. ```nix { PodmanArgs = [ "--dns=192.168.55.1" ]; } ``` -------------------------------- ### Configure Image Pull Behavior Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `Pull` and the command line argument `--pull`. It controls when to pull container images. Example: pull = "never". ```nix { Pull = "never"; } ``` -------------------------------- ### Configure Container Mounts (Quadlet Nix) Source: https://seiarotg.github.io/quadlet-nix/nixos-options Defines volume mounts for the container, mapping to the Quadlet option `Mount` and the Podman command-line argument `--mount`. Expects an attribute set of strings. ```nix { source = "/host/path"; target = "/container/path"; type = "bind"; } ``` -------------------------------- ### Configure User in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `User` and the command-line argument `--user`. This option sets the user under which the container process will run. It accepts a null or string value. Example: `"bin"`. ```nix User = "nobody"; ``` -------------------------------- ### Build Quadlet Container Image from Containerfile Source: https://seiarotg.github.io/quadlet-nix/introduction Shows how to build a container image for Quadlet directly from a Containerfile. The `pkgs.writeText` function is used to define the Containerfile content, which is then referenced in the build configuration. ```nix { pkgs, config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) builds; containerfile = pkgs.writeText "Containerfile" '' FROM docker.io/library/nginx:latest # ... ''; in { containers.nginx.containerConfig.image = builds.nginx.ref; builds.nginx.buildConfig.file = containerfile.outPath; }; } ``` -------------------------------- ### Configure Shm Size in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `ShmSize` and the command-line argument `--shm-size`. This option sets the size of the shared memory. It accepts a null or string value. Example: `"100m"`. ```nix ShmSize = "256m"; ``` -------------------------------- ### Specify Root Filesystem in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `Rootfs` and the command-line argument `--rootfs`. This option sets the path to the root filesystem. It accepts a null or string value. Example: `"/var/lib/rootfs"`. ```nix Rootfs = "/srv/container/rootfs"; ``` -------------------------------- ### Publish Container Ports Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Publishes container ports to the host. This maps to the `PublishPort` quadlet option and the `--publish` command-line argument. It accepts a list of strings, with a default of an empty list. Example: [ "50-59" ]. ```nix PublishPort = [ "50-59" ]; ``` -------------------------------- ### Configure Podman Build Authentication File Source: https://seiarotg.github.io/quadlet-nix/nixos-options This option maps to the quadlet option `AuthFile` and the command line argument `--authfile`. It specifies the path to a file containing authentication credentials for a container registry. Accepts a string representing the file path. ```Nix { # Maps to quadlet option `AuthFile` and command line argument `--authfile`. quadletAuthFile = "/etc/registry/auth.json"; } ``` -------------------------------- ### Configure Run Init in Quadlet Source: https://seiarotg.github.io/quadlet-nix/nixos-options Enables or disables running an init process within the container using the RunInit option. This maps to the RunInit quadlet option and the --init command-line argument. It accepts a boolean value or null. ```nix # Example of setting RunInit in a Nix expression (conceptual) let quadletConfig = { RunInit = true; }; in # ... use quadletConfig in your Nix build ... ``` -------------------------------- ### Set Container Memory Limit Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Specifies the memory limit for the container. This maps to the `Memory` quadlet option and the `--memory` command-line argument. It accepts null or a string, with a default of null. Example: "20g". ```nix Memory = "20g"; ``` -------------------------------- ### Configure Container Log Driver Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Specifies the logging driver for the container. This maps to the `LogDriver` quadlet option and the `--log-driver` command-line argument. It accepts null or a string, with a default of null. Example: "journald". ```nix LogDriver = "journald"; ``` -------------------------------- ### Specify Raw Quadlet Configuration Source: https://seiarotg.github.io/quadlet-nix/print Allows providing the entire Quadlet configuration as a raw string, bypassing other options. This is useful for complex or custom configurations. The `autoStart` option is not affected by this setting. ```nix { RawConfig = "--dns=1.1.1.1 --log-level=info"; } ``` -------------------------------- ### Configure Container IP Address Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Sets the IPv4 address for the container. This maps to the `IP` quadlet option and the `--ip` command-line argument. It accepts null or a string, with a default of null. Example: "192.5.0.1". ```nix IP = "192.5.0.1"; ``` -------------------------------- ### Configure Extra Dependencies for Systemd Units with Quadlet Source: https://seiarotg.github.io/quadlet-nix/index Explains how to set up extra dependencies for systemd units managed by Quadlet. Note that the `.ref` syntax is specific to Quadlet and does not work in regular systemd units. ```nix { config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) containers; in { ``` -------------------------------- ### Configure Volume Mounts Source: https://seiarotg.github.io/quadlet-nix/print Maps to the Quadlet option `Volume` and the command-line argument `--volume`. This option allows specifying volume mounts for containers. It expects a list of strings, where each string defines a source and destination path. ```text Volume=[ "/source:/dest" ] ``` -------------------------------- ### Set Container Entrypoint (Quadlet Nix) Source: https://seiarotg.github.io/quadlet-nix/nixos-options Defines the entrypoint for the container, mapping to the Quadlet option `Entrypoint` and the Podman command-line argument `--entrypoint`. Can be a null, a string, or a list of strings. ```nix "/foo.sh" ``` -------------------------------- ### Configure Network Additional Global Arguments Source: https://seiarotg.github.io/quadlet-nix/print Adds command-line arguments to be inserted between 'podman' and 'network create', mapping to the Quadlet option `GlobalArgs`. This option takes a list of strings. ```nix { GlobalArgs = [ "--log-level=debug" ]; } ``` -------------------------------- ### Set VolumeName Option and Argument Source: https://seiarotg.github.io/quadlet-nix/print Specifies the volume name for `podman volume create`. Maps to the quadlet option `VolumeName` and accepts a null or string value, defaulting to null. An example is `"foo"`. ```text Volume name as in `podman volume create foo` Maps to quadlet option `VolumeName`. _Type:_ null or string _Default:_ `null` _Example:_ `"foo"` ``` -------------------------------- ### Set Driver Option and Argument Source: https://seiarotg.github.io/quadlet-nix/print Maps to the quadlet option `Driver` and the command-line argument `--driver`. This option accepts a null or string value and defaults to null. An example value is "image". ```text Maps to quadlet option `Driver`and command line argument `--driver`. _Type:_ null or string _Default:_ `null` _Example:_ `"image"` ``` -------------------------------- ### Configure Global Podman Arguments Source: https://seiarotg.github.io/quadlet-nix/print Provides additional command-line arguments to be inserted before `podman pod create`. This maps to the quadlet option `GlobalArgs`. ```nix [ "--log-level=debug" ] ``` -------------------------------- ### Configure Sysctl Parameters Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `Sysctl` and the command line argument `--sysctl`. It allows setting kernel parameters within the container. Example: { name = "value"; } ```nix { Sysctl = { name = "value"; }; } ``` -------------------------------- ### Provide Raw Quadlet Configuration with Nix Source: https://seiarotg.github.io/quadlet-nix/nixos-options Insert raw Quadlet configuration text using the `Raw` option. Using this will ignore all other options that contribute to Quadlet files. The default value is null. ```nix raw = "some raw quadlet config"; ``` -------------------------------- ### Configure Shared Memory Size Source: https://seiarotg.github.io/quadlet-nix/print This option maps to the quadlet option `ShmSize` and the command line argument `--shm-size`. It sets the size of the /dev/shm (shared memory) filesystem. Example: "100m". ```nix { ShmSize = "100m"; } ``` -------------------------------- ### Build Container Image from Git Repository using Quadlet Source: https://seiarotg.github.io/quadlet-nix/index Illustrates building a container image from a Git repository using Quadlet. It specifies a Git repository URL and revision for an Alpine Linux base image. ```nix { config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) builds; src = builtins.fetchGit { url = "https://github.com/alpinelinux/docker-alpine.git"; rev = "4dc13cbc7caffe03c98aa99f28e27c2fb6f7e74d"; }; in { containers.example.containerConfig = { image = builds.alpine.ref; entrypoint = "/bin/sh"; exec = "-c 'echo 123'"; }; containers.example.serviceConfig.RemainAfterExit = true; builds.alpine.buildConfig = { tag = "alpine:3.22"; workdir = "${src}/x86_64"; }; }; } Alternatively, git integration of Podman can be used through `workdir = "https://github.com/nginx/docker-nginx.git"`. However, it will be users' responsibility to make binaries such as `git` available to the build service via `PATH`. ``` -------------------------------- ### Configure Container Volumes with Quadlet Source: https://seiarotg.github.io/quadlet-nix/index Demonstrates how to configure a container with a volume mount using Quadlet. It defines a bind mount for Nginx configuration files. ```nix { config, ... }: { # ... virtualisation.quadlet = let inherit (config.virtualisation.quadlet) volumes; in { containers.nginx.containerConfig.image = "docker.io/library/nginx:latest"; containers.nginx.containerConfig.volumes = [ "${volumes.nginx-config.ref}:/etc/nginx" ]; volumes.nginx-config.volumeConfig = { type = "bind"; device = "/path/to/host/directory"; }; }; } ``` -------------------------------- ### Configure Podman Build Target Stage Source: https://seiarotg.github.io/quadlet-nix/nixos-options This option maps to the quadlet option `Target` and the command line argument `--target`. It specifies the target build stage within a multi-stage Dockerfile. Accepts a string representing the target stage name. ```Nix { # Maps to quadlet option `Target` and command line argument `--target`. quadletTarget = "my-app"; } ``` -------------------------------- ### Configure Tmpfs Mounts in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `Tmpfs` and the command-line argument `--tmpfs`. This option mounts temporary file systems within the container. It accepts a list of strings. Example: `[ "/work" ]`. ```nix Tmpfs = [ "/run" "/tmp" ]; ``` -------------------------------- ### Configure SubUID Map Name in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `SubUIDMap` and the command-line argument `--subuidname`. This option specifies the name for the sub-UID map. It accepts a null or string value. Example: `"utest"`. ```nix SubUIDMap = "container_uids"; ``` -------------------------------- ### Add Global Volume Arguments (Nix) Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Specifies additional command-line arguments to insert between `podman` and `volume create`. Maps to the quadlet option `GlobalArgs`. ```nix global_args = [ "--log-level=debug" ]; ``` -------------------------------- ### Configure SubGID Map Name in Quadlet Source: https://seiarotg.github.io/quadlet-nix/home-manager-options Maps to the quadlet option `SubGIDMap` and the command-line argument `--subgidname`. This option specifies the name for the sub-GID map. It accepts a null or string value. Example: `"gtest"`. ```nix SubGIDMap = "container_gids"; ``` -------------------------------- ### Configure Podman Build Image Tag Source: https://seiarotg.github.io/quadlet-nix/nixos-options This option maps to the quadlet option `ImageTag` and the command line argument `--tag`. It specifies the tag for the built image. Accepts a string representing the image tag (e.g., "localhost/imagename"). ```Nix { # Maps to quadlet option `ImageTag` and command line argument `--tag`. quadletImageTag = "localhost/imagename"; } ```