mirror of
https://github.com/hercules-ci/arion.git
synced 2024-09-11 18:47:27 +03:00
feat: add support for docker-rootless
This commit is contained in:
parent
3131319c81
commit
46dbaee067
@ -1,9 +1,11 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
any
|
||||
attrValues
|
||||
mkIf
|
||||
mkOption
|
||||
mkEnableOption
|
||||
mkMerge
|
||||
types
|
||||
;
|
||||
@ -25,26 +27,31 @@ let
|
||||
type = arionSettingsType name;
|
||||
visible = "shallow";
|
||||
};
|
||||
rootless = mkEnableOption "Run this project in rootless mode";
|
||||
_systemd = mkOption { internal = true; };
|
||||
};
|
||||
config =
|
||||
let service = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "sockets.target" ];
|
||||
let
|
||||
|
||||
service = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "sockets.target" ];
|
||||
|
||||
path = [
|
||||
cfg.package
|
||||
cfg.docker.client.package
|
||||
];
|
||||
environment.ARION_PREBUILT = config.settings.out.dockerComposeYaml;
|
||||
environment.DOCKER_HOST = mkIf config.rootless "unix:///run/user/1000/docker.sock"; # TODO: Do not hardcode path
|
||||
script = ''
|
||||
echo 1>&2 "docker compose file: $ARION_PREBUILT"
|
||||
arion --prebuilt-file "$ARION_PREBUILT" up
|
||||
'';
|
||||
};
|
||||
|
||||
path = [
|
||||
cfg.package
|
||||
cfg.docker.client.package
|
||||
];
|
||||
environment.ARION_PREBUILT = config.settings.out.dockerComposeYaml;
|
||||
environment.DOCKER_HOST = mkIf (cfg.backend == "docker-rootless") "unix:///run/user/1000/docker.sock";
|
||||
script = ''
|
||||
echo 1>&2 "docker compose file: $ARION_PREBUILT"
|
||||
arion --prebuilt-file "$ARION_PREBUILT" up
|
||||
'';
|
||||
};
|
||||
in
|
||||
if cfg.backend == "docker-rootless" then
|
||||
if false then
|
||||
# if false then
|
||||
{ _systemd.user.services."arion-${name}" = service; }
|
||||
else
|
||||
{ _systemd.services."arion-${name}" = service; };
|
||||
@ -110,14 +117,8 @@ 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;
|
||||
(mkIf (any (project: project.rootless) (attrValues cfg.projects)) {
|
||||
virtualisation.docker.rootless.enable = true;
|
||||
})
|
||||
]
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user