sftpman: add module

This commit is contained in:
Fugi 2023-11-06 20:05:51 +01:00 committed by Robert Helgesson
parent c24c298562
commit 6e2afa5c3b
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
10 changed files with 231 additions and 0 deletions

View file

@ -0,0 +1,21 @@
{
config = {
programs.sftpman = {
enable = true;
mounts = {
mount1 = {
host = "host1.example.com";
mountPoint = "/path/to/somewhere";
user = "root";
};
};
};
test.stubs.sftpman = { };
test.asserts.assertions.expected = [''
sftpman mounts using authentication type "publickey" but missing 'sshKey': mount1
''];
};
}

View file

@ -0,0 +1,4 @@
{
sftpman-example-settings = ./example-settings.nix;
sftpman-assert-on-no-sshkey = ./assert-on-no-sshkey.nix;
}

View file

@ -0,0 +1,44 @@
{
config = {
programs.sftpman = {
enable = true;
defaultSshKey = "/home/user/.ssh/id_ed25519";
mounts = {
mount1 = {
host = "host1.example.com";
mountPoint = "/path/to/somewhere";
user = "root";
mountOptions = [ "idmap=user" ];
};
mount2 = {
host = "host2.example.com";
mountPoint = "/another/path";
user = "someuser";
authType = "password";
sshKey = null;
};
mount3 = {
host = "host3.example.com";
mountPoint = "/yet/another/path";
user = "user";
sshKey = "/home/user/.ssh/id_rsa";
};
};
};
test.stubs.sftpman = { };
nmt.script = ''
assertFileContent \
home-files/.config/sftpman/mounts/mount1.json \
${./expected-mount1.json}
assertFileContent \
home-files/.config/sftpman/mounts/mount2.json \
${./expected-mount2.json}
assertFileContent \
home-files/.config/sftpman/mounts/mount3.json \
${./expected-mount3.json}
'';
};
}

View file

@ -0,0 +1,13 @@
{
"authType": "publickey",
"beforeMount": "true",
"host": "host1.example.com",
"id": "mount1",
"mountOptions": [
"idmap=user"
],
"mountPoint": "/path/to/somewhere",
"port": 22,
"sshKey": "/home/user/.ssh/id_ed25519",
"user": "root"
}

View file

@ -0,0 +1,11 @@
{
"authType": "password",
"beforeMount": "true",
"host": "host2.example.com",
"id": "mount2",
"mountOptions": [],
"mountPoint": "/another/path",
"port": 22,
"sshKey": null,
"user": "someuser"
}

View file

@ -0,0 +1,11 @@
{
"authType": "publickey",
"beforeMount": "true",
"host": "host3.example.com",
"id": "mount3",
"mountOptions": [],
"mountPoint": "/yet/another/path",
"port": 22,
"sshKey": "/home/user/.ssh/id_rsa",
"user": "user"
}