mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13:28 +01:00
Compare commits
34
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4a2a6f8bb | ||
|
|
bf0abfde48 | ||
|
|
c53bfaa13a | ||
|
|
1ae7c794d9 | ||
|
|
f720e64ec3 | ||
|
|
f275b06323 | ||
|
|
33827d2bd1 | ||
|
|
79a12e659b | ||
|
|
ade21e2c96 | ||
|
|
cb6297aceb | ||
|
|
fe89f379e7 | ||
|
|
b1a94497b1 | ||
|
|
b64dddf61b | ||
|
|
4d5d07d37f | ||
|
|
11e3073dff | ||
|
|
b9ca21dc6c | ||
|
|
b8aecf159f | ||
|
|
49f8aa791f | ||
|
|
5be012e917 | ||
|
|
76816af65d | ||
|
|
c315045f42 | ||
|
|
84a5b93637 | ||
|
|
7d9940a4df | ||
|
|
3a4de9fa3a | ||
|
|
7ea6edd857 | ||
|
|
2ee76c861a | ||
|
|
d8f3cfc582 | ||
|
|
60375cf096 | ||
|
|
600d2e1d2f | ||
|
|
194a9965d1 | ||
|
|
a08bfe06b3 | ||
|
|
dcd15a37f7 | ||
|
|
d3e3aa7a14 | ||
|
|
d32f2d1750 |
No files matched your search
@@ -76,6 +76,7 @@ A simple disko configuration may look like this:
|
|||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
root = {
|
root = {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ let
|
|||||||
diskoScript =
|
diskoScript =
|
||||||
if hasDiskoConfigFlake then
|
if hasDiskoConfigFlake then
|
||||||
diskoEval
|
diskoEval
|
||||||
else if (lib.traceValSeq hasDiskoModuleFlake) then
|
else if hasDiskoModuleFlake then
|
||||||
(builtins.getFlake flake).nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr} or (
|
(builtins.getFlake flake).nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr} or (
|
||||||
pkgs.writeShellScriptBin "disko-compat-error" ''
|
pkgs.writeShellScriptBin "disko-compat-error" ''
|
||||||
echo 'Error: Attribute `nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr}` >&2
|
echo 'Error: Attribute `nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr}` >&2
|
||||||
|
|||||||
@@ -110,6 +110,15 @@ parseArgs() {
|
|||||||
extraSystemConfig="$2"
|
extraSystemConfig="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--disko-system-config)
|
||||||
|
if [[ $# -lt 2 ]]; then
|
||||||
|
echo "Option $1 requires one JSON argument." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
extraDiskoSystemConfig="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--extra-files)
|
--extra-files)
|
||||||
if [[ $# -lt 3 ]]; then
|
if [[ $# -lt 3 ]]; then
|
||||||
echo "Option $1 requires two arguments: source, destination" >&2
|
echo "Option $1 requires two arguments: source, destination" >&2
|
||||||
|
|||||||
+1
-1
@@ -204,7 +204,7 @@ of the NixOS manual. The following configuration for `grub` works for both EFI
|
|||||||
and BIOS systems. Add this to your configuration.nix, commenting out the
|
and BIOS systems. Add this to your configuration.nix, commenting out the
|
||||||
existing lines that configure `systemd-boot`. The entries will look like this:
|
existing lines that configure `systemd-boot`. The entries will look like this:
|
||||||
|
|
||||||
**Note:** Its not necessary to set `boot.loader.grub.device` here, since Disko
|
**Note:** It's not necessary to set `boot.loader.grub.device` here, since Disko
|
||||||
will take care of that automatically.
|
will take care of that automatically.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ for example like this:
|
|||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,6 +67,7 @@
|
|||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
raid1 = {
|
raid1 = {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
"name with spaces" = {
|
"name with spaces" = {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
empty = {
|
empty = {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
raid1 = {
|
raid1 = {
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
main = {
|
||||||
|
device = "/dev/disk/by-id/some-disk-id";
|
||||||
|
type = "disk";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
ESP = {
|
||||||
|
type = "EF00";
|
||||||
|
size = "500M";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
root = {
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "xfs";
|
||||||
|
mountpoint = "/";
|
||||||
|
mountOptions = [ "defaults" "pquota" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -244,11 +244,14 @@
|
|||||||
type = "topology";
|
type = "topology";
|
||||||
vdev = [
|
vdev = [
|
||||||
{
|
{
|
||||||
mode = "mirror";
|
# This syntax expects a disk called 'data3' with a gpt partition called 'zfs'.
|
||||||
members = [ "data1" "data2" ];
|
members = [ "data1" ];
|
||||||
|
# It's also possible to use the full path of the device or partition
|
||||||
|
# members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
members = [ "data3" ];
|
mode = "mirror";
|
||||||
|
members = [ "data2" "data3" ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
spare = [ "spare" ];
|
spare = [ "spare" ];
|
||||||
|
|||||||
+19
-1
@@ -72,7 +72,7 @@
|
|||||||
options.mountpoint = "legacy";
|
options.mountpoint = "legacy";
|
||||||
mountpoint = "/zfs_legacy_fs";
|
mountpoint = "/zfs_legacy_fs";
|
||||||
};
|
};
|
||||||
zfs_testvolume = {
|
zfs_volume = {
|
||||||
type = "zfs_volume";
|
type = "zfs_volume";
|
||||||
size = "10M";
|
size = "10M";
|
||||||
content = {
|
content = {
|
||||||
@@ -81,6 +81,24 @@
|
|||||||
mountpoint = "/ext4onzfs";
|
mountpoint = "/ext4onzfs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
zfs_volume_no_content = {
|
||||||
|
type = "zfs_volume";
|
||||||
|
size = "10M";
|
||||||
|
};
|
||||||
|
zfs_encryptedvolume = {
|
||||||
|
type = "zfs_volume";
|
||||||
|
size = "10M";
|
||||||
|
options = {
|
||||||
|
encryption = "aes-256-gcm";
|
||||||
|
keyformat = "passphrase";
|
||||||
|
keylocation = "file:///tmp/secret.key";
|
||||||
|
};
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
|
mountpoint = "/ext4onzfsencrypted";
|
||||||
|
};
|
||||||
|
};
|
||||||
encrypted = {
|
encrypted = {
|
||||||
type = "zfs_fs";
|
type = "zfs_fs";
|
||||||
options = {
|
options = {
|
||||||
|
|||||||
Generated
+3
-3
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1733749988,
|
"lastModified": 1736241350,
|
||||||
"narHash": "sha256-+5qdtgXceqhK5ZR1YbP1fAUsweBIrhL38726oIEAtDs=",
|
"narHash": "sha256-CHd7yhaDigUuJyDeX0SADbTM9FXfiWaeNyY34FL1wQU=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "bc27f0fde01ce4e1bfec1ab122d72b7380278e68",
|
"rev": "8c9fd3e564728e90829ee7dbac6edc972971cd0f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
nixosModules.default = self.nixosModules.disko; # convention
|
nixosModules.default = self.nixosModules.disko; # convention
|
||||||
nixosModules.disko.imports = [ ./module.nix ];
|
nixosModules.disko = ./module.nix;
|
||||||
lib = diskoLib;
|
lib = diskoLib;
|
||||||
packages = forAllSystems (system:
|
packages = forAllSystems (system:
|
||||||
let
|
let
|
||||||
|
|||||||
+5
-1
@@ -2,6 +2,7 @@
|
|||||||
, flakeAttr
|
, flakeAttr
|
||||||
, diskMappings
|
, diskMappings
|
||||||
, extraSystemConfig ? "{}"
|
, extraSystemConfig ? "{}"
|
||||||
|
, extraDiskoSystemConfig ? "{}"
|
||||||
, writeEfiBootEntries ? false
|
, writeEfiBootEntries ? false
|
||||||
, rootMountPoint ? "/mnt"
|
, rootMountPoint ? "/mnt"
|
||||||
,
|
,
|
||||||
@@ -41,6 +42,9 @@ let
|
|||||||
{
|
{
|
||||||
disko.rootMountPoint = rootMountPoint;
|
disko.rootMountPoint = rootMountPoint;
|
||||||
disko.devices.disk = lib.mkVMOverride cleanedDisks;
|
disko.devices.disk = lib.mkVMOverride cleanedDisks;
|
||||||
|
imports = [
|
||||||
|
({ _file = "disko-install --system-config"; } // (builtins.fromJSON extraDiskoSystemConfig))
|
||||||
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@@ -51,7 +55,7 @@ let
|
|||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
{
|
{
|
||||||
boot.loader.efi.canTouchEfiVariables = lib.mkVMOverride writeEfiBootEntries;
|
boot.loader.efi.canTouchEfiVariables = lib.mkVMOverride writeEfiBootEntries;
|
||||||
boot.loader.grub.devices = lib.mkVMOverride diskoSystem.config.boot.loader.grub.devices;
|
boot.loader.grub.devices = lib.mkVMOverride (lib.attrValues diskMappings);
|
||||||
imports = [
|
imports = [
|
||||||
({ _file = "disko-install --system-config"; } // (builtins.fromJSON extraSystemConfig))
|
({ _file = "disko-install --system-config"; } // (builtins.fromJSON extraSystemConfig))
|
||||||
];
|
];
|
||||||
|
|||||||
+12
-4
@@ -13,8 +13,16 @@ let
|
|||||||
|
|
||||||
configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
|
configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
|
||||||
vmTools = pkgs.vmTools.override
|
vmTools = pkgs.vmTools.override
|
||||||
{
|
({
|
||||||
rootModules = [ "9p" "9pnet_virtio" "virtio_pci" "virtio_blk" ]
|
rootModules = [
|
||||||
|
"9p" "9pnet_virtio" # we can drop those in future if we stop supporting 24.11
|
||||||
|
|
||||||
|
"virtiofs"
|
||||||
|
"virtio_pci"
|
||||||
|
"virtio_blk"
|
||||||
|
"virtio_balloon"
|
||||||
|
"virtio_rng"
|
||||||
|
]
|
||||||
++ (lib.optional configSupportsZfs "zfs")
|
++ (lib.optional configSupportsZfs "zfs")
|
||||||
++ cfg.extraRootModules;
|
++ cfg.extraRootModules;
|
||||||
kernel = pkgs.aggregateModules
|
kernel = pkgs.aggregateModules
|
||||||
@@ -24,7 +32,7 @@ let
|
|||||||
// lib.optionalAttrs (diskoLib.vmToolsSupportsCustomQemu lib)
|
// lib.optionalAttrs (diskoLib.vmToolsSupportsCustomQemu lib)
|
||||||
{
|
{
|
||||||
customQemu = cfg.qemu;
|
customQemu = cfg.qemu;
|
||||||
};
|
});
|
||||||
cleanedConfig = diskoLib.testLib.prepareDiskoConfig config diskoLib.testLib.devices;
|
cleanedConfig = diskoLib.testLib.prepareDiskoConfig config diskoLib.testLib.devices;
|
||||||
systemToInstall = extendModules {
|
systemToInstall = extendModules {
|
||||||
modules = [
|
modules = [
|
||||||
@@ -113,7 +121,7 @@ in
|
|||||||
{
|
{
|
||||||
buildInputs = dependencies;
|
buildInputs = dependencies;
|
||||||
inherit preVM QEMU_OPTS;
|
inherit preVM QEMU_OPTS;
|
||||||
postVm = cfg.extraPostVM;
|
postVM = cfg.extraPostVM;
|
||||||
inherit (diskoCfg) memSize;
|
inherit (diskoCfg) memSize;
|
||||||
}
|
}
|
||||||
(partitioner + installer));
|
(partitioner + installer));
|
||||||
|
|||||||
+10
-2
@@ -101,7 +101,13 @@
|
|||||||
_mount = diskoLib.mkMountOption {
|
_mount = diskoLib.mkMountOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default =
|
default =
|
||||||
lib.optionalAttrs (config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off") {
|
(lib.optionalAttrs (config.options.keylocation or "none" != "none") {
|
||||||
|
dev = ''
|
||||||
|
if [ "$(zfs get keystatus ${config._name} -H -o value)" == "unavailable" ]; then
|
||||||
|
zfs load-key ${config._name}
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
}) // lib.optionalAttrs (config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off") {
|
||||||
fs.${config.mountpoint} = ''
|
fs.${config.mountpoint} = ''
|
||||||
if ! findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
if ! findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
||||||
mount ${config._name} "${rootMountPoint}${config.mountpoint}" \
|
mount ${config._name} "${rootMountPoint}${config.mountpoint}" \
|
||||||
@@ -117,7 +123,9 @@
|
|||||||
_unmount = diskoLib.mkUnmountOption {
|
_unmount = diskoLib.mkUnmountOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default =
|
default =
|
||||||
lib.optionalAttrs (config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off") {
|
(lib.optionalAttrs (config.options.keylocation or "none" != "none") {
|
||||||
|
dev = "zfs unload-key ${config.name}";
|
||||||
|
}) // lib.optionalAttrs (config.options.mountpoint or "" != "none" && config.options.canmount or "" != "off") {
|
||||||
fs.${config.mountpoint} = ''
|
fs.${config.mountpoint} = ''
|
||||||
if findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
if findmnt ${config._name} "${rootMountPoint}${config.mountpoint}" >/dev/null 2>&1; then
|
||||||
umount "${rootMountPoint}${config.mountpoint}"
|
umount "${rootMountPoint}${config.mountpoint}"
|
||||||
|
|||||||
@@ -66,13 +66,30 @@
|
|||||||
};
|
};
|
||||||
_mount = diskoLib.mkMountOption {
|
_mount = diskoLib.mkMountOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default =
|
default = {
|
||||||
lib.optionalAttrs (config.content != null) config.content._mount;
|
dev = ''
|
||||||
|
${lib.optionalString (config.options.keylocation or "none" != "none") ''
|
||||||
|
if [ "$(zfs get keystatus ${config.name} -H -o value)" == "unavailable" ]; then
|
||||||
|
zfs load-key ${config.name}
|
||||||
|
fi
|
||||||
|
''}
|
||||||
|
|
||||||
|
${config.content._mount.dev or ""}
|
||||||
|
'';
|
||||||
|
fs = config.content._mount.fs or { };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
_unmount = diskoLib.mkUnmountOption {
|
_unmount = diskoLib.mkUnmountOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default =
|
default = {
|
||||||
lib.optionalAttrs (config.content != null) config.content._unmount;
|
dev = ''
|
||||||
|
${lib.optionalString (config.options.keylocation or "none" != "none") "zfs unload-key ${config.name}"}
|
||||||
|
|
||||||
|
${config.content._unmount.dev or ""}
|
||||||
|
'';
|
||||||
|
|
||||||
|
fs = config.content._unmount.fs or {};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
_config = lib.mkOption {
|
_config = lib.mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
|
|||||||
+51
-16
@@ -25,6 +25,44 @@ in
|
|||||||
};
|
};
|
||||||
mode = lib.mkOption {
|
mode = lib.mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
|
example = {
|
||||||
|
mode = {
|
||||||
|
topology = {
|
||||||
|
type = "topology";
|
||||||
|
vdev = [
|
||||||
|
{
|
||||||
|
# Members can be either specified by a full path or by a disk name
|
||||||
|
# This is example uses the full path
|
||||||
|
members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
log = [
|
||||||
|
{
|
||||||
|
# Example using gpt partition labels
|
||||||
|
# This expects an disk called `ssd` with a gpt partition called `zfs`
|
||||||
|
# disko.devices.disk.ssd = {
|
||||||
|
# type = "disk";
|
||||||
|
# device = "/dev/nvme0n1";
|
||||||
|
# content = {
|
||||||
|
# type = "gpt";
|
||||||
|
# partitions = {
|
||||||
|
# zfs = {
|
||||||
|
# size = "100%";
|
||||||
|
# content = {
|
||||||
|
# type = "zfs";
|
||||||
|
# # use your own pool name here
|
||||||
|
# pool = "zroot";
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
members = [ "ssd" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
type = (lib.types.oneOf [
|
type = (lib.types.oneOf [
|
||||||
(lib.types.enum modeOptions)
|
(lib.types.enum modeOptions)
|
||||||
(lib.types.attrsOf (diskoLib.subType {
|
(lib.types.attrsOf (diskoLib.subType {
|
||||||
@@ -299,33 +337,30 @@ in
|
|||||||
inherit config options;
|
inherit config options;
|
||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
datasetMounts = diskoLib.deepMergeMap (dataset: dataset._mount) (lib.attrValues config.datasets);
|
datasetFilesystemsMounts = diskoLib.deepMergeMap (dataset: dataset._mount.fs or {}) (lib.attrValues config.datasets);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
dev = ''
|
dev = ''
|
||||||
zpool list "${config.name}" >/dev/null 2>/dev/null ||
|
zpool list "${config.name}" >/dev/null 2>/dev/null ||
|
||||||
zpool import -l -R ${rootMountPoint} "${config.name}"
|
zpool import -l -R ${rootMountPoint} "${config.name}"
|
||||||
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues datasetMounts)}
|
|
||||||
|
${lib.concatMapStrings (x: x._mount.dev or "") (lib.attrValues config.datasets)}
|
||||||
'';
|
'';
|
||||||
fs = datasetMounts.fs or { };
|
fs = datasetFilesystemsMounts;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
_unmount = diskoLib.mkUnmountOption {
|
_unmount = diskoLib.mkUnmountOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default =
|
default = {
|
||||||
let
|
dev = ''
|
||||||
datasetUnmounts = diskoLib.deepMergeMap (dataset: dataset._unmount) (lib.attrValues config.datasets);
|
${lib.concatMapStrings (dataset: dataset._unmount.dev or "") (lib.attrValues config.datasets)}
|
||||||
in
|
|
||||||
{
|
|
||||||
dev = ''
|
|
||||||
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues datasetUnmounts)}
|
|
||||||
|
|
||||||
if zpool list "${config.name}" >/dev/null 2>/dev/null; then
|
if zpool list "${config.name}" >/dev/null 2>/dev/null; then
|
||||||
zpool export "${config.name}"
|
zpool export "${config.name}"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
fs = datasetUnmounts.fs or { };
|
fs = diskoLib.deepMergeMap (dataset: dataset._unmount.fs or {}) (lib.attrValues config.datasets);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
_config = lib.mkOption {
|
_config = lib.mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
|
|||||||
+2
-2
@@ -59,9 +59,9 @@ in
|
|||||||
extraPostVM = lib.mkOption {
|
extraPostVM = lib.mkOption {
|
||||||
type = lib.types.lines;
|
type = lib.types.lines;
|
||||||
description = ''
|
description = ''
|
||||||
extra shell code to execute once the disk image(s) have been succesfully created and moved to $out
|
extra shell code to execute once the disk image(s) have been successfully created and moved to $out
|
||||||
'';
|
'';
|
||||||
default = "";
|
default = ":";
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
''${pkgs.zstd}/bin/zstd --compress $out/*raw
|
''${pkgs.zstd}/bin/zstd --compress $out/*raw
|
||||||
rm $out/*raw
|
rm $out/*raw
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { }
|
||||||
|
, diskoLib ? pkgs.callPackage ../lib { }
|
||||||
|
}:
|
||||||
|
diskoLib.testLib.makeDiskoTest {
|
||||||
|
inherit pkgs;
|
||||||
|
name = "xfs";
|
||||||
|
disko-config = ../example/xfs-with-quota.nix;
|
||||||
|
extraTestScript = ''
|
||||||
|
machine.succeed("mountpoint /");
|
||||||
|
|
||||||
|
machine.succeed("xfs_quota -c 'print' / | grep -q '(pquota)'")
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -57,9 +57,9 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
vdev = ""
|
vdev = ""
|
||||||
actual.sort()
|
actual.sort()
|
||||||
expected=sorted([
|
expected=sorted([
|
||||||
'zroot /dev/disk/by-partlabel/disk-data3-zfs',
|
'zroot /dev/disk/by-partlabel/disk-data1-zfs',
|
||||||
'zroot mirror /dev/disk/by-partlabel/disk-data1-zfs',
|
|
||||||
'zroot mirror /dev/disk/by-partlabel/disk-data2-zfs',
|
'zroot mirror /dev/disk/by-partlabel/disk-data2-zfs',
|
||||||
|
'zroot mirror /dev/disk/by-partlabel/disk-data3-zfs',
|
||||||
'dedup /dev/disk/by-partlabel/disk-dedup3-zfs',
|
'dedup /dev/disk/by-partlabel/disk-dedup3-zfs',
|
||||||
'dedup mirror /dev/disk/by-partlabel/disk-dedup1-zfs',
|
'dedup mirror /dev/disk/by-partlabel/disk-dedup1-zfs',
|
||||||
'dedup mirror /dev/disk/by-partlabel/disk-dedup2-zfs',
|
'dedup mirror /dev/disk/by-partlabel/disk-dedup2-zfs',
|
||||||
|
|||||||
+5
-2
@@ -11,7 +11,8 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
||||||
};
|
};
|
||||||
extraTestScript = ''
|
extraTestScript = ''
|
||||||
machine.succeed("test -b /dev/zvol/zroot/zfs_testvolume");
|
machine.succeed("test -b /dev/zvol/zroot/zfs_volume");
|
||||||
|
machine.succeed("test -b /dev/zvol/zroot/zfs_encryptedvolume");
|
||||||
|
|
||||||
def assert_property(ds, property, expected_value):
|
def assert_property(ds, property, expected_value):
|
||||||
out = machine.succeed(f"zfs get -H {property} {ds} -o value").rstrip()
|
out = machine.succeed(f"zfs get -H {property} {ds} -o value").rstrip()
|
||||||
@@ -23,7 +24,8 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
assert_property("zroot/zfs_fs", "compression", "zstd")
|
assert_property("zroot/zfs_fs", "compression", "zstd")
|
||||||
assert_property("zroot", "com.sun:auto-snapshot", "false")
|
assert_property("zroot", "com.sun:auto-snapshot", "false")
|
||||||
assert_property("zroot/zfs_fs", "com.sun:auto-snapshot", "true")
|
assert_property("zroot/zfs_fs", "com.sun:auto-snapshot", "true")
|
||||||
assert_property("zroot/zfs_testvolume", "volsize", "10M")
|
assert_property("zroot/zfs_volume", "volsize", "10M")
|
||||||
|
assert_property("zroot/zfs_encryptedvolume", "volsize", "10M")
|
||||||
assert_property("zroot/zfs_unmounted_fs", "mountpoint", "none")
|
assert_property("zroot/zfs_unmounted_fs", "mountpoint", "none")
|
||||||
|
|
||||||
machine.succeed("zfs get name zroot@blank")
|
machine.succeed("zfs get name zroot@blank")
|
||||||
@@ -31,6 +33,7 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
machine.succeed("mountpoint /zfs_fs");
|
machine.succeed("mountpoint /zfs_fs");
|
||||||
machine.succeed("mountpoint /zfs_legacy_fs");
|
machine.succeed("mountpoint /zfs_legacy_fs");
|
||||||
machine.succeed("mountpoint /ext4onzfs");
|
machine.succeed("mountpoint /ext4onzfs");
|
||||||
|
machine.succeed("mountpoint /ext4onzfsencrypted");
|
||||||
machine.succeed("mountpoint /zfs_crypted");
|
machine.succeed("mountpoint /zfs_crypted");
|
||||||
machine.succeed("zfs get keystatus zroot/encrypted");
|
machine.succeed("zfs get keystatus zroot/encrypted");
|
||||||
machine.succeed("zfs get keystatus zroot/encrypted/test");
|
machine.succeed("zfs get keystatus zroot/encrypted/test");
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{ version = "1.10.0"; released = true; }
|
{ version = "1.10.0"; released = false; }
|
||||||
Reference in new issue
Block a user