1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00

rclone: correctly escape whitespace in secrets

This commit is contained in:
Jess 2025-03-23 12:32:46 +13:00 committed by Austin Horstman
parent 63e77d09a1
commit 7a08b8c898
4 changed files with 33 additions and 1 deletions

View file

@ -124,7 +124,7 @@ in {
lib.mapAttrsToList (secret: secretFile: ''
${lib.getExe cfg.package} config update \
${remote.name} config_refresh_token=false \
${secret} $(cat ${secretFile}) \
${secret} "$(cat ${secretFile})" \
--quiet > /dev/null
'') remote.value.secrets or { };

View file

@ -84,6 +84,20 @@
./with-secrets-in-store.conf
} /home/alice/.config/rclone/rclone.conf")
with subtest("Secrets with spaces"):
succeed_as_alice("install -m644 ${
./secrets-with-whitespace.nix
} /home/alice/.config/home-manager/test-remote.nix")
actual = succeed_as_alice("home-manager switch")
expected = "Activating createRcloneConfig"
assert expected in actual, \
f"expected home-manager switch to contain {expected}, but got {actual}"
succeed_as_alice("diff -u ${
./secrets-with-whitespace.conf
} /home/alice/.config/rclone/rclone.conf")
# TODO: verify correct activation order with the agenix and sops hm modules
logout_alice()

View file

@ -0,0 +1,5 @@
[alices-cool-remote-v3]
description = alices speeedy remote
type = memory
spaces-secret = This is a secret with spaces, it has single spaces, and lots of spaces :3

View file

@ -0,0 +1,13 @@
{ pkgs, ... }: {
programs.rclone.remotes = {
alices-cool-remote-v3 = {
config = {
type = "memory";
description = "alices speeedy remote";
};
secrets.spaces-secret = "${pkgs.writeText "secret" ''
This is a secret with spaces, it has single spaces, and lots of spaces :3
''}";
};
};
}