Use latest zfs compatible kernel
This commit is contained in:
parent
ae05bdb2dd
commit
253720c398
|
@ -8,6 +8,8 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
|
||||||
|
|
||||||
# just all the microvms from this flake
|
# just all the microvms from this flake
|
||||||
# that are supposed to run on the server
|
# that are supposed to run on the server
|
||||||
microvm.autostart =
|
microvm.autostart =
|
||||||
|
@ -18,44 +20,47 @@
|
||||||
(config.c3d2.deployment.server or null) == config.networking.hostName
|
(config.c3d2.deployment.server or null) == config.networking.hostName
|
||||||
) (builtins.attrNames self.nixosConfigurations);
|
) (builtins.attrNames self.nixosConfigurations);
|
||||||
|
|
||||||
systemd.services."microvm-virtiofsd@" = {
|
systemd.services = {
|
||||||
requires = [ "microvm-zfs-datasets@%i.service" ];
|
"microvm-virtiofsd@" = {
|
||||||
};
|
requires = [ "microvm-zfs-datasets@%i.service" ];
|
||||||
systemd.services."microvm-zfs-datasets@" = {
|
|
||||||
description = "Create ZFS datasets for MicroVM '%i'";
|
|
||||||
before = [ "microvm-virtiofsd@%i.service" ];
|
|
||||||
after = [ "local-fs.target" ];
|
|
||||||
partOf = [ "microvm@%i.service" ];
|
|
||||||
unitConfig.ConditionPathExists = "/var/lib/microvms/%i/current/share/microvm/virtiofs";
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
WorkingDirectory = "/var/lib/microvms/%i";
|
|
||||||
SyslogIdentifier = "microvm-zfs-datasets@%i";
|
|
||||||
};
|
};
|
||||||
path = with pkgs; [ zfs ];
|
|
||||||
scriptArgs = "%i";
|
|
||||||
script = ''
|
|
||||||
zfsExists() {
|
|
||||||
zfs list $1 >/dev/null 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
NAME="$1"
|
"microvm-zfs-datasets@" = {
|
||||||
BASE="${config.c3d2.deployment.microvmBaseZfsDataset}"
|
description = "Create ZFS datasets for MicroVM '%i'";
|
||||||
zfsExists $BASE || \
|
before = [ "microvm-virtiofsd@%i.service" ];
|
||||||
zfs create $BASE
|
after = [ "local-fs.target" ];
|
||||||
zfsExists $BASE/$NAME || \
|
partOf = [ "microvm@%i.service" ];
|
||||||
zfs create $BASE/$NAME
|
unitConfig.ConditionPathExists = "/var/lib/microvms/%i/current/share/microvm/virtiofs";
|
||||||
for d in current/share/microvm/virtiofs/*; do
|
serviceConfig = {
|
||||||
SOURCE=$(cat $d/source)
|
Type = "oneshot";
|
||||||
TAG=$(basename $d)
|
RemainAfterExit = true;
|
||||||
MNT=$SOURCE
|
WorkingDirectory = "/var/lib/microvms/%i";
|
||||||
if [[ "$MNT" == /var/lib/microvms/$NAME/* ]]; then
|
SyslogIdentifier = "microvm-zfs-datasets@%i";
|
||||||
zfsExists $BASE/$NAME/$TAG || \
|
};
|
||||||
zfs create -o mountpoint=$MNT $BASE/$NAME/$TAG
|
path = with pkgs; [ zfs ];
|
||||||
fi
|
scriptArgs = "%i";
|
||||||
done
|
script = ''
|
||||||
'';
|
zfsExists() {
|
||||||
|
zfs list $1 >/dev/null 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
NAME="$1"
|
||||||
|
BASE="${config.c3d2.deployment.microvmBaseZfsDataset}"
|
||||||
|
zfsExists $BASE || \
|
||||||
|
zfs create $BASE
|
||||||
|
zfsExists $BASE/$NAME || \
|
||||||
|
zfs create $BASE/$NAME
|
||||||
|
for d in current/share/microvm/virtiofs/*; do
|
||||||
|
SOURCE=$(cat $d/source)
|
||||||
|
TAG=$(basename $d)
|
||||||
|
MNT=$SOURCE
|
||||||
|
if [[ "$MNT" == /var/lib/microvms/$NAME/* ]]; then
|
||||||
|
zfsExists $BASE/$NAME/$TAG || \
|
||||||
|
zfs create -o mountpoint=$MNT $BASE/$NAME/$TAG
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nix.settings = {
|
nix.settings = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user