mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 03:17:13 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
149 lines
5.4 KiB
Nix
149 lines
5.4 KiB
Nix
import ./make-test-python.nix (
|
|
{ pkgs, ... }:
|
|
let
|
|
inherit (import ./ssh-keys.nix pkgs)
|
|
snakeOilPrivateKey
|
|
snakeOilPublicKey
|
|
;
|
|
|
|
commonConfig =
|
|
{ pkgs, ... }:
|
|
{
|
|
virtualisation.emptyDiskImages = [ 2048 ];
|
|
boot.supportedFilesystems = [ "zfs" ];
|
|
environment.systemPackages = [ pkgs.parted ];
|
|
};
|
|
in
|
|
{
|
|
name = "sanoid";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ lopsided98 ];
|
|
};
|
|
|
|
nodes = {
|
|
source =
|
|
{ ... }:
|
|
{
|
|
imports = [ commonConfig ];
|
|
networking.hostId = "daa82e91";
|
|
|
|
programs.ssh.extraConfig = ''
|
|
UserKnownHostsFile=/dev/null
|
|
StrictHostKeyChecking=no
|
|
'';
|
|
|
|
services.sanoid = {
|
|
enable = true;
|
|
templates.test = {
|
|
hourly = 12;
|
|
daily = 1;
|
|
monthly = 1;
|
|
yearly = 1;
|
|
|
|
autosnap = true;
|
|
};
|
|
datasets."pool/sanoid".use_template = [ "test" ];
|
|
datasets."pool/compat".useTemplate = [ "test" ];
|
|
extraArgs = [ "--verbose" ];
|
|
};
|
|
|
|
services.syncoid = {
|
|
enable = true;
|
|
sshKey = "/var/lib/syncoid/id_ecdsa";
|
|
commands = {
|
|
# Sync snapshot taken by sanoid
|
|
"pool/sanoid" = {
|
|
target = "root@target:pool/sanoid";
|
|
extraArgs = [
|
|
"--no-sync-snap"
|
|
"--create-bookmark"
|
|
];
|
|
};
|
|
# Take snapshot and sync
|
|
"pool/syncoid".target = "root@target:pool/syncoid";
|
|
|
|
# Test pool without parent (regression test for https://github.com/NixOS/nixpkgs/pull/180111)
|
|
"pool".target = "root@target:pool/full-pool";
|
|
|
|
# Test backward compatible options (regression test for https://github.com/NixOS/nixpkgs/issues/181561)
|
|
"pool/compat" = {
|
|
target = "root@target:pool/compat";
|
|
extraArgs = [ "--no-sync-snap" ];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
target =
|
|
{ ... }:
|
|
{
|
|
imports = [ commonConfig ];
|
|
networking.hostId = "dcf39d36";
|
|
|
|
services.openssh.enable = true;
|
|
users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
source.succeed(
|
|
"mkdir /mnt",
|
|
"parted --script /dev/vdb -- mklabel msdos mkpart primary 1024M -1s",
|
|
"udevadm settle",
|
|
"zpool create pool -R /mnt /dev/vdb1",
|
|
"zfs create pool/sanoid",
|
|
"zfs create pool/compat",
|
|
"zfs create pool/syncoid",
|
|
"udevadm settle",
|
|
)
|
|
target.succeed(
|
|
"mkdir /mnt",
|
|
"parted --script /dev/vdb -- mklabel msdos mkpart primary 1024M -1s",
|
|
"udevadm settle",
|
|
"zpool create pool -R /mnt /dev/vdb1",
|
|
"udevadm settle",
|
|
)
|
|
|
|
source.succeed(
|
|
"mkdir -m 700 -p /var/lib/syncoid",
|
|
"cat '${snakeOilPrivateKey}' > /var/lib/syncoid/id_ecdsa",
|
|
"chmod 600 /var/lib/syncoid/id_ecdsa",
|
|
"chown -R syncoid:syncoid /var/lib/syncoid/",
|
|
)
|
|
|
|
assert len(source.succeed("zfs allow pool")) == 0, "Pool shouldn't have delegated permissions set before snapshotting"
|
|
assert len(source.succeed("zfs allow pool/sanoid")) == 0, "Sanoid dataset shouldn't have delegated permissions set before snapshotting"
|
|
assert len(source.succeed("zfs allow pool/syncoid")) == 0, "Syncoid dataset shouldn't have delegated permissions set before snapshotting"
|
|
|
|
# Take snapshot with sanoid
|
|
source.succeed("touch /mnt/pool/sanoid/test.txt")
|
|
source.succeed("touch /mnt/pool/compat/test.txt")
|
|
source.systemctl("start --wait sanoid.service")
|
|
|
|
assert len(source.succeed("zfs allow pool")) == 0, "Pool shouldn't have delegated permissions set after snapshotting"
|
|
assert len(source.succeed("zfs allow pool/sanoid")) == 0, "Sanoid dataset shouldn't have delegated permissions set after snapshotting"
|
|
assert len(source.succeed("zfs allow pool/syncoid")) == 0, "Syncoid dataset shouldn't have delegated permissions set after snapshotting"
|
|
|
|
# Sync snapshots
|
|
target.wait_for_open_port(22)
|
|
source.succeed("touch /mnt/pool/syncoid/test.txt")
|
|
source.systemctl("start --wait syncoid-pool-sanoid.service")
|
|
target.succeed("cat /mnt/pool/sanoid/test.txt")
|
|
source.systemctl("start --wait syncoid-pool-syncoid.service")
|
|
source.systemctl("start --wait syncoid-pool-syncoid.service")
|
|
target.succeed("cat /mnt/pool/syncoid/test.txt")
|
|
|
|
assert(len(source.succeed("zfs list -H -t snapshot pool/syncoid").splitlines()) == 1), "Syncoid should only retain one sync snapshot"
|
|
|
|
source.systemctl("start --wait syncoid-pool.service")
|
|
target.succeed("[[ -d /mnt/pool/full-pool/syncoid ]]")
|
|
|
|
source.systemctl("start --wait syncoid-pool-compat.service")
|
|
target.succeed("cat /mnt/pool/compat/test.txt")
|
|
|
|
assert len(source.succeed("zfs allow pool")) == 0, "Pool shouldn't have delegated permissions set after syncing snapshots"
|
|
assert len(source.succeed("zfs allow pool/sanoid")) == 0, "Sanoid dataset shouldn't have delegated permissions set after syncing snapshots"
|
|
assert len(source.succeed("zfs allow pool/syncoid")) == 0, "Syncoid dataset shouldn't have delegated permissions set after syncing snapshots"
|
|
'';
|
|
}
|
|
)
|