mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13:28 +01:00
Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
404786c442 | ||
|
|
d0c543d740 | ||
|
|
ca27b88c88 | ||
|
|
c5140c6079 | ||
|
|
1770bf1ae5 | ||
|
|
51d33bbb7f | ||
|
|
76c0a6dba3 | ||
|
|
a8e75da08f | ||
|
|
8f806681d7 | ||
|
|
329d3d7e8b | ||
|
|
f6dbc8952d | ||
|
|
ddbe63d43e | ||
|
|
b36e87600d | ||
|
|
212ff71553 | ||
|
|
b2c95fb68f | ||
|
|
0d8c6ad4a4 | ||
|
|
0c8f1b9eab | ||
|
|
46b9f51eb6 | ||
|
|
eea057603d | ||
|
|
9a7ab516cf | ||
|
|
87d86e499c | ||
|
|
23f112ad4e |
No files matched your search
@@ -4,3 +4,6 @@ result-*
|
|||||||
|
|
||||||
# Created by the NixOS interactive test driver
|
# Created by the NixOS interactive test driver
|
||||||
.nixos-test-history
|
.nixos-test-history
|
||||||
|
|
||||||
|
# Created by `:bl` in `nix repl`
|
||||||
|
repl-result-out
|
||||||
@@ -108,7 +108,7 @@ let
|
|||||||
else if hasDiskoModuleFlake then
|
else if hasDiskoModuleFlake then
|
||||||
(builtins.getFlake flake).nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr}
|
(builtins.getFlake flake).nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr}
|
||||||
or (pkgs.writeShellScriptBin "disko-compat-error" ''
|
or (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
|
||||||
echo ' not found in flake `${flake}`!' >&2
|
echo ' not found in flake `${flake}`!' >&2
|
||||||
echo ' This is probably caused by the locked version of disko in the flake' >&2
|
echo ' This is probably caused by the locked version of disko in the flake' >&2
|
||||||
echo ' being different from the version of disko you executed.' >&2
|
echo ' being different from the version of disko you executed.' >&2
|
||||||
|
|||||||
@@ -4,5 +4,7 @@ set -efux -o pipefail
|
|||||||
disk=$(realpath "$1")
|
disk=$(realpath "$1")
|
||||||
|
|
||||||
lsblk -a -f >&2
|
lsblk -a -f >&2
|
||||||
|
# since we currently cannot recursively deactivate swaps on zfs volumes, we need to deactivate all of them.
|
||||||
|
lsblk --output-all --json | jq -r -f "$(dirname "$0")/zfs-swap-deactivate.jq" | bash -x
|
||||||
lsblk --output-all --json | jq -r --arg disk_to_clear "$disk" -f "$(dirname "$0")/disk-deactivate.jq" | bash -x
|
lsblk --output-all --json | jq -r --arg disk_to_clear "$disk" -f "$(dirname "$0")/disk-deactivate.jq" | bash -x
|
||||||
lsblk -a -f >&2
|
lsblk -a -f >&2
|
||||||
@@ -1,20 +1,25 @@
|
|||||||
|
def shellquote:
|
||||||
|
gsub("'"; "''\\''") |
|
||||||
|
"'" + . + "'"
|
||||||
|
;
|
||||||
|
|
||||||
# since lsblk lacks zfs support, we have to do it this way
|
# since lsblk lacks zfs support, we have to do it this way
|
||||||
def remove:
|
def remove:
|
||||||
if .fstype == "zfs_member" then
|
if .fstype == "zfs_member" then
|
||||||
"if type zpool >/dev/null; then zpool destroy -f \(.label); zpool labelclear -f \(.label); fi"
|
"if type zpool >/dev/null; then zpool destroy -f \(.label); zpool labelclear -f \(.label); fi"
|
||||||
elif .fstype == "LVM2_member" then
|
elif .fstype == "LVM2_member" then
|
||||||
[
|
[
|
||||||
"vg=$(pvs \(.path) --noheadings --options vg_name | grep -o '[a-zA-Z0-9-]*')",
|
"vg=$(pvs \(.path | shellquote) --noheadings --options vg_name | grep -o '[a-zA-Z0-9-]*')",
|
||||||
"vgchange -a n \"$vg\"",
|
"vgchange -a n \"$vg\"",
|
||||||
"vgremove -f \"$vg\""
|
"vgremove -f \"$vg\""
|
||||||
]
|
]
|
||||||
elif .fstype == "swap" then
|
elif .fstype == "swap" then
|
||||||
"swapoff \(.path)"
|
"swapoff \(.path | shellquote)"
|
||||||
elif .fstype == null then
|
elif .fstype == null then
|
||||||
# maybe its zfs
|
# maybe its zfs
|
||||||
[
|
[
|
||||||
# the next line has some horrible escaping
|
# the next line has some horrible escaping
|
||||||
"zpool=$(if type zdb >/dev/null; then zdb -l \(.path) | sed -nr $'s/ +name: \\'(.*)\\'/\\\\1/p'; fi)",
|
"zpool=$(if type zdb >/dev/null; then zdb -l \(.path | shellquote) | sed -nr $'s/ +name: \\'(.*)\\'/\\\\1/p'; fi)",
|
||||||
"if [[ -n \"${zpool}\" ]]; then zpool destroy -f \"$zpool\"; zpool labelclear -f \"$zpool\"; fi",
|
"if [[ -n \"${zpool}\" ]]; then zpool destroy -f \"$zpool\"; zpool labelclear -f \"$zpool\"; fi",
|
||||||
"unset zpool"
|
"unset zpool"
|
||||||
]
|
]
|
||||||
@@ -27,25 +32,25 @@ def deactivate:
|
|||||||
if .type == "disk" or .type == "loop" then
|
if .type == "disk" or .type == "loop" then
|
||||||
[
|
[
|
||||||
# If this disk is a member of raid, stop that raid
|
# If this disk is a member of raid, stop that raid
|
||||||
"md_dev=$(lsblk \(.path) -l -p -o type,name | awk 'match($1,\"raid.*\") {print $2}')",
|
"md_dev=$(lsblk \(.path | shellquote) -l -p -o type,name | awk 'match($1,\"raid.*\") {print $2}')",
|
||||||
"if [[ -n \"${md_dev}\" ]]; then umount \"$md_dev\"; mdadm --stop \"$md_dev\"; fi",
|
"if [[ -n \"${md_dev}\" ]]; then umount \"$md_dev\"; mdadm --stop \"$md_dev\"; fi",
|
||||||
# Remove all file-systems and other magic strings
|
# Remove all file-systems and other magic strings
|
||||||
"wipefs --all -f \(.path)",
|
"wipefs --all -f \(.path | shellquote)",
|
||||||
# Remove the MBR bootstrap code
|
# Remove the MBR bootstrap code
|
||||||
"dd if=/dev/zero of=\(.path) bs=440 count=1"
|
"dd if=/dev/zero of=\(.path | shellquote) bs=440 count=1"
|
||||||
]
|
]
|
||||||
elif .type == "part" then
|
elif .type == "part" then
|
||||||
[
|
[
|
||||||
"wipefs --all -f \(.path)"
|
"wipefs --all -f \(.path | shellquote)"
|
||||||
]
|
]
|
||||||
elif .type == "crypt" then
|
elif .type == "crypt" then
|
||||||
[
|
[
|
||||||
"cryptsetup luksClose \(.path)",
|
"cryptsetup luksClose \(.path | shellquote)",
|
||||||
"wipefs --all -f \(.path)"
|
"wipefs --all -f \(.path | shellquote)"
|
||||||
]
|
]
|
||||||
elif .type == "swap" then
|
elif .type == "swap" then
|
||||||
[
|
[
|
||||||
"swapoff \(.path)",
|
"swapoff \(.path | shellquote)"
|
||||||
]
|
]
|
||||||
elif .type == "lvm" then
|
elif .type == "lvm" then
|
||||||
(.name | split("-")[0]) as $vgname |
|
(.name | split("-")[0]) as $vgname |
|
||||||
@@ -55,7 +60,7 @@ def deactivate:
|
|||||||
]
|
]
|
||||||
elif (.type | contains("raid")) then
|
elif (.type | contains("raid")) then
|
||||||
[
|
[
|
||||||
"mdadm --stop \(.name)"
|
"mdadm --stop \(.name | shellquote)"
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
["echo Warning: unknown type '\(.type)'. Consider handling this in https://github.com/nix-community/disko/blob/master/disk-deactivate/disk-deactivate.jq"]
|
["echo Warning: unknown type '\(.type)'. Consider handling this in https://github.com/nix-community/disko/blob/master/disk-deactivate/disk-deactivate.jq"]
|
||||||
@@ -64,7 +69,7 @@ def deactivate:
|
|||||||
|
|
||||||
def walk:
|
def walk:
|
||||||
[
|
[
|
||||||
(.mountpoints[] | select(. != null) | "umount -R \(.)"),
|
(.mountpoints[] | select(. != null) | "umount -R \(. | shellquote)"),
|
||||||
((.children // []) | map(walk)),
|
((.children // []) | map(walk)),
|
||||||
remove,
|
remove,
|
||||||
deactivate
|
deactivate
|
||||||
@@ -87,4 +92,3 @@ def init:
|
|||||||
;
|
;
|
||||||
|
|
||||||
.blockdevices | map(init) | flatten | join("\n")
|
.blockdevices | map(init) | flatten | join("\n")
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
def turnOffSwaps:
|
||||||
|
if (.name | test("^zd[0-9]+$")) and .type == "disk" then
|
||||||
|
"swapoff /dev/" + .name
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
;
|
||||||
|
|
||||||
|
.blockdevices | map(turnOffSwaps) | flatten | join("\n")
|
||||||
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
# Running Interactive VMs with disko
|
# Running Interactive VMs with `disko`
|
||||||
|
|
||||||
disko now exports its own flavor of interactive VMs (similiar to
|
disko now exports its own flavor of interactive VMs (similiar to
|
||||||
config.system.build.vm). Simply import the disko module and build the vm runner
|
config.system.build.vm). Simply import the disko module and build the vm runner
|
||||||
with:
|
with:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
nix run -L '.#nixosConfigurations.mymachine.config.system.build.vmWithDisko'
|
nix run -L '.#nixosConfigurations.mymachine.config.system.build.vmWithDisko'
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@ option:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
extraConfig that is set in disko.tests.extraConfig is also applied to the
|
Extra configuration that is set in `disko.tests.extraConfig` is also applied to the
|
||||||
interactive VMs. imageSize of the VMs will be determined by the imageSize in the
|
interactive VMs. The image size of the VMs will be determined by the
|
||||||
disk type in your disko config. memorySize is set by disko.memSize
|
`disko.devices.disk.<name>.imageSize`
|
||||||
|
specifications. The memory size is set by `disko.memSize`.
|
||||||
+17
-2
@@ -55,15 +55,30 @@ Instead, you can build and then run the VM for a test in interactive mode. This
|
|||||||
will create the VM and all virtual disks as required by the test's config, but
|
will create the VM and all virtual disks as required by the test's config, but
|
||||||
allow you to interact with the machine on a terminal afterwards.
|
allow you to interact with the machine on a terminal afterwards.
|
||||||
|
|
||||||
First, build the interactive test driver and run it:
|
First, build the interactive test driver:
|
||||||
|
|
||||||
```
|
```
|
||||||
nix build .#checks.x86_64-linux.simple-efi.driverInteractive
|
nix build .#checks.x86_64-linux.simple-efi.driverInteractive
|
||||||
|
```
|
||||||
|
|
||||||
|
The build outputs will be linked in the "result" directory. Of interest will be
|
||||||
|
the generated Python "test-script" it contains, which will contain the commands
|
||||||
|
that the test driver will run.
|
||||||
|
|
||||||
|
You can run the test driver with:
|
||||||
|
```
|
||||||
result/bin/nixos-test-driver --keep-vm-state
|
result/bin/nixos-test-driver --keep-vm-state
|
||||||
```
|
```
|
||||||
|
|
||||||
This will open an IPython prompt in which you can use the same objects and
|
This will open an IPython prompt in which you can use the same objects and
|
||||||
functions as in `extraTestScript`. In there, you can run
|
functions as in `extraTestScript`.
|
||||||
|
|
||||||
|
In there, you can debug the test-script, by copy-pasting and running (parts of)
|
||||||
|
its contents into the prompt. This will, for example, allow you to inspect the
|
||||||
|
VM state after running each of the generated "disko-format", "disko-mount",
|
||||||
|
"disko-destroy-format-mount", etc. scripts.
|
||||||
|
|
||||||
|
From the prompt, you can also run:
|
||||||
|
|
||||||
```
|
```
|
||||||
machine.shell_interact()
|
machine.shell_interact()
|
||||||
|
|||||||
+123
-10
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
disko.devices = {
|
disko.devices = {
|
||||||
disk = {
|
disk = {
|
||||||
main = {
|
vdb = {
|
||||||
device = "/dev/disk/by-path/pci-0000:02:00.0-nvme-1";
|
device = "/dev/vdb";
|
||||||
type = "disk";
|
type = "disk";
|
||||||
content = {
|
content = {
|
||||||
type = "gpt";
|
type = "gpt";
|
||||||
partitions = {
|
partitions = {
|
||||||
ESP = {
|
vdb1 = {
|
||||||
end = "500M";
|
|
||||||
type = "EF00";
|
type = "EF00";
|
||||||
|
size = "100M";
|
||||||
content = {
|
content = {
|
||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
@@ -17,18 +17,131 @@
|
|||||||
mountOptions = [ "umask=0077" ];
|
mountOptions = [ "umask=0077" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
root = {
|
|
||||||
name = "root";
|
vdb2 = {
|
||||||
end = "-0";
|
size = "100%";
|
||||||
content = {
|
content = {
|
||||||
type = "filesystem";
|
type = "bcachefs";
|
||||||
format = "bcachefs";
|
# This refers to a filesystem in the `bcachefs_filesystems` attrset below.
|
||||||
mountpoint = "/";
|
filesystem = "mounted_subvolumes_in_multi";
|
||||||
|
label = "group_a.vdb2";
|
||||||
|
extraFormatArgs = [
|
||||||
|
"--discard"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
vdc = {
|
||||||
|
device = "/dev/vdc";
|
||||||
|
type = "disk";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
vdc1 = {
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "bcachefs";
|
||||||
|
filesystem = "mounted_subvolumes_in_multi";
|
||||||
|
label = "group_a.vdc1";
|
||||||
|
extraFormatArgs = [
|
||||||
|
"--discard"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
vdd = {
|
||||||
|
device = "/dev/vdd";
|
||||||
|
type = "disk";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
vdd1 = {
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "bcachefs";
|
||||||
|
filesystem = "mounted_subvolumes_in_multi";
|
||||||
|
label = "group_b.vdd1";
|
||||||
|
extraFormatArgs = [
|
||||||
|
"--force"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
vde = {
|
||||||
|
device = "/dev/vde";
|
||||||
|
type = "disk";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
vdd1 = {
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "bcachefs";
|
||||||
|
filesystem = "relies_on_external_subvolume";
|
||||||
|
label = "group_a.vde1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bcachefs_filesystems = {
|
||||||
|
# Example showing mounted subvolumes in a multi-disk configuration.
|
||||||
|
mounted_subvolumes_in_multi = {
|
||||||
|
type = "bcachefs_filesystem";
|
||||||
|
passwordFile = "/tmp/secret.key";
|
||||||
|
extraFormatArgs = [
|
||||||
|
"--compression=lz4"
|
||||||
|
"--background_compression=lz4"
|
||||||
|
];
|
||||||
|
subvolumes = {
|
||||||
|
# Subvolume name is different from mountpoint.
|
||||||
|
"subvolumes/root" = {
|
||||||
|
mountpoint = "/";
|
||||||
|
mountOptions = [
|
||||||
|
"verbose"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
# Subvolume name is the same as the mountpoint.
|
||||||
|
"subvolumes/home" = {
|
||||||
|
mountpoint = "/home";
|
||||||
|
};
|
||||||
|
# Nested subvolume doesn't need a mountpoint as its parent is mounted.
|
||||||
|
"subvolumes/home/user" = {
|
||||||
|
};
|
||||||
|
# Parent is not mounted so the mountpoint must be set.
|
||||||
|
"subvolumes/nix" = {
|
||||||
|
mountpoint = "/nix";
|
||||||
|
};
|
||||||
|
# This subvolume will be created but not mounted.
|
||||||
|
"subvolumes/test" = {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Example showing a bcachefs filesystem without subvolumes
|
||||||
|
# and which relies on a subvolume in another filesystem being mounted.
|
||||||
|
relies_on_external_subvolume = {
|
||||||
|
type = "bcachefs_filesystem";
|
||||||
|
mountpoint = "/home/Documents";
|
||||||
|
extraFormatArgs = [
|
||||||
|
"--compression=lz4"
|
||||||
|
"--background_compression=lz4"
|
||||||
|
];
|
||||||
|
mountOptions = [
|
||||||
|
"verbose"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
+3
-3
@@ -107,13 +107,13 @@
|
|||||||
lvm_type = "mirror";
|
lvm_type = "mirror";
|
||||||
content = {
|
content = {
|
||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
format = "exfat";
|
format = "ext4";
|
||||||
mountpoint = "/exfat_on_lvm";
|
mountpoint = "/ext4_on_lvm";
|
||||||
mountOptions = [
|
mountOptions = [
|
||||||
"defaults"
|
"defaults"
|
||||||
];
|
];
|
||||||
postMountHook = ''
|
postMountHook = ''
|
||||||
touch /mnt/exfat_on_lvm/file-from-postMountHook
|
touch /mnt/ext4_on_lvm/file-from-postMountHook
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Generated
+3
-3
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1738136902,
|
"lastModified": 1744868846,
|
||||||
"narHash": "sha256-pUvLijVGARw4u793APze3j6mU1Zwdtz7hGkGGkD87qw=",
|
"narHash": "sha256-5RJTdUHDmj12Qsv7XOhuospjAjATNiTMElplWnJE9Hs=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9a5db3142ce450045840cc8d832b13b8a2018e0c",
|
"rev": "ebe4301cbd8f81c4f8d3244b3632338bbeb6d49c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"i686-linux"
|
"i686-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
"riscv64-linux"
|
"riscv64-linux"
|
||||||
|
"aarch64-darwin"
|
||||||
];
|
];
|
||||||
forAllSystems = lib.genAttrs supportedSystems;
|
forAllSystems = lib.genAttrs supportedSystems;
|
||||||
|
|
||||||
@@ -68,6 +69,12 @@
|
|||||||
diskoVersion = version;
|
diskoVersion = version;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
checkJqSyntax = pkgs.runCommand "check-jq-syntax" { nativeBuildInputs = [ pkgs.jq ]; } ''
|
||||||
|
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/disk-deactivate.jq} --arg disk_to_clear foo
|
||||||
|
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/zfs-swap-deactivate.jq}
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
|
|
||||||
jsonTypes = pkgs.writeTextFile {
|
jsonTypes = pkgs.writeTextFile {
|
||||||
name = "jsonTypes";
|
name = "jsonTypes";
|
||||||
text = (builtins.toJSON diskoLib.jsonTypes);
|
text = (builtins.toJSON diskoLib.jsonTypes);
|
||||||
@@ -83,7 +90,7 @@
|
|||||||
//
|
//
|
||||||
pkgs.lib.optionalAttrs (!pkgs.stdenv.buildPlatform.isRiscV64 && !pkgs.stdenv.hostPlatform.isx86_32)
|
pkgs.lib.optionalAttrs (!pkgs.stdenv.buildPlatform.isRiscV64 && !pkgs.stdenv.hostPlatform.isx86_32)
|
||||||
{
|
{
|
||||||
inherit jsonTypes treefmt;
|
inherit jsonTypes treefmt checkJqSyntax;
|
||||||
inherit (self.packages.${system}) disko-doc;
|
inherit (self.packages.${system}) disko-doc;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ let
|
|||||||
# option for valid contents of partitions (basically like devices, but without tables)
|
# option for valid contents of partitions (basically like devices, but without tables)
|
||||||
_partitionTypes = {
|
_partitionTypes = {
|
||||||
inherit (diskoLib.types)
|
inherit (diskoLib.types)
|
||||||
|
bcachefs
|
||||||
btrfs
|
btrfs
|
||||||
filesystem
|
filesystem
|
||||||
zfs
|
zfs
|
||||||
@@ -69,6 +70,7 @@ let
|
|||||||
# option for valid contents of devices
|
# option for valid contents of devices
|
||||||
_deviceTypes = {
|
_deviceTypes = {
|
||||||
inherit (diskoLib.types)
|
inherit (diskoLib.types)
|
||||||
|
bcachefs
|
||||||
table
|
table
|
||||||
gpt
|
gpt
|
||||||
btrfs
|
btrfs
|
||||||
@@ -611,6 +613,7 @@ let
|
|||||||
let
|
let
|
||||||
devices = {
|
devices = {
|
||||||
inherit (cfg.config)
|
inherit (cfg.config)
|
||||||
|
bcachefs_filesystems
|
||||||
disk
|
disk
|
||||||
mdadm
|
mdadm
|
||||||
zpool
|
zpool
|
||||||
@@ -621,6 +624,11 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
bcachefs_filesystems = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf diskoLib.types.bcachefs_filesystem;
|
||||||
|
default = { };
|
||||||
|
description = "bcachefs filesystem";
|
||||||
|
};
|
||||||
disk = lib.mkOption {
|
disk = lib.mkOption {
|
||||||
type = lib.types.attrsOf diskoLib.types.disk;
|
type = lib.types.attrsOf diskoLib.types.disk;
|
||||||
default = { };
|
default = { };
|
||||||
@@ -687,6 +695,7 @@ let
|
|||||||
throw "No disks defined, did you forget to import your disko config?"
|
throw "No disks defined, did you forget to import your disko config?"
|
||||||
else
|
else
|
||||||
v;
|
v;
|
||||||
|
# @todo Do we need to add bcachefs-tools or not?
|
||||||
destroyDependencies = with pkgs; [
|
destroyDependencies = with pkgs; [
|
||||||
util-linux
|
util-linux
|
||||||
e2fsprogs
|
e2fsprogs
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ let
|
|||||||
disks = lib.attrValues cfg_.disko.devices.disk;
|
disks = lib.attrValues cfg_.disko.devices.disk;
|
||||||
rootDisk = {
|
rootDisk = {
|
||||||
name = "root";
|
name = "root";
|
||||||
file = ''"$tmp"/${lib.escapeShellArg (builtins.head disks).name}.qcow2'';
|
file = ''"$tmp"/${lib.escapeShellArg (builtins.head disks).imageName}.qcow2'';
|
||||||
driveExtraOpts.cache = "writeback";
|
driveExtraOpts.cache = "writeback";
|
||||||
driveExtraOpts.werror = "report";
|
driveExtraOpts.werror = "report";
|
||||||
deviceExtraOpts.bootindex = "1";
|
deviceExtraOpts.bootindex = "1";
|
||||||
@@ -36,7 +36,7 @@ let
|
|||||||
};
|
};
|
||||||
otherDisks = map (disk: {
|
otherDisks = map (disk: {
|
||||||
name = disk.name;
|
name = disk.name;
|
||||||
file = ''"$tmp"/${lib.escapeShellArg disk.name}.qcow2'';
|
file = ''"$tmp"/${lib.escapeShellArg disk.imageName}.qcow2'';
|
||||||
driveExtraOpts.werror = "report";
|
driveExtraOpts.werror = "report";
|
||||||
}) (builtins.tail disks);
|
}) (builtins.tail disks);
|
||||||
|
|
||||||
@@ -78,8 +78,8 @@ in
|
|||||||
trap 'rm -rf "$tmp"' EXIT
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
${lib.concatMapStringsSep "\n" (disk: ''
|
${lib.concatMapStringsSep "\n" (disk: ''
|
||||||
${hostPkgs.qemu}/bin/qemu-img create -f qcow2 \
|
${hostPkgs.qemu}/bin/qemu-img create -f qcow2 \
|
||||||
-b ${config.system.build.diskoImages}/${lib.escapeShellArg disk.name}.qcow2 \
|
-b ${config.system.build.diskoImages}/${lib.escapeShellArg disk.imageName}.qcow2 \
|
||||||
-F qcow2 "$tmp"/${lib.escapeShellArg disk.name}.qcow2
|
-F qcow2 "$tmp"/${lib.escapeShellArg disk.imageName}.qcow2
|
||||||
'') disks}
|
'') disks}
|
||||||
set +f
|
set +f
|
||||||
${config.system.build.vm}/bin/run-*-vm
|
${config.system.build.vm}/bin/run-*-vm
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ let
|
|||||||
disko.devices = lib.mkForce cleanedConfig.disko.devices;
|
disko.devices = lib.mkForce cleanedConfig.disko.devices;
|
||||||
boot.loader.grub.devices = lib.mkForce cleanedConfig.boot.loader.grub.devices;
|
boot.loader.grub.devices = lib.mkForce cleanedConfig.boot.loader.grub.devices;
|
||||||
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||||
|
nixpkgs.buildPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -125,7 +126,7 @@ let
|
|||||||
${pkgs.systemdMinimal}/lib/systemd/systemd-udevd --daemon
|
${pkgs.systemdMinimal}/lib/systemd/systemd-udevd --daemon
|
||||||
partprobe
|
partprobe
|
||||||
udevadm trigger --action=add
|
udevadm trigger --action=add
|
||||||
udevadm settle
|
udevadm settle --timeout=120
|
||||||
|
|
||||||
${lib.optionalString diskoCfg.testMode ''
|
${lib.optionalString diskoCfg.testMode ''
|
||||||
export IN_DISKO_TEST=1
|
export IN_DISKO_TEST=1
|
||||||
@@ -144,7 +145,7 @@ let
|
|||||||
time xargs cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
|
time xargs cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
|
||||||
|
|
||||||
${systemToInstall.config.system.build.nixos-install}/bin/nixos-install --root ${systemToInstall.config.disko.rootMountPoint} --system ${systemToInstall.config.system.build.toplevel} --keep-going --no-channel-copy -v --no-root-password --option binary-caches ""
|
${systemToInstall.config.system.build.nixos-install}/bin/nixos-install --root ${systemToInstall.config.disko.rootMountPoint} --system ${systemToInstall.config.system.build.toplevel} --keep-going --no-channel-copy -v --no-root-password --option binary-caches ""
|
||||||
umount -Rv ${systemToInstall.config.disko.rootMountPoint}
|
umount -Rv ${lib.escapeShellArg systemToInstall.config.disko.rootMountPoint}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
QEMU_OPTS = lib.concatStringsSep " " (
|
QEMU_OPTS = lib.concatStringsSep " " (
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
device,
|
||||||
|
diskoLib,
|
||||||
|
lib,
|
||||||
|
options,
|
||||||
|
parent,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
type = lib.mkOption {
|
||||||
|
type = lib.types.enum [ "bcachefs" ];
|
||||||
|
internal = true;
|
||||||
|
description = "Type.";
|
||||||
|
};
|
||||||
|
device = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = device;
|
||||||
|
description = "Device to use.";
|
||||||
|
example = "/dev/sda";
|
||||||
|
};
|
||||||
|
filesystem = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "Name of the bcachefs filesystem this partition belongs to.";
|
||||||
|
example = "main_bcachefs_filesystem";
|
||||||
|
};
|
||||||
|
# These are passed as arguments to the device corresponding to this one in the invocation of the `bcachefs format` command
|
||||||
|
# in the bcachefs_filesystem type defined in bcachefs_filesystem.nix used to format the bcachefs filesystem that this device is a part of.
|
||||||
|
extraFormatArgs = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = "Extra arguments passed to the bcachefs format command.";
|
||||||
|
example = [ "--discard" ];
|
||||||
|
};
|
||||||
|
# This value is passed to the `--label` option for the device corresponding to this one in the invocation of the `bcachefs format` command
|
||||||
|
# in the bcachefs_filesystem type defined in bcachefs_filesystem.nix used to format the bcachefs filesystem that this device is a part of.
|
||||||
|
label = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Label to use for this device.
|
||||||
|
This value is passed as the `--label` argument to the `bcachefs format` command when formatting the device.
|
||||||
|
'';
|
||||||
|
example = "group_a.sda2";
|
||||||
|
};
|
||||||
|
_parent = lib.mkOption {
|
||||||
|
internal = true;
|
||||||
|
default = parent;
|
||||||
|
};
|
||||||
|
_meta = lib.mkOption {
|
||||||
|
internal = true;
|
||||||
|
readOnly = true;
|
||||||
|
type = lib.types.functionTo diskoLib.jsonType;
|
||||||
|
# Ensures that this file's `_create` will be ran for all member devices that are part of the filesystem being created,
|
||||||
|
# before the `_create` in bcachefs_filesystem.nix is ran.
|
||||||
|
default = dev: {
|
||||||
|
deviceDependencies.bcachefs_filesystems.${config.filesystem} = [ dev ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_create = diskoLib.mkCreateOption {
|
||||||
|
inherit config options;
|
||||||
|
# The bcachefs_filesystem type defined in bcachefs_filesystem.nix will include this device when formatting and mounting the filesystem.
|
||||||
|
# The current file should not run the `bcachefs format` command. Instead, the`bcachefs format` command will be ran
|
||||||
|
# in the `_create` attribute in bcachefs_filesystem.nix, once it has collected and generated the arguments specifying the devices that should be part of the filesystem.
|
||||||
|
default = ''
|
||||||
|
# Write device arguments to temporary directory for bcachefs_filesystem.
|
||||||
|
{
|
||||||
|
printf '%s\n' '--label="${config.label}"';
|
||||||
|
${lib.concatMapStrings (args: ''printf '%s\n' '${args}';'') config.extraFormatArgs}
|
||||||
|
printf '%s\n' '${config.device}';
|
||||||
|
} >> "$disko_devices_dir/bcachefs-${lib.escapeShellArg config.filesystem}";
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
_mount = diskoLib.mkMountOption {
|
||||||
|
inherit config options;
|
||||||
|
# Empty, since mounting will be handled by the bcachefs_filesystem type defined in bcachefs_filesystem.nix.
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
_unmount = diskoLib.mkUnmountOption {
|
||||||
|
inherit config options;
|
||||||
|
# Empty, since unmounting will be handled by the bcachefs_filesystem type defined in bcachefs_filesystem.nix.
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
_config = lib.mkOption {
|
||||||
|
internal = true;
|
||||||
|
readOnly = true;
|
||||||
|
# Empty, since NixOS configuration will be handled by the bcachefs_filesystem type defined in bcachefs_filesystem.nix.
|
||||||
|
default = { };
|
||||||
|
description = "NixOS configuration.";
|
||||||
|
};
|
||||||
|
_pkgs = lib.mkOption {
|
||||||
|
internal = true;
|
||||||
|
readOnly = true;
|
||||||
|
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
||||||
|
default = pkgs: [ ];
|
||||||
|
description = "Packages.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,339 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
diskoLib,
|
||||||
|
lib,
|
||||||
|
options,
|
||||||
|
parent,
|
||||||
|
rootMountPoint,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
name = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = config._module.args.name;
|
||||||
|
description = "Name of the bcachefs filesystem.";
|
||||||
|
example = "main_bcachefs_filesystem";
|
||||||
|
};
|
||||||
|
type = lib.mkOption {
|
||||||
|
type = lib.types.enum [ "bcachefs_filesystem" ];
|
||||||
|
internal = true;
|
||||||
|
description = "Type.";
|
||||||
|
};
|
||||||
|
extraFormatArgs = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = "Extra arguments passed to the `bcachefs format` command.";
|
||||||
|
example = [
|
||||||
|
"--compression=lz4"
|
||||||
|
"--background_compression=lz4"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
mountOptions = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ "X-mount.mkdir" ];
|
||||||
|
description = ''
|
||||||
|
Options to pass to mount.
|
||||||
|
The "X-mount.mkdir" option is always automatically added.
|
||||||
|
'';
|
||||||
|
example = [
|
||||||
|
"noatime"
|
||||||
|
"verbose"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
mountpoint = lib.mkOption {
|
||||||
|
type = lib.types.nullOr diskoLib.optionTypes.absolute-pathname;
|
||||||
|
default = null;
|
||||||
|
description = "Path to mount the bcachefs filesystem to.";
|
||||||
|
example = "/";
|
||||||
|
};
|
||||||
|
uuid = lib.mkOption {
|
||||||
|
type = lib.types.strMatching "[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}";
|
||||||
|
default =
|
||||||
|
let
|
||||||
|
# Generate a deterministic but random-looking UUID based on the filesystem name
|
||||||
|
# This avoids the need for impure access to nixpkgs at evaluation time
|
||||||
|
hash = builtins.hashString "sha256" "${config.name}";
|
||||||
|
hexChars = builtins.substring 0 32 hash;
|
||||||
|
p1 = builtins.substring 0 8 hexChars;
|
||||||
|
p2 = builtins.substring 8 4 hexChars;
|
||||||
|
p3 = builtins.substring 12 4 hexChars;
|
||||||
|
p4 = builtins.substring 16 4 hexChars;
|
||||||
|
p5 = builtins.substring 20 12 hexChars;
|
||||||
|
in
|
||||||
|
"${p1}-${p2}-${p3}-${p4}-${p5}";
|
||||||
|
defaultText = "generated deterministically based on filesystem name";
|
||||||
|
example = "809b3a2b-828a-4730-95e1-75b6343e415a";
|
||||||
|
description = ''
|
||||||
|
The UUID of the bcachefs filesystem.
|
||||||
|
If not provided, a deterministic UUID will be generated based on the filesystem name.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
passwordFile = lib.mkOption {
|
||||||
|
type = lib.types.nullOr diskoLib.optionTypes.absolute-pathname;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Path to the file containing the password for encryption.
|
||||||
|
Setting this option will automatically cause the `--encrypted` option to be passed to `bcachefs format` and cause the filesystem to have encryption enabled.
|
||||||
|
'';
|
||||||
|
example = "/tmp/disk.key";
|
||||||
|
};
|
||||||
|
subvolumes = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (
|
||||||
|
lib.types.submodule (
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
name = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = config._module.args.name;
|
||||||
|
description = ''
|
||||||
|
Path of the subvolume within the filesystem.
|
||||||
|
Leading forward slashes are automatically removed.
|
||||||
|
'';
|
||||||
|
example = "subvolumes/home";
|
||||||
|
};
|
||||||
|
type = lib.mkOption {
|
||||||
|
type = lib.types.enum [ "bcachefs_subvolume" ];
|
||||||
|
default = "bcachefs_subvolume";
|
||||||
|
internal = true;
|
||||||
|
description = "Type.";
|
||||||
|
};
|
||||||
|
mountOptions = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = lib.naturalSort [
|
||||||
|
"X-mount.mkdir"
|
||||||
|
"X-mount.subdir=${lib.removePrefix "/" config.name}"
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
Options to pass to mount.
|
||||||
|
The "X-mount.mkdir" and "X-mount.subdir" options are always automatically added.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
mountpoint = lib.mkOption {
|
||||||
|
type = lib.types.nullOr diskoLib.optionTypes.absolute-pathname;
|
||||||
|
default = null;
|
||||||
|
description = "Path to mount the subvolume to.";
|
||||||
|
example = "/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
default = { };
|
||||||
|
description = "List of subvolumes to define.";
|
||||||
|
example = {
|
||||||
|
"subvolumes/root" = {
|
||||||
|
mountpoint = "/";
|
||||||
|
extraFormatArgs = [
|
||||||
|
"--compression=lz4"
|
||||||
|
"--background_compression=lz4"
|
||||||
|
];
|
||||||
|
mountOptions = [
|
||||||
|
"verbose"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
"subvolumes/home" = {
|
||||||
|
mountpoint = "/home";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_parent = lib.mkOption {
|
||||||
|
internal = true;
|
||||||
|
default = parent;
|
||||||
|
};
|
||||||
|
_meta = lib.mkOption {
|
||||||
|
internal = true;
|
||||||
|
readOnly = true;
|
||||||
|
type = lib.types.functionTo diskoLib.jsonType;
|
||||||
|
default = dev: { };
|
||||||
|
description = "Metadata";
|
||||||
|
};
|
||||||
|
_create = diskoLib.mkCreateOption {
|
||||||
|
inherit config options;
|
||||||
|
# This sets a string variable containing arguments to be passed to the `bcachefs format` command.
|
||||||
|
# This string will consist of `--label` and other arguments that correspond to the values of the `label` and `extraFormatArgs` attributes, respectively,
|
||||||
|
# from each of the bcachefs devices in this filesystem specified in the configuration.
|
||||||
|
# Then, it sets the `default` attribute to a string containing shell commands that calls the `bcachefs format` command, passing in the arguments generated, as well as a `--uuid` value.
|
||||||
|
default = ''
|
||||||
|
if ! test -s "$disko_devices_dir/bcachefs-${config.name}"; then
|
||||||
|
printf "\033[31mERROR:\033[0m No devices found for bcachefs filesystem \"${config.name}\"!\nDid you forget to add some or misspell the filesystem name?\n" >&2;
|
||||||
|
exit 1;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# Create the filesystem.
|
||||||
|
(
|
||||||
|
# Empty out $@.
|
||||||
|
set --;
|
||||||
|
# Collect devices and arguments to $@.
|
||||||
|
while IFS= read -r line; do
|
||||||
|
# Append current line as a new positional parameter
|
||||||
|
set -- "$@" "$line";
|
||||||
|
done < "$disko_devices_dir/bcachefs-${config.name}";
|
||||||
|
|
||||||
|
# Format the filesystem with all devices and arguments.
|
||||||
|
if ! blkid -o export "$(blkid -lU ${config.uuid})" | grep -q 'TYPE=bcachefs' >&2 2>&1; then
|
||||||
|
bcachefs format \
|
||||||
|
"$@" \
|
||||||
|
--uuid="${config.uuid}" \
|
||||||
|
${lib.concatStringsSep " \\\n" config.extraFormatArgs} \
|
||||||
|
${
|
||||||
|
lib.optionalString (config.passwordFile != null) ''--encrypted < "${config.passwordFile}"''
|
||||||
|
};
|
||||||
|
fi;
|
||||||
|
);
|
||||||
|
|
||||||
|
# Mount the bcachefs filesystem onto a temporary directory,
|
||||||
|
# then, create the subvolumes from inside of that directory.
|
||||||
|
${lib.optionalString (config.subvolumes != { }) ''
|
||||||
|
if blkid -o export "$(blkid -lU ${config.uuid})" | grep -q 'TYPE=bcachefs' >&2 2>&1; then
|
||||||
|
${lib.concatMapStrings (subvolume: ''
|
||||||
|
(
|
||||||
|
TEMPDIR="$(mktemp -d)";
|
||||||
|
MNTPOINT="$(mktemp -d)";
|
||||||
|
${lib.optionalString (
|
||||||
|
config.passwordFile != null
|
||||||
|
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
||||||
|
bcachefs mount \
|
||||||
|
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
||||||
|
UUID="${config.uuid}" \
|
||||||
|
"$MNTPOINT";
|
||||||
|
trap 'umount "$MNTPOINT"; rm -rf "$MNTPOINT"; rm -rf "$TEMPDIR";' EXIT;
|
||||||
|
SUBVOL_ABS_PATH="$MNTPOINT/${subvolume.name}";
|
||||||
|
# Check if it's already a subvolume (using snapshot).
|
||||||
|
if ! bcachefs subvolume snapshot "$SUBVOL_ABS_PATH" "$TEMPDIR/" >&2 2>&1; then
|
||||||
|
# It's not a subvolume, now check if it's a directory.
|
||||||
|
if ! test -d "$SUBVOL_ABS_PATH"; then
|
||||||
|
# It's not a subvolume AND not a directory, so create it.
|
||||||
|
mkdir -p -- "$(dirname -- "$SUBVOL_ABS_PATH")";
|
||||||
|
bcachefs subvolume create "$SUBVOL_ABS_PATH";
|
||||||
|
fi
|
||||||
|
fi;
|
||||||
|
)
|
||||||
|
'') (lib.attrValues config.subvolumes)}
|
||||||
|
fi;
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
_mount = diskoLib.mkMountOption {
|
||||||
|
inherit config options;
|
||||||
|
default =
|
||||||
|
let
|
||||||
|
subvolumeMounts = diskoLib.deepMergeMap (
|
||||||
|
subvolume:
|
||||||
|
lib.optionalAttrs (subvolume.mountpoint != null) {
|
||||||
|
${subvolume.mountpoint} = ''
|
||||||
|
if ! findmnt "${rootMountPoint}${subvolume.mountpoint}" >&2 2>&1; then
|
||||||
|
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
||||||
|
# necessitating running `mkdir` here.
|
||||||
|
mkdir -p "${rootMountPoint}${subvolume.mountpoint}";
|
||||||
|
${lib.optionalString (
|
||||||
|
config.passwordFile != null
|
||||||
|
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
||||||
|
bcachefs mount \
|
||||||
|
-o "${
|
||||||
|
lib.concatStringsSep "," (
|
||||||
|
lib.unique (
|
||||||
|
[
|
||||||
|
"X-mount.mkdir"
|
||||||
|
"X-mount.subdir=${lib.removePrefix "/" subvolume.name}"
|
||||||
|
]
|
||||||
|
++ subvolume.mountOptions
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}" \
|
||||||
|
UUID="${config.uuid}" \
|
||||||
|
"${rootMountPoint}${subvolume.mountpoint}";
|
||||||
|
fi;
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
) (lib.attrValues config.subvolumes);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
fs =
|
||||||
|
subvolumeMounts
|
||||||
|
// lib.optionalAttrs (config.mountpoint != null) {
|
||||||
|
${config.mountpoint} = ''
|
||||||
|
if ! findmnt "${rootMountPoint}${config.mountpoint}" >&2 2>&1; then
|
||||||
|
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
||||||
|
# necessitating running `mkdir` here.
|
||||||
|
mkdir -p "${rootMountPoint}${config.mountpoint}";
|
||||||
|
${lib.optionalString (
|
||||||
|
config.passwordFile != null
|
||||||
|
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
||||||
|
bcachefs mount \
|
||||||
|
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
||||||
|
UUID="${config.uuid}" \
|
||||||
|
"${rootMountPoint}${config.mountpoint}";
|
||||||
|
fi;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_unmount = diskoLib.mkUnmountOption {
|
||||||
|
inherit config options;
|
||||||
|
default =
|
||||||
|
let
|
||||||
|
subvolumeMounts = lib.concatMapAttrs (
|
||||||
|
_: subvolume:
|
||||||
|
lib.optionalAttrs (subvolume.mountpoint != null) {
|
||||||
|
${subvolume.mountpoint} = ''
|
||||||
|
if findmnt "UUID=${config.uuid}" "${rootMountPoint}${subvolume.mountpoint}" >&2 2>&1; then
|
||||||
|
umount "${rootMountPoint}${subvolume.mountpoint}";
|
||||||
|
fi;
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
) config.subvolumes;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
fs =
|
||||||
|
subvolumeMounts
|
||||||
|
// lib.optionalAttrs (config.mountpoint != null) {
|
||||||
|
${config.mountpoint} = ''
|
||||||
|
if findmnt "UUID=${config.uuid}" "${rootMountPoint}${config.mountpoint}" >&2 2>&1; then
|
||||||
|
umount "${rootMountPoint}${config.mountpoint}";
|
||||||
|
fi;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_config = lib.mkOption {
|
||||||
|
internal = true;
|
||||||
|
readOnly = true;
|
||||||
|
default =
|
||||||
|
(lib.optional (config.mountpoint != null) {
|
||||||
|
fileSystems.${config.mountpoint} = {
|
||||||
|
device = "UUID=${config.uuid}";
|
||||||
|
fsType = "bcachefs";
|
||||||
|
options = lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions);
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
++ (map (subvolume: {
|
||||||
|
fileSystems.${subvolume.mountpoint} = {
|
||||||
|
device = "UUID=${config.uuid}";
|
||||||
|
fsType = "bcachefs";
|
||||||
|
options = lib.unique (
|
||||||
|
[
|
||||||
|
"X-mount.mkdir"
|
||||||
|
"X-mount.subdir=${lib.removePrefix "/" subvolume.name}"
|
||||||
|
]
|
||||||
|
++ subvolume.mountOptions
|
||||||
|
);
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
}) (lib.filter (subvolume: subvolume.mountpoint != null) (lib.attrValues config.subvolumes)));
|
||||||
|
description = "NixOS configuration.";
|
||||||
|
};
|
||||||
|
_pkgs = lib.mkOption {
|
||||||
|
internal = true;
|
||||||
|
readOnly = true;
|
||||||
|
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
||||||
|
default = pkgs: [
|
||||||
|
pkgs.bcachefs-tools
|
||||||
|
pkgs.util-linux
|
||||||
|
];
|
||||||
|
description = "Packages.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
+2
-2
@@ -160,7 +160,7 @@ in
|
|||||||
(
|
(
|
||||||
MNTPOINT=$(mktemp -d)
|
MNTPOINT=$(mktemp -d)
|
||||||
mount ${device} "$MNTPOINT" -o subvol=/
|
mount ${device} "$MNTPOINT" -o subvol=/
|
||||||
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
trap 'umount "$MNTPOINT"; rm -rf "$MNTPOINT"' EXIT
|
||||||
${swapCreate "$MNTPOINT" config.swap}
|
${swapCreate "$MNTPOINT" config.swap}
|
||||||
)
|
)
|
||||||
''}
|
''}
|
||||||
@@ -168,7 +168,7 @@ in
|
|||||||
(
|
(
|
||||||
MNTPOINT=$(mktemp -d)
|
MNTPOINT=$(mktemp -d)
|
||||||
mount "${config.device}" "$MNTPOINT" -o subvol=/
|
mount "${config.device}" "$MNTPOINT" -o subvol=/
|
||||||
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
trap 'umount "$MNTPOINT"; rm -rf "$MNTPOINT"' EXIT
|
||||||
SUBVOL_ABS_PATH="$MNTPOINT/${subvol.name}"
|
SUBVOL_ABS_PATH="$MNTPOINT/${subvol.name}"
|
||||||
mkdir -p "$(dirname "$SUBVOL_ABS_PATH")"
|
mkdir -p "$(dirname "$SUBVOL_ABS_PATH")"
|
||||||
if ! btrfs subvolume show "$SUBVOL_ABS_PATH" > /dev/null 2>&1; then
|
if ! btrfs subvolume show "$SUBVOL_ABS_PATH" > /dev/null 2>&1; then
|
||||||
|
|||||||
@@ -106,6 +106,7 @@
|
|||||||
pkgs.gnugrep
|
pkgs.gnugrep
|
||||||
]
|
]
|
||||||
++ (
|
++ (
|
||||||
|
# TODO add many more
|
||||||
if (config.format == "xfs") then
|
if (config.format == "xfs") then
|
||||||
[ pkgs.xfsprogs ]
|
[ pkgs.xfsprogs ]
|
||||||
else if (config.format == "btrfs") then
|
else if (config.format == "btrfs") then
|
||||||
@@ -122,8 +123,6 @@
|
|||||||
[ pkgs.bcachefs-tools ]
|
[ pkgs.bcachefs-tools ]
|
||||||
else if (config.format == "f2fs") then
|
else if (config.format == "f2fs") then
|
||||||
[ pkgs.f2fs-tools ]
|
[ pkgs.f2fs-tools ]
|
||||||
else if (config.format == "exfat") then
|
|
||||||
[ pkgs.exfatprogs ]
|
|
||||||
else
|
else
|
||||||
[ ]
|
[ ]
|
||||||
);
|
);
|
||||||
|
|||||||
+2
-2
@@ -204,7 +204,7 @@ in
|
|||||||
${lib.optionalString (hp.config.mbrPartitionType != null) ''
|
${lib.optionalString (hp.config.mbrPartitionType != null) ''
|
||||||
sfdisk --label-nested dos --part-type "${parent.device}" ${(toString partition.config._index)} ${hp.config.mbrPartitionType}
|
sfdisk --label-nested dos --part-type "${parent.device}" ${(toString partition.config._index)} ${hp.config.mbrPartitionType}
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle --timeout 120
|
||||||
''}
|
''}
|
||||||
${lib.optionalString hp.config.mbrBootableFlag ''
|
${lib.optionalString hp.config.mbrBootableFlag ''
|
||||||
sfdisk --label-nested dos --activate "${parent.device}" ${(toString partition.config._index)}
|
sfdisk --label-nested dos --activate "${parent.device}" ${(toString partition.config._index)}
|
||||||
@@ -288,7 +288,7 @@ in
|
|||||||
# ensure /dev/disk/by-path/..-partN exists before continuing
|
# ensure /dev/disk/by-path/..-partN exists before continuing
|
||||||
partprobe "${config.device}" || : # sometimes partprobe fails, but the partitions are still up2date
|
partprobe "${config.device}" || : # sometimes partprobe fails, but the partitions are still up2date
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle --timeout 120
|
||||||
''
|
''
|
||||||
) sortedPartitions}
|
) sortedPartitions}
|
||||||
|
|
||||||
|
|||||||
+11
-4
@@ -132,13 +132,20 @@ in
|
|||||||
default = ''
|
default = ''
|
||||||
if ! blkid "${config.device}" >/dev/null || ! (blkid "${config.device}" -o export | grep -q '^TYPE='); then
|
if ! blkid "${config.device}" >/dev/null || ! (blkid "${config.device}" -o export | grep -q '^TYPE='); then
|
||||||
${lib.optionalString config.askPassword ''
|
${lib.optionalString config.askPassword ''
|
||||||
|
promptSecret() {
|
||||||
|
prompt=$1
|
||||||
|
var=$2
|
||||||
|
|
||||||
|
echo -n "$prompt"
|
||||||
|
IFS= read -r -s "$var"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
askPassword() {
|
askPassword() {
|
||||||
if [ -z ''${IN_DISKO_TEST+x} ]; then
|
if [ -z ''${IN_DISKO_TEST+x} ]; then
|
||||||
set +x
|
set +x
|
||||||
echo "Enter password for ${config.device}: "
|
promptSecret "Enter password for ${config.device}: " password
|
||||||
IFS= read -r -s password
|
promptSecret "Enter password for ${config.device} again to be safe: " password_check
|
||||||
echo "Enter password for ${config.device} again to be safe: "
|
|
||||||
IFS= read -r -s password_check
|
|
||||||
export password
|
export password
|
||||||
[ "$password" = "$password_check" ]
|
[ "$password" = "$password_check" ]
|
||||||
set -x
|
set -x
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@
|
|||||||
"''${disk_devices[@]}"
|
"''${disk_devices[@]}"
|
||||||
partprobe "/dev/md/${config.name}"
|
partprobe "/dev/md/${config.name}"
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle --timeout=120
|
||||||
# for some reason mdadm devices spawn with an existing partition table, so we need to wipe it
|
# for some reason mdadm devices spawn with an existing partition table, so we need to wipe it
|
||||||
sgdisk --zap-all "/dev/md/${config.name}"
|
sgdisk --zap-all "/dev/md/${config.name}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+4
-2
@@ -55,6 +55,8 @@
|
|||||||
fs-type = lib.mkOption {
|
fs-type = lib.mkOption {
|
||||||
type = lib.types.nullOr (
|
type = lib.types.nullOr (
|
||||||
lib.types.enum [
|
lib.types.enum [
|
||||||
|
# @todo Check if this is needed
|
||||||
|
"bcachefs"
|
||||||
"btrfs"
|
"btrfs"
|
||||||
"ext2"
|
"ext2"
|
||||||
"ext3"
|
"ext3"
|
||||||
@@ -147,7 +149,7 @@
|
|||||||
# ensure /dev/disk/by-path/..-partN exists before continuing
|
# ensure /dev/disk/by-path/..-partN exists before continuing
|
||||||
partprobe "${config.device}"
|
partprobe "${config.device}"
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle --timeout 120
|
||||||
${lib.optionalString partition.bootable ''
|
${lib.optionalString partition.bootable ''
|
||||||
parted -s "${config.device}" -- set ${toString partition._index} boot on
|
parted -s "${config.device}" -- set ${toString partition._index} boot on
|
||||||
''}
|
''}
|
||||||
@@ -157,7 +159,7 @@
|
|||||||
# ensure further operations can detect new partitions
|
# ensure further operations can detect new partitions
|
||||||
partprobe "${config.device}"
|
partprobe "${config.device}"
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle --timeout 120
|
||||||
'') config.partitions
|
'') config.partitions
|
||||||
)}
|
)}
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
zvol_wait
|
zvol_wait
|
||||||
partprobe "/dev/zvol/${config._parent.name}/${config.name}"
|
partprobe "/dev/zvol/${config._parent.name}/${config.name}"
|
||||||
udevadm trigger --subsystem-match=block
|
udevadm trigger --subsystem-match=block
|
||||||
udevadm settle
|
udevadm settle --timeout=120
|
||||||
fi
|
fi
|
||||||
${lib.optionalString (config.content != null) config.content._create}
|
${lib.optionalString (config.content != null) config.content._create}
|
||||||
'';
|
'';
|
||||||
|
|||||||
+18
-9
@@ -8,6 +8,7 @@
|
|||||||
nixos-install-tools,
|
nixos-install-tools,
|
||||||
binlore,
|
binlore,
|
||||||
diskoVersion,
|
diskoVersion,
|
||||||
|
stdenv,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
@@ -20,20 +21,28 @@ let
|
|||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin $out/share/disko
|
mkdir -p $out/bin $out/share/disko
|
||||||
cp -r install-cli.nix cli.nix default.nix disk-deactivate lib $out/share/disko
|
cp -r install-cli.nix cli.nix default.nix disk-deactivate lib $out/share/disko
|
||||||
|
set -x
|
||||||
|
|
||||||
for i in disko disko-install; do
|
scripts=(disko)
|
||||||
|
${lib.optionalString (!stdenv.isDarwin) ''
|
||||||
|
scripts+=(disko-install)
|
||||||
|
''}
|
||||||
|
|
||||||
|
for i in "''${scripts[@]}"; do
|
||||||
sed -e "s|libexec_dir=\".*\"|libexec_dir=\"$out/share/disko\"|" "$i" > "$out/bin/$i"
|
sed -e "s|libexec_dir=\".*\"|libexec_dir=\"$out/share/disko\"|" "$i" > "$out/bin/$i"
|
||||||
chmod 755 "$out/bin/$i"
|
chmod 755 "$out/bin/$i"
|
||||||
wrapProgram "$out/bin/$i" \
|
wrapProgram "$out/bin/$i" \
|
||||||
--set DISKO_VERSION "${diskoVersion}" \
|
--set DISKO_VERSION "${diskoVersion}" \
|
||||||
|
--prefix NIX_PATH : "nixpkgs=${path}" \
|
||||||
--prefix PATH : ${
|
--prefix PATH : ${
|
||||||
lib.makeBinPath [
|
lib.makeBinPath (
|
||||||
nix
|
[
|
||||||
coreutils
|
nix
|
||||||
nixos-install-tools
|
coreutils
|
||||||
]
|
]
|
||||||
} \
|
++ lib.optional (!stdenv.isDarwin) nixos-install-tools
|
||||||
--prefix NIX_PATH : "nixpkgs=${path}"
|
)
|
||||||
|
}
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
# Otherwise resholve thinks that disko and disko-install might be able to execute their arguments
|
# Otherwise resholve thinks that disko and disko-install might be able to execute their arguments
|
||||||
@@ -46,7 +55,7 @@ let
|
|||||||
homepage = "https://github.com/nix-community/disko";
|
homepage = "https://github.com/nix-community/disko";
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = with maintainers; [ lassulus ];
|
maintainers = with maintainers; [ lassulus ];
|
||||||
platforms = platforms.linux;
|
platforms = platforms.unix;
|
||||||
mainProgram = finalAttrs.name;
|
mainProgram = finalAttrs.name;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
+115
-6
@@ -6,12 +6,121 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
name = "bcachefs";
|
name = "bcachefs";
|
||||||
disko-config = ../example/bcachefs.nix;
|
disko-config = ../example/bcachefs.nix;
|
||||||
extraTestScript = ''
|
enableOCR = true;
|
||||||
machine.succeed("mountpoint /");
|
bootCommands = ''
|
||||||
machine.succeed("lsblk >&2");
|
machine.wait_for_text("enter passphrase for /");
|
||||||
|
machine.send_chars("secretsecret\n");
|
||||||
|
machine.wait_for_text("enter passphrase for /home");
|
||||||
|
machine.send_chars("secretsecret\n");
|
||||||
|
machine.wait_for_text("enter passphrase for /nix");
|
||||||
|
machine.send_chars("secretsecret\n");
|
||||||
'';
|
'';
|
||||||
# so that the installer boots with a bcachefs enabled kernel
|
extraSystemConfig = {
|
||||||
extraInstallerConfig = {
|
environment.systemPackages = [
|
||||||
boot.supportedFilesystems = [ "bcachefs" ];
|
pkgs.jq
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
extraTestScript = ''
|
||||||
|
# Print debug information.
|
||||||
|
machine.succeed("ls -la /subvolumes >&2");
|
||||||
|
machine.succeed("lsblk >&2");
|
||||||
|
machine.succeed("lsblk -f >&2");
|
||||||
|
machine.succeed("mount >&2");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 >&2");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vdd1 >&2");
|
||||||
|
machine.succeed("findmnt --json >&2");
|
||||||
|
|
||||||
|
# Verify subvolume structure.
|
||||||
|
machine.succeed("test -d /subvolumes/root");
|
||||||
|
machine.succeed("test -d /subvolumes/home");
|
||||||
|
machine.succeed("test -d /subvolumes/home/user");
|
||||||
|
machine.succeed("test -d /subvolumes/nix");
|
||||||
|
machine.succeed("test -d /subvolumes/test");
|
||||||
|
machine.fail("test -d /subvolumes/non-existent");
|
||||||
|
|
||||||
|
# Verify existence of mountpoints.
|
||||||
|
machine.succeed("mountpoint /");
|
||||||
|
machine.succeed("mountpoint /home");
|
||||||
|
machine.succeed("mountpoint /nix");
|
||||||
|
machine.succeed("mountpoint /home/Documents");
|
||||||
|
machine.fail("mountpoint /non-existent");
|
||||||
|
|
||||||
|
# Verify device membership and labels.
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Devices:' | grep -q '3'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vdd1 | grep 'Devices:' | grep -q '1'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'vdb2'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'vdc1'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'vdd1'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vdd1 | grep 'Label:' | grep -q 'vde1'");
|
||||||
|
machine.fail("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'non-existent'");
|
||||||
|
|
||||||
|
# @todo Verify format arguments.
|
||||||
|
|
||||||
|
# Verify mount options from configuration.
|
||||||
|
machine.succeed("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| select(.target == "/") \
|
||||||
|
| .options \
|
||||||
|
| split(",") \
|
||||||
|
| contains(["verbose", "compression=lz4", "background_compression=lz4"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.succeed("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| .. \
|
||||||
|
| select(.target? == "/home/Documents") \
|
||||||
|
| .options \
|
||||||
|
| split(",") \
|
||||||
|
| contains(["verbose"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.fail("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| select(.target == "/") \
|
||||||
|
| .options \
|
||||||
|
| split(",") \
|
||||||
|
| contains(["non-existent"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
# Verify device composition of filesystems.
|
||||||
|
machine.succeed("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| select(.target == "/") \
|
||||||
|
| .source | split(":") \
|
||||||
|
| contains(["/dev/vda2", "/dev/vdb1", "/dev/vdc1"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.succeed("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| .. \
|
||||||
|
| select(.target? == "/home/Documents") \
|
||||||
|
| .source \
|
||||||
|
| contains("/dev/vdd1") \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.fail("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| select(.target == "/") \
|
||||||
|
| .source | split(":") \
|
||||||
|
| contains(["/dev/non-existent"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
+1
-1
@@ -19,7 +19,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 /exfat_on_lvm");
|
machine.succeed("mountpoint /ext4_on_lvm");
|
||||||
'';
|
'';
|
||||||
extraSystemConfig = {
|
extraSystemConfig = {
|
||||||
imports = [
|
imports = [
|
||||||
|
|||||||
+2
-2
@@ -19,10 +19,10 @@ 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 /exfat_on_lvm");
|
machine.succeed("mountpoint /ext4_on_lvm");
|
||||||
|
|
||||||
|
|
||||||
machine.succeed("test -e /exfat_on_lvm/file-from-postMountHook");
|
machine.succeed("test -e /ext4_on_lvm/file-from-postMountHook");
|
||||||
'';
|
'';
|
||||||
extraInstallerConfig = {
|
extraInstallerConfig = {
|
||||||
boot.kernelModules = [
|
boot.kernelModules = [
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ pkgs.nixosTest {
|
|||||||
permission = machine.succeed("stat -c %a /tmp/age.key").strip()
|
permission = machine.succeed("stat -c %a /tmp/age.key").strip()
|
||||||
assert permission == "600", f"expected permission 600 on /tmp/age.key, got {permission}"
|
assert permission == "600", f"expected permission 600 on /tmp/age.key, got {permission}"
|
||||||
|
|
||||||
|
# Some distros like to automount disks with spaces
|
||||||
|
machine.succeed('mkdir -p "/mnt/with spaces" && mkfs.ext4 /dev/vdb && mount /dev/vdb "/mnt/with spaces"')
|
||||||
machine.succeed("${disko}/bin/disko-install --disk main /dev/vdb --extra-files /tmp/age.key /var/lib/secrets/age.key --flake ${../..}#testmachine")
|
machine.succeed("${disko}/bin/disko-install --disk main /dev/vdb --extra-files /tmp/age.key /var/lib/secrets/age.key --flake ${../..}#testmachine")
|
||||||
# test idempotency
|
# test idempotency
|
||||||
machine.succeed("${disko}/bin/disko-install --mode mount --disk main /dev/vdb --flake ${../..}#testmachine")
|
machine.succeed("${disko}/bin/disko-install --mode mount --disk main /dev/vdb --flake ${../..}#testmachine")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
documentation.enable = false;
|
documentation.enable = false;
|
||||||
system.stateVersion = config.system.nixos.version;
|
system.stateVersion = config.system.nixos.release;
|
||||||
disko.checkScripts = true;
|
disko.checkScripts = true;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
documentation.enable = false;
|
documentation.enable = false;
|
||||||
system.stateVersion = config.system.nixos.version;
|
system.stateVersion = config.system.nixos.release;
|
||||||
disko.memSize = 2048;
|
disko.memSize = 2048;
|
||||||
disko.checkScripts = true;
|
disko.checkScripts = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user