feat(zfs): add declarative management for ZFS datasets and integration tests
treefmt / nix fmt (pull_request) Successful in 5s
pytest / pytest (pull_request) Successful in 31s
test ebook search / test-ebook-search (pull_request) Successful in 36s
build_systems / build-brain (pull_request) Successful in 49s
build_systems / build-bob (pull_request) Successful in 49s
build_systems / build-rhapsody-in-green (pull_request) Successful in 1m2s
zfs integration / zfs-integration (pull_request) Successful in 1m9s
build_systems / build-jeeves (pull_request) Successful in 2m18s
treefmt / nix fmt (pull_request) Successful in 5s
pytest / pytest (pull_request) Successful in 31s
test ebook search / test-ebook-search (pull_request) Successful in 36s
build_systems / build-brain (pull_request) Successful in 49s
build_systems / build-bob (pull_request) Successful in 49s
build_systems / build-rhapsody-in-green (pull_request) Successful in 1m2s
zfs integration / zfs-integration (pull_request) Successful in 1m9s
build_systems / build-jeeves (pull_request) Successful in 2m18s
This commit is contained in:
1 parent
0398e5e878
commit
ef4ebc6cdf
6 files changed
+255
-2
No files matched your search
@@ -0,0 +1,135 @@
|
||||
{ self }:
|
||||
{
|
||||
name = "zfs-integration";
|
||||
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
testPython = pkgs.python314.withPackages (pythonPackages: [
|
||||
pythonPackages.apprise
|
||||
pythonPackages.typer
|
||||
]);
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
../common/global/snapshot_manager.nix
|
||||
../common/optional/zfs_manager.nix
|
||||
];
|
||||
|
||||
boot.supportedFilesystems = [ "zfs" ];
|
||||
networking.hostId = "deadbeef";
|
||||
|
||||
virtualisation = {
|
||||
emptyDiskImages = [ 2048 ];
|
||||
memorySize = 2048;
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
testPython
|
||||
pkgs.zfs
|
||||
];
|
||||
|
||||
services = {
|
||||
snapshot_manager = {
|
||||
enable = true;
|
||||
package = testPython;
|
||||
PYTHONPATH = "${self}/";
|
||||
};
|
||||
|
||||
zfs_manager = {
|
||||
enable = true;
|
||||
package = testPython;
|
||||
PYTHONPATH = "${self}/";
|
||||
defaultSnapshots = {
|
||||
"15_min" = 2;
|
||||
hourly = 2;
|
||||
daily = 2;
|
||||
monthly = 2;
|
||||
};
|
||||
datasets = {
|
||||
testpool = {
|
||||
properties = {
|
||||
atime = "off";
|
||||
compression = "lz4";
|
||||
mountpoint = "/testpool";
|
||||
};
|
||||
};
|
||||
|
||||
"testpool/parent" = {
|
||||
properties = {
|
||||
compression = "zstd";
|
||||
mountpoint = "/testpool/parent";
|
||||
};
|
||||
};
|
||||
|
||||
"testpool/parent/child" = {
|
||||
properties = {
|
||||
recordsize = "16K";
|
||||
sync = "disabled";
|
||||
};
|
||||
snapshots = {
|
||||
"15_min" = 1;
|
||||
hourly = 1;
|
||||
daily = 1;
|
||||
monthly = 1;
|
||||
};
|
||||
};
|
||||
|
||||
"testpool/secure" = {
|
||||
createIfMissing = false;
|
||||
properties = {
|
||||
encryption = "aes-256-gcm";
|
||||
keyformat = "hex";
|
||||
keylocation = "file:///root/zfs.key";
|
||||
};
|
||||
snapshots = {
|
||||
"15_min" = 0;
|
||||
hourly = 0;
|
||||
daily = 0;
|
||||
monthly = 0;
|
||||
};
|
||||
};
|
||||
|
||||
"testpool/secure/child" = {
|
||||
properties.compression = "zstd-9";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services = {
|
||||
prepare-zfs-integration = {
|
||||
description = "Prepare the ZFS integration-test pool";
|
||||
requiredBy = [ "zfs_manager.service" ];
|
||||
before = [ "zfs_manager.service" ];
|
||||
path = [ pkgs.zfs ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
printf '%064d\n' 0 > /root/zfs.key
|
||||
chmod 0400 /root/zfs.key
|
||||
zpool create -f -m /testpool testpool /dev/vdb
|
||||
zfs create \
|
||||
-o encryption=aes-256-gcm \
|
||||
-o keyformat=hex \
|
||||
-o keylocation=file:///root/zfs.key \
|
||||
testpool/secure
|
||||
'';
|
||||
};
|
||||
|
||||
zfs_manager = {
|
||||
requires = [ "prepare-zfs-integration.service" ];
|
||||
after = [ "prepare-zfs-integration.service" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript =
|
||||
{ nodes, ... }:
|
||||
builtins.replaceStrings
|
||||
[ "@snapshot_config@" ]
|
||||
[ (toString nodes.machine.services.snapshot_manager.path) ]
|
||||
(builtins.readFile ./zfs_integration.py);
|
||||
}
|
||||
Reference in new issue
Block a user