2022-10-31 11:04:38 +01:00
|
|
|
{ hostAddress, localAddress, containerBackupCfg
|
2022-11-03 16:48:06 +01:00
|
|
|
, sshPort ? containerBackupCfg.portInt, autoStart ? false }: {
|
2021-02-09 11:44:44 +01:00
|
|
|
config = { config, pkgs, lib, ... }: {
|
2022-11-03 16:48:06 +01:00
|
|
|
system.stateVersion = "22.05"; # Did you read the comment?
|
2022-10-30 16:11:21 +01:00
|
|
|
|
2022-10-31 11:04:38 +01:00
|
|
|
imports = [ ../profiles/containers/configuration.nix ];
|
2021-02-09 11:44:44 +01:00
|
|
|
|
|
|
|
networking.firewall.enable = false;
|
|
|
|
|
|
|
|
services.ddclientovh = {
|
2022-10-31 11:04:38 +01:00
|
|
|
enable = true;
|
|
|
|
domain = containerBackupCfg.addr;
|
2021-02-09 11:44:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.openssh.enable = true;
|
|
|
|
|
|
|
|
users.extraUsers."${containerBackupCfg.user}" = {
|
|
|
|
uid = 2000;
|
2021-12-06 21:38:15 +01:00
|
|
|
group = containerBackupCfg.group;
|
2021-02-09 11:44:44 +01:00
|
|
|
shell = pkgs.bashInteractive;
|
|
|
|
home = "/${containerBackupCfg.targetPath}";
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDNI3H0BRSYOZ/MbTs9J80doJwSd1HymFOP5quNt0J48vxZ5FPVrT2FHpQiNrCcYbCKRsU4X8AiGUHiXC0PapQQ3JDkqp6WZoqBNDx6BI7RadyH1TqVQPlou3pQmCAogzfBInruR53YTDmQqXiPwfM0okPOXgiBNjDfZXOX4+CyUfkmZZwASoicTInqWGkn1sFnh4tyXIkgWflg0njlVmfkVvH71+evvKLYHtoNpVXazkQ0SXbyuW5f3mSta7TNkpC3HbBm+4n+WxYGySrlRLWQhTo+aoWUKk9h5zvECDNpwRtbqzt+bA9nKrdg180ceu8hruwvWNiC6PPA2GW9Z1+VKROviGu1C3dliE/pPCBtK+ZoRVv2CGE+pmAuQsB9Nif9tk5tY6HJhuLNxKYiMfQkiLsDYv6KdZXUIVK/4BIDkZuQNnjhdOQBLnea0ANOhutA9gnjxnsd3UT6ovfazg5gud7n3u4yBtzjTkRrqWZ63eM1NmUVOgMWHQ715pV+hJfOFGqzRBEe3g/p3bWNgpROBYJbG1H8l9DN7emG4FGWsb1HeNFwQ5lS0Zsezb7qzahr4vSmHNugVw7w8ONt5dPbPI9wQnWvkkuHH76P/NYy6OC6lHrN1rXyA1okqdPr06YAZnCot+Pqdgn/ijxgp06J3dtkhin+Q7PoQbGff3ERIw== bkp"
|
|
|
|
];
|
|
|
|
|
2022-10-30 16:11:21 +01:00
|
|
|
packages = with pkgs; [ btrfs-progs ];
|
2021-08-21 02:43:11 +02:00
|
|
|
|
|
|
|
isSystemUser = true;
|
2021-02-09 11:44:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
security.sudo = {
|
|
|
|
enable = true;
|
2022-10-31 11:04:38 +01:00
|
|
|
extraRules = [{
|
|
|
|
users = [ "bkp" ];
|
|
|
|
commands = [
|
|
|
|
{
|
|
|
|
command = "/etc/profiles/per-user/bkp/bin/btrfs";
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
command = "/run/current-system/sw/bin/readlink";
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
command = "/run/current-system/sw/bin/test";
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}];
|
2021-02-09 11:44:44 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-03 16:48:06 +01:00
|
|
|
inherit autoStart;
|
2021-02-09 11:44:44 +01:00
|
|
|
|
|
|
|
bindMounts = {
|
|
|
|
"/${containerBackupCfg.targetPath}" = {
|
|
|
|
hostPath = "/var/lib/container-volumes/backup-target";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-03 16:48:06 +01:00
|
|
|
extraFlags = [ "--resolv-conf=bind-host" ];
|
|
|
|
|
2021-02-09 11:44:44 +01:00
|
|
|
privateNetwork = true;
|
2022-10-31 11:04:38 +01:00
|
|
|
forwardPorts = [{
|
|
|
|
# ssh
|
|
|
|
containerPort = 22;
|
|
|
|
hostPort = sshPort;
|
|
|
|
protocol = "tcp";
|
|
|
|
}];
|
2021-02-09 11:44:44 +01:00
|
|
|
|
|
|
|
inherit hostAddress localAddress;
|
|
|
|
}
|