Skip to content

Commit d884eb2

Browse files
committed
fix(docker-clone): couldn't follow symlinks so copied secrets to /var/lib/docker-plugins/rclone dir instead
1 parent ca7c817 commit d884eb2

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

modules/docker.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ with lib;
7070
Type = "oneshot";
7171
RemainAfterExit = false;
7272
ExecStart =
73-
pkgs.writeShellScript "install-docker-plugins" # bash
73+
pkgs.writeShellScript "install-docker-plugins" # sh
7474
''
7575
#!/usr/bin/env sh
7676

modules/rclone.nix

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ with lib;
2828
"docker-rclone/rclone.conf" = {
2929
format = "binary";
3030
sopsFile = ../hosts/shared/secrets/rclone.conf;
31-
path = "/var/lib/docker-plugins/rclone/config/rclone.conf";
3231
};
3332
};
3433

@@ -38,5 +37,29 @@ with lib;
3837
"d /var/lib/docker-plugins/rclone/config 0755 root root -"
3938
"d /var/lib/docker-plugins/rclone/cache 0755 root root -"
4039
];
40+
41+
# NOTE: sops symlinks to /run/secrets and Docker doesn't follow symlinks so we need to copy the file instead
42+
systemd.services = mkIf (config.host.docker.enable && dockerHasRclonePlugin) {
43+
copy-docker-rclone-config = {
44+
description = "Copy rclone.conf to docker-plugins directory";
45+
documentation = [ "man:rclone(1)" ];
46+
wants = [ "network-online.target" ];
47+
wantedBy = [ "multi-user.target" ];
48+
serviceConfig = {
49+
Type = "oneshot";
50+
RemainAfterExit = false;
51+
ExecStart =
52+
pkgs.writeShellScript "copy-docker-rclone-config" # sh
53+
''
54+
#!/usr/bin/env sh
55+
56+
filepath="${config.sops.secrets."docker-rclone/rclone.conf".path}"
57+
58+
cp "$filepath" /var/lib/docker-plugins/rclone/config/rclone.conf
59+
chmod 600 /var/lib/docker-plugins/rclone/config/rclone.conf
60+
'';
61+
};
62+
};
63+
};
4164
};
4265
}

0 commit comments

Comments
 (0)