rclone: respect mounts enable option
This commit is contained in:
parent
83eeebd967
commit
9e07a347f4
2 changed files with 36 additions and 14 deletions
|
|
@ -356,8 +356,8 @@ in
|
|||
mount-path = name;
|
||||
mount = value;
|
||||
in
|
||||
[
|
||||
(lib.nameValuePair "rclone-mount:${replaceSlashes mount-path}@${remote-name}" {
|
||||
lib.optional mount.enable (
|
||||
lib.nameValuePair "rclone-mount:${replaceSlashes mount-path}@${remote-name}" {
|
||||
Unit = {
|
||||
Description = "Rclone FUSE daemon for ${remote-name}:${mount-path}";
|
||||
};
|
||||
|
|
@ -382,8 +382,8 @@ in
|
|||
};
|
||||
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
})
|
||||
]
|
||||
}
|
||||
)
|
||||
) (lib.attrsToList remote.mounts)
|
||||
)
|
||||
(
|
||||
|
|
|
|||
|
|
@ -26,6 +26,21 @@ let
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
alices-disabled-remote = {
|
||||
config = {
|
||||
type = "sftp";
|
||||
host = "remote";
|
||||
user = "alice";
|
||||
key_pem = "${keyPem}";
|
||||
known_hosts = "${sshKeys.snakeOilEd25519PublicKey}";
|
||||
};
|
||||
mounts = {
|
||||
"/home/alice/other-files" = {
|
||||
mountPoint = "/home/alice/other-files";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
'';
|
||||
|
|
@ -43,6 +58,23 @@ in
|
|||
remote.wait_for_unit("network.target")
|
||||
remote.wait_for_unit("multi-user.target")
|
||||
|
||||
succeed_as_alice(
|
||||
"mkdir -p /home/alice/.ssh",
|
||||
"install -m644 ${module} /home/alice/.config/home-manager/test-remote.nix"
|
||||
)
|
||||
|
||||
actual = succeed_as_alice("home-manager switch")
|
||||
expected = "rclone-config.service"
|
||||
assert "Starting units: " in actual and expected in actual, \
|
||||
f"expected home-manager switch to contain {expected}, but got {actual}"
|
||||
|
||||
with subtest("Disabled remotes aren't created"):
|
||||
svc_name = "rclone-mount:.home.alice.other-files@alices-disabled-remote.service"
|
||||
|
||||
status, out = machine.systemctl(f"status {svc_name}", "alice")
|
||||
assert status != 0, \
|
||||
f"The disabled mount {svc_name} was created"
|
||||
|
||||
with subtest("Mount a remote (sftp)"):
|
||||
# https://rclone.org/commands/rclone_mount/#vfs-directory-cache
|
||||
# Sending a SIGHUP evicts every dcache entry
|
||||
|
|
@ -55,16 +87,6 @@ in
|
|||
box=remote
|
||||
)
|
||||
|
||||
succeed_as_alice(
|
||||
"mkdir -p /home/alice/.ssh",
|
||||
"install -m644 ${module} /home/alice/.config/home-manager/test-remote.nix"
|
||||
)
|
||||
|
||||
actual = succeed_as_alice("home-manager switch")
|
||||
expected = "rclone-config.service"
|
||||
assert "Starting units: " in actual and expected in actual, \
|
||||
f"expected home-manager switch to contain {expected}, but got {actual}"
|
||||
|
||||
# remote -> machine
|
||||
succeed_as_alice(
|
||||
"mkdir /home/alice/files",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue