From ecaeaf61e9785ef2cb664f0f26598bfe0ede27f6 Mon Sep 17 00:00:00 2001 From: Joscha Loos Date: Mon, 10 Oct 2022 23:43:30 +0200 Subject: [PATCH] feat: add support for docker-rootless --- nixos-module.nix | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/nixos-module.nix b/nixos-module.nix index 375994a..ba0abce 100644 --- a/nixos-module.nix +++ b/nixos-module.nix @@ -27,8 +27,8 @@ let }; _systemd = mkOption { internal = true; }; }; - config = { - _systemd.services."arion-${name}" = { + config = + let config = { wantedBy = [ "multi-user.target" ]; after = [ "sockets.target" ]; @@ -37,12 +37,17 @@ let cfg.docker.client.package ]; environment.ARION_PREBUILT = config.settings.out.dockerComposeYaml; + # environment.DOCKER_HOST = "unix://$XDG_RUNTIME_DIR/docker.sock"; script = '' echo 1>&2 "docker compose file: $ARION_PREBUILT" arion --prebuilt-file "$ARION_PREBUILT" up ''; }; - }; + in + if cfg.backend == "docker-rootless" then + { _systemd.user.services."arion-${name}" = config; } + else + { _systemd.services."arion-${name}" = config; }; }; arionSettingsType = name: @@ -57,14 +62,14 @@ in options = { virtualisation.arion = { backend = mkOption { - type = types.enum [ "podman-socket" "docker" ]; + type = types.enum [ "podman-socket" "docker" "docker-rootless" ]; description = '' Which container implementation to use. ''; }; package = mkOption { type = types.package; - + default = (import ./. { inherit pkgs; }).arion; description = '' Arion package to use. This will provide arion @@ -105,6 +110,15 @@ in virtualisation.docker.enable = true; virtualisation.arion.docker.client.package = pkgs.docker; }) + (mkIf (cfg.backend == "docker-rootless") { + virtualisation = { + docker.rootless = { + enable = true; + setSocketVariable = true; + }; + }; + virtualisation.arion.docker.client.package = pkgs.docker; + }) ] ); }