mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13:28 +01:00
Compare commits
58
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9067124b0d | ||
|
|
af087d076d | ||
|
|
3f65d72ca6 | ||
|
|
d377b56993 | ||
|
|
6f4cf5abbe | ||
|
|
fec5efebfc | ||
|
|
3a9450b26e | ||
|
|
67ff9807dd | ||
|
|
ddef55ae5f | ||
|
|
4f554162ff | ||
|
|
146f45bee0 | ||
|
|
c8a0e78d86 | ||
|
|
31fe7eda26 | ||
|
|
a5c4f2ab72 | ||
|
|
bafad29f89 | ||
|
|
49c1bc1b34 | ||
|
|
4073ff2f48 | ||
|
|
f64ab1525b | ||
|
|
8246829f2e | ||
|
|
545aba0296 | ||
|
|
3db2f04765 | ||
|
|
d5ad4485e6 | ||
|
|
2bf3421f7f | ||
|
|
79264292b7 | ||
|
|
16b74a1e30 | ||
|
|
da6109c917 | ||
|
|
83c4da299c | ||
|
|
8fd2d6c750 | ||
|
|
7f1857b315 | ||
|
|
dfa4d1b9c3 | ||
|
|
17d08c65c2 | ||
|
|
6d06f63fc0 | ||
|
|
d74db625a5 | ||
|
|
a4f7deb49f | ||
|
|
58d6e5a83f | ||
|
|
a894f2811e | ||
|
|
df522e787f | ||
|
|
58e72c6ec2 | ||
|
|
cec44d77d9 | ||
|
|
ec7c109a4f | ||
|
|
490c0d6bd1 | ||
|
|
85555d27de | ||
|
|
6ca7c94d6a | ||
|
|
14afb10129 | ||
|
|
a956a7c255 | ||
|
|
6bb82b77ce | ||
|
|
06fb9283ca | ||
|
|
69265ccde5 | ||
|
|
cbc1f418d0 | ||
|
|
aa5d53aee8 | ||
|
|
c7e0b00007 | ||
|
|
aba0ae38df | ||
|
|
b5cfd59e9a | ||
|
|
c4fe2d108b | ||
|
|
78d6a1365c | ||
|
|
8d78963819 | ||
|
|
b5d1320ebc | ||
|
|
7b63642358 |
No files matched your search
@@ -1,22 +0,0 @@
|
|||||||
name: "Publish a flake to flakestry"
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v?[0-9]+.[0-9]+.[0-9]+"
|
|
||||||
- "v?[0-9]+.[0-9]+"
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
tag:
|
|
||||||
description: "The existing tag to publish"
|
|
||||||
type: "string"
|
|
||||||
required: true
|
|
||||||
jobs:
|
|
||||||
publish-flake:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
id-token: "write"
|
|
||||||
contents: "read"
|
|
||||||
steps:
|
|
||||||
- uses: flakestry/flakestry-publish@main
|
|
||||||
with:
|
|
||||||
version: "${{ inputs.tag || github.ref_name }}"
|
|
||||||
@@ -11,11 +11,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: cachix/install-nix-action@v31
|
uses: cachix/install-nix-action@v31
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
uses: DeterminateSystems/update-flake-lock@v24
|
uses: DeterminateSystems/update-flake-lock@v27
|
||||||
with:
|
with:
|
||||||
pr-labels: |
|
pr-labels: |
|
||||||
merge-queue
|
merge-queue
|
||||||
@@ -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
|
||||||
@@ -12,6 +12,43 @@ way to help us fix issues quickly. Check out
|
|||||||
For more information on how to run and debug tests, check out
|
For more information on how to run and debug tests, check out
|
||||||
[Running and debugging tests](./docs/testing.md).
|
[Running and debugging tests](./docs/testing.md).
|
||||||
|
|
||||||
|
## Finding and Running Tests
|
||||||
|
|
||||||
|
### Listing All Available Tests
|
||||||
|
|
||||||
|
To see all available tests in the project:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# List all test files
|
||||||
|
ls tests/*.nix | grep -v default.nix
|
||||||
|
|
||||||
|
# List all tests using nix eval
|
||||||
|
nix eval --apply builtins.attrNames .#checks.x86_64-linux --json | jq -r '.[]' | sort
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run all tests and checks
|
||||||
|
nix-fast-build
|
||||||
|
|
||||||
|
# Run a specific test by name
|
||||||
|
nix build .#checks.x86_64-linux.simple-efi -L
|
||||||
|
|
||||||
|
# Run tests matching a pattern
|
||||||
|
nix eval --apply 'checks: builtins.filter (name: builtins.match ".*luks.*" name != null) (builtins.attrNames checks)' .#checks.x86_64-linux --json | jq -r '.[]' | xargs -I {} echo nix build .#checks.x86_64-linux.{} -L
|
||||||
|
```
|
||||||
|
|
||||||
|
### Understanding Test Structure
|
||||||
|
|
||||||
|
Each test file in `tests/` corresponds to an example configuration in `example/`:
|
||||||
|
- `tests/simple-efi.nix` tests `example/simple-efi.nix`
|
||||||
|
- `tests/luks-lvm.nix` tests `example/luks-lvm.nix`
|
||||||
|
- etc.
|
||||||
|
|
||||||
|
Tests use NixOS's `make-test-python.nix` framework to create VMs that actually partition disks and verify the configurations work correctly.
|
||||||
|
|
||||||
|
|
||||||
## How to find issues to work on
|
## How to find issues to work on
|
||||||
|
|
||||||
If you're looking for a low-hanging fruit, check out
|
If you're looking for a low-hanging fruit, check out
|
||||||
|
|||||||
@@ -17,11 +17,14 @@ let
|
|||||||
|
|
||||||
hasDiskoFile = diskoFile != null;
|
hasDiskoFile = diskoFile != null;
|
||||||
|
|
||||||
|
hasDiskoConfigFlake =
|
||||||
|
hasDiskoFile || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
|
||||||
|
|
||||||
diskoAttr =
|
diskoAttr =
|
||||||
(
|
(
|
||||||
if noDeps then
|
if noDeps then
|
||||||
(
|
(
|
||||||
if hasDiskoFile then
|
if hasDiskoFile || hasDiskoConfigFlake then
|
||||||
{
|
{
|
||||||
destroy = "_cliDestroyNoDeps";
|
destroy = "_cliDestroyNoDeps";
|
||||||
format = "_cliFormatNoDeps";
|
format = "_cliFormatNoDeps";
|
||||||
@@ -50,7 +53,7 @@ let
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
(
|
(
|
||||||
if hasDiskoFile then
|
if hasDiskoFile || hasDiskoConfigFlake then
|
||||||
{
|
{
|
||||||
destroy = "_cliDestroy";
|
destroy = "_cliDestroy";
|
||||||
format = "_cliFormat";
|
format = "_cliFormat";
|
||||||
@@ -79,9 +82,6 @@ let
|
|||||||
}
|
}
|
||||||
).${mode};
|
).${mode};
|
||||||
|
|
||||||
hasDiskoConfigFlake =
|
|
||||||
hasDiskoFile || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
|
|
||||||
|
|
||||||
hasDiskoModuleFlake = lib.hasAttrByPath [
|
hasDiskoModuleFlake = lib.hasAttrByPath [
|
||||||
"nixosConfigurations"
|
"nixosConfigurations"
|
||||||
flakeAttr
|
flakeAttr
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ fi
|
|||||||
echo "disko version $DISKO_VERSION"
|
echo "disko version $DISKO_VERSION"
|
||||||
|
|
||||||
nixBuild() {
|
nixBuild() {
|
||||||
if command -v nom-build > /dev/null; then
|
if command -v nom-build > /dev/null && [ -t 1 ]; then
|
||||||
nom-build "$@"
|
nom-build "$@"
|
||||||
else
|
else
|
||||||
nix-build "$@"
|
nix-build "$@"
|
||||||
|
|||||||
+31
-6
@@ -164,7 +164,7 @@ cleanupMountPoint() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nixBuild() {
|
nixBuild() {
|
||||||
if command -v nom-build > /dev/null; then
|
if command -v nom-build > /dev/null && [ -t 1 ]; then
|
||||||
nom-build "$@"
|
nom-build "$@"
|
||||||
else
|
else
|
||||||
nix-build "$@"
|
nix-build "$@"
|
||||||
@@ -198,10 +198,24 @@ main() {
|
|||||||
flakeAttr="${BASH_REMATCH[2]}"
|
flakeAttr="${BASH_REMATCH[2]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -e "$flake" ]]; then
|
# Resolve flake to nix store path to respect git tracking
|
||||||
flake=$(realpath "$flake")
|
if ! flake_metadata=$(nix flake metadata --json "${nix_args[@]}" "$flake" 2>&1); then
|
||||||
|
echo "Failed to resolve flake metadata for: $flake" >&2
|
||||||
|
echo "$flake_metadata" >&2
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Extract the "path" field from JSON using sed
|
||||||
|
flake_path=$(echo "$flake_metadata" | sed -nE 's/.*"path": ?"([^"]+)".*/\1/p')
|
||||||
|
|
||||||
|
if [[ -z "$flake_path" ]]; then
|
||||||
|
echo "Failed to get store path from flake metadata" >&2
|
||||||
|
echo "$flake_metadata" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
flake="$flake_path"
|
||||||
|
|
||||||
if [[ -z ${flakeAttr-} ]]; then
|
if [[ -z ${flakeAttr-} ]]; then
|
||||||
echo "Please specify the name of the NixOS configuration to be installed, as a URI fragment in the flake-uri." >&2
|
echo "Please specify the name of the NixOS configuration to be installed, as a URI fragment in the flake-uri." >&2
|
||||||
echo 'For example, to use the output nixosConfigurations.foo from the flake.nix, append "#foo" to the flake-uri.' >&2
|
echo 'For example, to use the output nixosConfigurations.foo from the flake.nix, append "#foo" to the flake-uri.' >&2
|
||||||
@@ -215,7 +229,7 @@ main() {
|
|||||||
trap cleanupMountPoint EXIT
|
trap cleanupMountPoint EXIT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
outputs=$(nixBuild "${libexec_dir}"/install-cli.nix \
|
if ! outputs=$(nixBuild "${libexec_dir}"/install-cli.nix \
|
||||||
"${nix_args[@]}" \
|
"${nix_args[@]}" \
|
||||||
--no-out-link \
|
--no-out-link \
|
||||||
--impure \
|
--impure \
|
||||||
@@ -227,9 +241,20 @@ main() {
|
|||||||
--argstr extraSystemConfig "$extraSystemConfig" \
|
--argstr extraSystemConfig "$extraSystemConfig" \
|
||||||
-A installToplevel \
|
-A installToplevel \
|
||||||
-A closureInfo \
|
-A closureInfo \
|
||||||
-A "$diskoAttr")
|
-A "$diskoAttr"); then
|
||||||
|
echo "Failed to build NixOS configuration" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
IFS=$'\n' mapfile -t artifacts <<<"$outputs"
|
IFS=$'\n' mapfile -t artifacts <<<"$outputs"
|
||||||
|
|
||||||
|
if [[ ${#artifacts[@]} -ne 3 ]]; then
|
||||||
|
echo "Expected 3 build outputs, got ${#artifacts[@]}" >&2
|
||||||
|
echo "Outputs received:" >&2
|
||||||
|
printf '%s\n' "${artifacts[@]}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
nixos_system=${artifacts[0]}
|
nixos_system=${artifacts[0]}
|
||||||
closure_info=${artifacts[1]}
|
closure_info=${artifacts[1]}
|
||||||
disko_script=${artifacts[2]}
|
disko_script=${artifacts[2]}
|
||||||
@@ -256,7 +281,7 @@ main() {
|
|||||||
if [[ ! -f "${mountPoint}/nix/var/nix/db/db.sqlite" ]]; then
|
if [[ ! -f "${mountPoint}/nix/var/nix/db/db.sqlite" ]]; then
|
||||||
echo "Copying store paths" >&2
|
echo "Copying store paths" >&2
|
||||||
mkdir -p "${mountPoint}/nix/store"
|
mkdir -p "${mountPoint}/nix/store"
|
||||||
xargs cp --recursive --target "${mountPoint}/nix/store" < "${closure_info}/store-paths"
|
xargs xcp --recursive --target-directory "${mountPoint}/nix/store" < "${closure_info}/store-paths"
|
||||||
echo "Loading nix database" >&2
|
echo "Loading nix database" >&2
|
||||||
NIX_STATE_DIR=${mountPoint}/nix/var/nix nix-store --load-db < "${closure_info}/registration"
|
NIX_STATE_DIR=${mountPoint}/nix/var/nix nix-store --load-db < "${closure_info}/registration"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+74
-8
@@ -1,11 +1,9 @@
|
|||||||
# Generating Disk Images with Secrets Included using Disko
|
# Generating Disk Images with Secrets Included using Disko
|
||||||
|
|
||||||
Using Disko on NixOS allows you to efficiently create `.raw` VM images from a
|
Using Disko on NixOS allows you to efficiently create `.raw` disk images from a system configuration.
|
||||||
system configuration. The generated image can be used as a VM or directly
|
Follow the steps below to generate disk images:
|
||||||
written to a physical drive to create a bootable disk. Follow the steps below to
|
|
||||||
generate disk images:
|
|
||||||
|
|
||||||
## Generating the `.raw` VM Image
|
## Generating the `.raw` Image
|
||||||
|
|
||||||
1. **Create a NixOS configuration that includes the disko and the disk
|
1. **Create a NixOS configuration that includes the disko and the disk
|
||||||
configuration of your choice**
|
configuration of your choice**
|
||||||
@@ -24,16 +22,29 @@ In the this example we create a flake containing a nixos configuration for
|
|||||||
disko.inputs.nixpkgs.follows = "nixpkgs";
|
disko.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, disko, nixpkgs }: {
|
outputs = { self, disko, nixpkgs, ... }: {
|
||||||
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
|
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
# You can get this file from here: https://github.com/nix-community/disko/blob/master/example/simple-efi.nix
|
# You can get this file from here: https://github.com/nix-community/disko/blob/master/example/simple-efi.nix
|
||||||
./simple-efi.nix
|
./simple-efi.nix
|
||||||
disko.nixosModules.disko
|
disko.nixosModules.disko
|
||||||
({ config, ... }: {
|
({ config, modulesPath, ... }: {
|
||||||
|
imports = [
|
||||||
|
# include this line to boot to boot the image inside a VM
|
||||||
|
# "${modulesPath}/profiles/qemu-guest.nix"
|
||||||
|
# On other hardware, you may need a hardware-configuration.nix as generated by nixos-generate-config or use nixos-facter (https://github.com/numtide/nixos-facter)
|
||||||
|
# ./hardware-configuration.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
# Optional. Useful for testing
|
||||||
|
# users.users.root.initialPassword = "root";
|
||||||
|
|
||||||
|
boot.loader.grub.efiSupport = lib.mkDefault true;
|
||||||
|
boot.loader.grub.efiInstallAsRemovable = lib.mkDefault true;
|
||||||
|
|
||||||
# shut up state version warning
|
# shut up state version warning
|
||||||
system.stateVersion = config.system.nixos.version;
|
system.stateVersion = config.system.nixos.release;
|
||||||
# Adjust this to your liking.
|
# Adjust this to your liking.
|
||||||
# WARNING: if you set a too low value the image might be not big enough to contain the nixos installation
|
# WARNING: if you set a too low value the image might be not big enough to contain the nixos installation
|
||||||
disko.devices.disk.main.imageSize = "10G";
|
disko.devices.disk.main.imageSize = "10G";
|
||||||
@@ -141,3 +152,58 @@ In the this example we create a flake containing a nixos configuration for
|
|||||||
|
|
||||||
By following these instructions and understanding the process, you can smoothly
|
By following these instructions and understanding the process, you can smoothly
|
||||||
generate disk images with Disko for your NixOS system configurations.
|
generate disk images with Disko for your NixOS system configurations.
|
||||||
|
|
||||||
|
## Test the image inside a VM
|
||||||
|
|
||||||
|
Make sure you uncommented the `"${modulesPath}/profiles/qemu-guest.nix"` import in the example above!
|
||||||
|
|
||||||
|
Write the following script to `qemu.nix`. Note that it expects an UEFI compatible image!
|
||||||
|
|
||||||
|
```
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
writeShellApplication {
|
||||||
|
name = "test-image";
|
||||||
|
runtimeInputs = [ qemu ];
|
||||||
|
text = ''
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: $0 <path-to-boot-image>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
tmpFile=$(mktemp /tmp/test-image.XXXXXX)
|
||||||
|
trap 'rm -f $tmpFile' EXIT
|
||||||
|
cp "$1" "$tmpFile"
|
||||||
|
qemu-system-x86_64 \
|
||||||
|
-enable-kvm \
|
||||||
|
-m 2G \
|
||||||
|
-cpu max \
|
||||||
|
-smp 2 \
|
||||||
|
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
|
||||||
|
-device virtio-net-pci,netdev=net0 \
|
||||||
|
-drive if=pflash,format=raw,readonly=on,file=${OVMF.firmware} \
|
||||||
|
-drive if=pflash,format=raw,readonly=on,file=${OVMF.variables} \
|
||||||
|
-drive "if=virtio,format=raw,file=$tmpFile"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This command will run a qemu vm with your image:
|
||||||
|
|
||||||
|
```
|
||||||
|
$(nix-build ./qemu.nix)/bin/test-image ./main.raw
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace `main.raw` with the image that you build!
|
||||||
|
|
||||||
|
Tip: You can customize memory (`-m` flag) or cpu (`-smp` flag) available to the VM to your liking.
|
||||||
|
|
||||||
|
## Build the image inside the nix sandbox
|
||||||
|
|
||||||
|
Instead of the diskoImagesScript, we can also build the image inside the nix store.
|
||||||
|
This approach is slower because it requires copying the image after the build and
|
||||||
|
we also don't have a secure way to embed secrets this way.
|
||||||
|
|
||||||
|
```
|
||||||
|
nix build .#nixosConfigurations.myhost.config.system.build.diskoImages
|
||||||
|
ls -a ./result/main.raw
|
||||||
|
```
|
||||||
+13
-2
@@ -197,8 +197,19 @@ Add this to your flake.nix output:
|
|||||||
```nix
|
```nix
|
||||||
# `self` here is referring to the flake `self`, you may need to pass it using `specialArgs` or define your NixOS installer configuration
|
# `self` here is referring to the flake `self`, you may need to pass it using `specialArgs` or define your NixOS installer configuration
|
||||||
# in the flake.nix itself to get direct access to the `self` flake variable.
|
# in the flake.nix itself to get direct access to the `self` flake variable.
|
||||||
{ pkgs, self, ... }:
|
{ lib, pkgs, self, ... }:
|
||||||
let
|
let
|
||||||
|
flakeOutPaths =
|
||||||
|
let
|
||||||
|
collector =
|
||||||
|
parent:
|
||||||
|
map (
|
||||||
|
child:
|
||||||
|
[ child.outPath ] ++ (if child ? inputs && child.inputs != { } then (collector child) else [ ])
|
||||||
|
) (lib.attrValues parent.inputs);
|
||||||
|
in
|
||||||
|
lib.unique (lib.flatten (collector self));
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
self.nixosConfigurations.your-machine.config.system.build.toplevel
|
self.nixosConfigurations.your-machine.config.system.build.toplevel
|
||||||
self.nixosConfigurations.your-machine.config.system.build.diskoScript
|
self.nixosConfigurations.your-machine.config.system.build.diskoScript
|
||||||
@@ -210,7 +221,7 @@ let
|
|||||||
self.nixosConfigurations.your-machine.pkgs.perlPackages.FileSlurp
|
self.nixosConfigurations.your-machine.pkgs.perlPackages.FileSlurp
|
||||||
|
|
||||||
(self.nixosConfigurations.your-machine.pkgs.closureInfo { rootPaths = [ ]; }).drvPath
|
(self.nixosConfigurations.your-machine.pkgs.closureInfo { rootPaths = [ ]; }).drvPath
|
||||||
] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
|
] ++ flakeOutPaths;
|
||||||
|
|
||||||
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
||||||
in
|
in
|
||||||
|
|||||||
+42
-141
@@ -23,7 +23,7 @@
|
|||||||
content = {
|
content = {
|
||||||
type = "bcachefs";
|
type = "bcachefs";
|
||||||
# This refers to a filesystem in the `bcachefs_filesystems` attrset below.
|
# This refers to a filesystem in the `bcachefs_filesystems` attrset below.
|
||||||
filesystem = "unmounted_subvolumes_in_multi";
|
filesystem = "mounted_subvolumes_in_multi";
|
||||||
label = "group_a.vdb2";
|
label = "group_a.vdb2";
|
||||||
extraFormatArgs = [
|
extraFormatArgs = [
|
||||||
"--discard"
|
"--discard"
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
size = "100%";
|
size = "100%";
|
||||||
content = {
|
content = {
|
||||||
type = "bcachefs";
|
type = "bcachefs";
|
||||||
filesystem = "unmounted_subvolumes_in_multi";
|
filesystem = "mounted_subvolumes_in_multi";
|
||||||
label = "group_a.vdc1";
|
label = "group_a.vdc1";
|
||||||
extraFormatArgs = [
|
extraFormatArgs = [
|
||||||
"--discard"
|
"--discard"
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
size = "100%";
|
size = "100%";
|
||||||
content = {
|
content = {
|
||||||
type = "bcachefs";
|
type = "bcachefs";
|
||||||
filesystem = "unmounted_subvolumes_in_multi";
|
filesystem = "mounted_subvolumes_in_multi";
|
||||||
label = "group_b.vdd1";
|
label = "group_b.vdd1";
|
||||||
extraFormatArgs = [
|
extraFormatArgs = [
|
||||||
"--force"
|
"--force"
|
||||||
@@ -79,87 +79,6 @@
|
|||||||
vde = {
|
vde = {
|
||||||
device = "/dev/vde";
|
device = "/dev/vde";
|
||||||
type = "disk";
|
type = "disk";
|
||||||
content = {
|
|
||||||
type = "gpt";
|
|
||||||
partitions = {
|
|
||||||
vde1 = {
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "bcachefs";
|
|
||||||
filesystem = "mounted_subvolumes_in_multi";
|
|
||||||
label = "group_a.vde1";
|
|
||||||
extraFormatArgs = [
|
|
||||||
"--discard"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
vdf = {
|
|
||||||
device = "/dev/vdf";
|
|
||||||
type = "disk";
|
|
||||||
content = {
|
|
||||||
type = "gpt";
|
|
||||||
partitions = {
|
|
||||||
vdf1 = {
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "bcachefs";
|
|
||||||
filesystem = "mounted_subvolumes_in_multi";
|
|
||||||
label = "group_a.vdf1";
|
|
||||||
extraFormatArgs = [
|
|
||||||
"--discard"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
vdg = {
|
|
||||||
device = "/dev/vdg";
|
|
||||||
type = "disk";
|
|
||||||
content = {
|
|
||||||
type = "gpt";
|
|
||||||
partitions = {
|
|
||||||
vdd1 = {
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "bcachefs";
|
|
||||||
filesystem = "mounted_subvolumes_in_multi";
|
|
||||||
label = "group_b.vdg1";
|
|
||||||
extraFormatArgs = [
|
|
||||||
"--force"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
vdh = {
|
|
||||||
device = "/dev/vdh";
|
|
||||||
type = "disk";
|
|
||||||
content = {
|
|
||||||
type = "gpt";
|
|
||||||
partitions = {
|
|
||||||
vdd1 = {
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "bcachefs";
|
|
||||||
filesystem = "no_reliance_on_external_subvolume";
|
|
||||||
label = "group_a.vdh1";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
vdi = {
|
|
||||||
device = "/dev/vdi";
|
|
||||||
type = "disk";
|
|
||||||
content = {
|
content = {
|
||||||
type = "gpt";
|
type = "gpt";
|
||||||
partitions = {
|
partitions = {
|
||||||
@@ -168,7 +87,7 @@
|
|||||||
content = {
|
content = {
|
||||||
type = "bcachefs";
|
type = "bcachefs";
|
||||||
filesystem = "relies_on_external_subvolume";
|
filesystem = "relies_on_external_subvolume";
|
||||||
label = "group_a.vdi1";
|
label = "group_a.vde1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -177,72 +96,54 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
bcachefs_filesystems = {
|
bcachefs_filesystems = {
|
||||||
# Example showing unmounted subvolumes in a multi-disk configuration.
|
# Example showing mounted subvolumes in a multi-disk configuration.
|
||||||
unmounted_subvolumes_in_multi = {
|
mounted_subvolumes_in_multi = {
|
||||||
type = "bcachefs_filesystem";
|
type = "bcachefs_filesystem";
|
||||||
passwordFile = "/tmp/secret.key";
|
passwordFile = "/tmp/secret.key";
|
||||||
extraFormatArgs = [
|
extraFormatArgs = [
|
||||||
"--compression=lz4"
|
"--compression=lz4"
|
||||||
"--background_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,
|
||||||
|
# which relies on a subvolume in another filesystem being mounted
|
||||||
|
# and uses a hard-coded UUID.
|
||||||
|
relies_on_external_subvolume = {
|
||||||
|
type = "bcachefs_filesystem";
|
||||||
|
mountpoint = "/home/Documents";
|
||||||
|
extraFormatArgs = [
|
||||||
|
"--compression=lz4"
|
||||||
|
"--background_compression=lz4"
|
||||||
|
];
|
||||||
mountOptions = [
|
mountOptions = [
|
||||||
"verbose"
|
"verbose"
|
||||||
];
|
];
|
||||||
mountpoint = "/";
|
uuid = "64e50034-ebe2-eaf8-1f93-cf56266a8d86";
|
||||||
subvolumes = {
|
|
||||||
"subvolumes/rootfs" = { };
|
|
||||||
"subvolumes/home" = { };
|
|
||||||
"subvolumes/home/user" = { };
|
|
||||||
"subvolumes/nix" = { };
|
|
||||||
"subvolumes/test" = { };
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# # Example showing mounted subvolumes in a multi-disk configuration (not yet working).
|
|
||||||
# mounted_subvolumes_in_multi = {
|
|
||||||
# type = "bcachefs_filesystem";
|
|
||||||
# passwordFile = "/tmp/secret.key";
|
|
||||||
# extraFormatArgs = [
|
|
||||||
# "--compression=lz4"
|
|
||||||
# "--background_compression=lz4"
|
|
||||||
# ];
|
|
||||||
# mountOptions = [
|
|
||||||
# "verbose"
|
|
||||||
# ];
|
|
||||||
# subvolumes = {
|
|
||||||
# # Subvolume name is different from mountpoint
|
|
||||||
# "foo" = {
|
|
||||||
# mountpoint = "/bar";
|
|
||||||
# };
|
|
||||||
# # Subvolume name is the same as the mountpoint
|
|
||||||
# "home" = {
|
|
||||||
# mountpoint = "/home";
|
|
||||||
# };
|
|
||||||
# # Sub(sub)volume doesn't need a mountpoint as its parent is mounted
|
|
||||||
# "home/user" = {
|
|
||||||
# };
|
|
||||||
# # Parent is not mounted so the mountpoint must be set
|
|
||||||
# "nix" = {
|
|
||||||
# mountpoint = "/nix";
|
|
||||||
# };
|
|
||||||
# # This subvolume will be created but not mounted
|
|
||||||
# "test" = {
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
|
|
||||||
# Example showing another bcachefs filesystem.
|
|
||||||
no_reliance_on_external_subvolume = {
|
|
||||||
type = "bcachefs_filesystem";
|
|
||||||
mountpoint = "/sometestdir";
|
|
||||||
};
|
|
||||||
|
|
||||||
# # Example showing another bcachefs filesystem that relies on a subvolume
|
|
||||||
# # in another filesystem being mounted (not yet working).
|
|
||||||
# relies_on_external_subvolume = {
|
|
||||||
# type = "bcachefs_filesystem";
|
|
||||||
# mountpoint = "/home/somedir/vdf1";
|
|
||||||
# };
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
boot = {
|
boot = {
|
||||||
size = "1M";
|
size = "1M";
|
||||||
type = "EF02"; # for grub MBR
|
type = "EF02"; # for grub MBR
|
||||||
|
attributes = [ 0 ]; # partition attribute
|
||||||
};
|
};
|
||||||
root = {
|
root = {
|
||||||
size = "100%";
|
size = "100%";
|
||||||
|
|||||||
@@ -244,7 +244,7 @@
|
|||||||
type = "topology";
|
type = "topology";
|
||||||
vdev = [
|
vdev = [
|
||||||
{
|
{
|
||||||
# This syntax expects a disk called 'data3' with a gpt partition called 'zfs'.
|
# This syntax expects a disk called 'data1' with a gpt partition called 'zfs'.
|
||||||
members = [ "data1" ];
|
members = [ "data1" ];
|
||||||
# It's also possible to use the full path of the device or partition
|
# It's also possible to use the full path of the device or partition
|
||||||
# members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ];
|
# members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ];
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
options.flake.diskoConfigurations = lib.mkOption {
|
||||||
|
type = lib.types.lazyAttrsOf lib.types.raw;
|
||||||
|
default = { };
|
||||||
|
description = "Instantiated Disko configurations. Used by `disko` and `disko-install`.";
|
||||||
|
example = {
|
||||||
|
my-pc = {
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
my-disk = {
|
||||||
|
device = "/dev/sda";
|
||||||
|
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 = "ext4";
|
||||||
|
mountpoint = "/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Generated
+3
-3
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1744868846,
|
"lastModified": 1752596105,
|
||||||
"narHash": "sha256-5RJTdUHDmj12Qsv7XOhuospjAjATNiTMElplWnJE9Hs=",
|
"narHash": "sha256-lFNVsu/mHLq3q11MuGkMhUUoSXEdQjCHvpReaGP1S2k=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "ebe4301cbd8f81c4f8d3244b3632338bbeb6d49c",
|
"rev": "dab3a6e781554f965bde3def0aa2fda4eb8f1708",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -29,6 +29,9 @@
|
|||||||
{
|
{
|
||||||
nixosModules.default = self.nixosModules.disko; # convention
|
nixosModules.default = self.nixosModules.disko; # convention
|
||||||
nixosModules.disko = ./module.nix;
|
nixosModules.disko = ./module.nix;
|
||||||
|
flakeModule = self.flakeModules.default;
|
||||||
|
flakeModules.default = self.flakeModules.disko;
|
||||||
|
flakeModules.disko = ./flake-module.nix;
|
||||||
lib = diskoLib;
|
lib = diskoLib;
|
||||||
packages = forAllSystems (
|
packages = forAllSystems (
|
||||||
system:
|
system:
|
||||||
|
|||||||
+41
-15
@@ -23,21 +23,40 @@ let
|
|||||||
lib.mkOptionType {
|
lib.mkOptionType {
|
||||||
name = "subType";
|
name = "subType";
|
||||||
description = "one of ${lib.concatStringsSep "," (lib.attrNames types)}";
|
description = "one of ${lib.concatStringsSep "," (lib.attrNames types)}";
|
||||||
check =
|
check = x: lib.isAttrs x;
|
||||||
x:
|
|
||||||
if x ? type then
|
|
||||||
types.${x.type}.check x
|
|
||||||
else
|
|
||||||
throw "No type option set in:\n${lib.generators.toPretty { } x}";
|
|
||||||
merge =
|
merge =
|
||||||
loc:
|
loc: defs:
|
||||||
lib.foldl' (
|
let
|
||||||
_res: def:
|
evaled = lib.evalModules {
|
||||||
types.${def.value.type}.merge loc [
|
modules =
|
||||||
|
[
|
||||||
|
{
|
||||||
|
freeformType = lib.types.lazyAttrsOf lib.types.raw;
|
||||||
|
options.type = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ map (
|
||||||
|
{ value, file }:
|
||||||
|
{
|
||||||
|
_file = file;
|
||||||
|
config = value;
|
||||||
|
}
|
||||||
|
) defs;
|
||||||
|
};
|
||||||
|
inherit (evaled.config) type;
|
||||||
|
in
|
||||||
|
types.${type}.merge loc (
|
||||||
|
[
|
||||||
# we add a dummy root parent node to render documentation
|
# we add a dummy root parent node to render documentation
|
||||||
(lib.recursiveUpdate { value._module.args = extraArgs; } def)
|
{
|
||||||
|
file = "";
|
||||||
|
value._module.args = extraArgs;
|
||||||
|
}
|
||||||
]
|
]
|
||||||
) { };
|
++ defs
|
||||||
|
);
|
||||||
nestedTypes = types;
|
nestedTypes = types;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -875,9 +894,15 @@ let
|
|||||||
umount -Rv "${rootMountPoint}" || :
|
umount -Rv "${rootMountPoint}" || :
|
||||||
|
|
||||||
# shellcheck disable=SC2043,2041
|
# shellcheck disable=SC2043,2041
|
||||||
for dev in ${toString (lib.catAttrs "device" (lib.attrValues devices.disk))}; do
|
for dev in ${
|
||||||
|
toString (
|
||||||
|
lib.catAttrs "device" (lib.attrValues (lib.filterAttrs (name: disk: disk.destroy) devices.disk))
|
||||||
|
)
|
||||||
|
};
|
||||||
|
do
|
||||||
$BASH ${../disk-deactivate}/disk-deactivate "$dev"
|
$BASH ${../disk-deactivate}/disk-deactivate "$dev"
|
||||||
done
|
done
|
||||||
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
_destroy = lib.mkOption {
|
_destroy = lib.mkOption {
|
||||||
@@ -888,7 +913,8 @@ let
|
|||||||
'';
|
'';
|
||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
selectedDisks = lib.escapeShellArgs (lib.catAttrs "device" (lib.attrValues devices.disk));
|
disksToWipe = lib.attrValues (lib.filterAttrs (name: disk: disk.destroy) devices.disk);
|
||||||
|
selectedDisks = lib.escapeShellArgs (lib.catAttrs "device" disksToWipe);
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
if [ "$1" != "--yes-wipe-all-disks" ]; then
|
if [ "$1" != "--yes-wipe-all-disks" ]; then
|
||||||
@@ -913,7 +939,7 @@ let
|
|||||||
umount -Rv "${rootMountPoint}" || :
|
umount -Rv "${rootMountPoint}" || :
|
||||||
|
|
||||||
# shellcheck disable=SC2043,2041
|
# shellcheck disable=SC2043,2041
|
||||||
for dev in ${selectedDisks}; do
|
for dev in ${toString (lib.catAttrs "device" disksToWipe)}; do
|
||||||
$BASH ${../disk-deactivate}/disk-deactivate "$dev"
|
$BASH ${../disk-deactivate}/disk-deactivate "$dev"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -82,6 +82,6 @@ in
|
|||||||
-F qcow2 "$tmp"/${lib.escapeShellArg disk.imageName}.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 "$@"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
+15
-3
@@ -14,6 +14,7 @@ let
|
|||||||
checked = diskoCfg.checkScripts;
|
checked = diskoCfg.checkScripts;
|
||||||
|
|
||||||
configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
|
configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
|
||||||
|
configSupportsBcachefs = config.boot.supportedFilesystems.bcachefs or false;
|
||||||
binfmt = diskoLib.binfmt {
|
binfmt = diskoLib.binfmt {
|
||||||
inherit
|
inherit
|
||||||
diskoLib
|
diskoLib
|
||||||
@@ -41,12 +42,20 @@ let
|
|||||||
"virtio_rng"
|
"virtio_rng"
|
||||||
]
|
]
|
||||||
++ (lib.optional configSupportsZfs "zfs")
|
++ (lib.optional configSupportsZfs "zfs")
|
||||||
|
++ (lib.optional configSupportsBcachefs "bcachefs")
|
||||||
++ cfg.extraRootModules;
|
++ cfg.extraRootModules;
|
||||||
kernel = pkgs.aggregateModules (
|
kernel = pkgs.aggregateModules (
|
||||||
[ cfg.kernelPackages.kernel ]
|
[
|
||||||
|
cfg.kernelPackages.kernel
|
||||||
|
]
|
||||||
|
++ lib.optional (cfg.kernelPackages.kernel ? modules) cfg.kernelPackages.kernel.modules
|
||||||
++ lib.optional (
|
++ lib.optional (
|
||||||
lib.elem "zfs" cfg.extraRootModules || configSupportsZfs
|
lib.elem "zfs" cfg.extraRootModules || configSupportsZfs
|
||||||
) cfg.kernelPackages.${config.boot.zfs.package.kernelModuleAttribute}
|
) cfg.kernelPackages.${config.boot.zfs.package.kernelModuleAttribute}
|
||||||
|
++ lib.optional (
|
||||||
|
(lib.elem "bcachefs" cfg.extraRootModules || configSupportsBcachefs)
|
||||||
|
&& pkgs.bcachefs-tools ? kernelModule
|
||||||
|
) (cfg.kernelPackages.callPackage pkgs.bcachefs-tools.kernelModule { })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs (diskoLib.vmToolsSupportsCustomQemu lib) {
|
// lib.optionalAttrs (diskoLib.vmToolsSupportsCustomQemu lib) {
|
||||||
@@ -73,6 +82,7 @@ let
|
|||||||
disko.testMode = true;
|
disko.testMode = true;
|
||||||
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;
|
||||||
|
boot.kernelPackages = cfg.kernelPackages;
|
||||||
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||||
nixpkgs.buildPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
nixpkgs.buildPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||||
}
|
}
|
||||||
@@ -92,6 +102,7 @@ let
|
|||||||
util-linux
|
util-linux
|
||||||
findutils
|
findutils
|
||||||
kmod
|
kmod
|
||||||
|
xcp
|
||||||
]
|
]
|
||||||
++ cfg.extraDependencies;
|
++ cfg.extraDependencies;
|
||||||
preVM = ''
|
preVM = ''
|
||||||
@@ -136,13 +147,14 @@ let
|
|||||||
|
|
||||||
installer = lib.optionalString cfg.copyNixStore ''
|
installer = lib.optionalString cfg.copyNixStore ''
|
||||||
${binfmtSetup}
|
${binfmtSetup}
|
||||||
|
unset NIX_REMOTE
|
||||||
# populate nix db, so nixos-install doesn't complain
|
# populate nix db, so nixos-install doesn't complain
|
||||||
export NIX_STATE_DIR=${systemToInstall.config.disko.rootMountPoint}/nix/var/nix
|
export NIX_STATE_DIR=${systemToInstall.config.disko.rootMountPoint}/nix/var/nix
|
||||||
nix-store --load-db < "${closureInfo}/registration"
|
nix-store --load-db < "${closureInfo}/registration"
|
||||||
|
|
||||||
# We copy files with cp because `nix copy` seems to have a large memory leak
|
# We copy files with cp because `nix copy` seems to have a large memory leak
|
||||||
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
|
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
|
||||||
time xargs cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
|
xargs xcp --recursive --target-directory ${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 ${lib.escapeShellArg systemToInstall.config.disko.rootMountPoint}
|
umount -Rv ${lib.escapeShellArg systemToInstall.config.disko.rootMountPoint}
|
||||||
@@ -266,7 +278,7 @@ in
|
|||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
QEMU_OPTS=${lib.escapeShellArg QEMU_OPTS}
|
QEMU_OPTS=${lib.escapeShellArg QEMU_OPTS}
|
||||||
# replace quoted $out with the actual path
|
# replace quoted $out with the actual path
|
||||||
QEUM_OPTS=''${QEMU_OPTS//\$out/$out}
|
QEMU_OPTS=''${QEMU_OPTS//\$out/$out}
|
||||||
QEMU_OPTS+=" -m $build_memory -object memory-backend-memfd,id=mem,size=''${build_memory}M,share=on -machine memory-backend=mem"
|
QEMU_OPTS+=" -m $build_memory -object memory-backend-memfd,id=mem,size=''${build_memory}M,share=on -machine memory-backend=mem"
|
||||||
export QEMU_OPTS
|
export QEMU_OPTS
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -89,7 +89,7 @@ let
|
|||||||
args:
|
args:
|
||||||
makeTest args {
|
makeTest args {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
inherit (pkgs) system;
|
system = pkgs.stdenv.hostPlatform.system;
|
||||||
};
|
};
|
||||||
# for installation we skip /dev/vda because it is the test runner disk
|
# for installation we skip /dev/vda because it is the test runner disk
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ let
|
|||||||
|
|
||||||
installed-system-eval = eval-config {
|
installed-system-eval = eval-config {
|
||||||
modules = [ installed-system ];
|
modules = [ installed-system ];
|
||||||
inherit (pkgs) system;
|
system = pkgs.stdenv.hostPlatform.system;
|
||||||
};
|
};
|
||||||
|
|
||||||
installedTopLevel =
|
installedTopLevel =
|
||||||
@@ -181,6 +181,9 @@ let
|
|||||||
};
|
};
|
||||||
boot.zfs.devNodes = "/dev/disk/by-uuid"; # needed because /dev/disk/by-id is empty in qemu-vms
|
boot.zfs.devNodes = "/dev/disk/by-uuid"; # needed because /dev/disk/by-id is empty in qemu-vms
|
||||||
|
|
||||||
|
# Silence mdadm warning about missing MAILADDR or PROGRAM
|
||||||
|
boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
|
||||||
|
|
||||||
# grub will install to these devices, we need to force those or we are offset by 1
|
# grub will install to these devices, we need to force those or we are offset by 1
|
||||||
# we use mkOveride 70, so that users can override this with mkForce in case they are testing grub mirrored boots
|
# we use mkOveride 70, so that users can override this with mkForce in case they are testing grub mirrored boots
|
||||||
boot.loader.grub.devices = lib.mkOverride 70 testConfigInstall.boot.loader.grub.devices;
|
boot.loader.grub.devices = lib.mkOverride 70 testConfigInstall.boot.loader.grub.devices;
|
||||||
@@ -248,7 +251,10 @@ let
|
|||||||
(
|
(
|
||||||
if lib.versionAtLeast (lib.versions.majorMinor lib.version) "23.11" then
|
if lib.versionAtLeast (lib.versions.majorMinor lib.version) "23.11" then
|
||||||
{
|
{
|
||||||
|
# From https://github.com/NixOS/nixpkgs/blob/7a8665e3a624a01b10d10d10b819cb1a8f34ee6e/nixos/modules/profiles/installation-device.nix#L116-L118
|
||||||
boot.swraid.enable = true;
|
boot.swraid.enable = true;
|
||||||
|
# remove warning about unset mail
|
||||||
|
boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
default = ''
|
default = ''
|
||||||
# Write device arguments to temporary directory for bcachefs_filesystem.
|
# Write device arguments to temporary directory for bcachefs_filesystem.
|
||||||
{
|
{
|
||||||
printf '%s\n' '--label="${config.label}"';
|
printf '%s\n' '--label=${config.label}';
|
||||||
${lib.concatMapStrings (args: ''printf '%s\n' '${args}';'') config.extraFormatArgs}
|
${lib.concatMapStrings (args: ''printf '%s\n' '${args}';'') config.extraFormatArgs}
|
||||||
printf '%s\n' '${config.device}';
|
printf '%s\n' '${config.device}';
|
||||||
} >> "$disko_devices_dir/bcachefs-${lib.escapeShellArg config.filesystem}";
|
} >> "$disko_devices_dir/bcachefs-${lib.escapeShellArg config.filesystem}";
|
||||||
|
|||||||
@@ -113,10 +113,7 @@
|
|||||||
mountpoint = lib.mkOption {
|
mountpoint = lib.mkOption {
|
||||||
type = lib.types.nullOr diskoLib.optionTypes.absolute-pathname;
|
type = lib.types.nullOr diskoLib.optionTypes.absolute-pathname;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = "Path to mount the subvolume to.";
|
||||||
Path to mount the subvolume to.
|
|
||||||
DO NOT USE. Currently not working.
|
|
||||||
'';
|
|
||||||
example = "/";
|
example = "/";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -126,7 +123,19 @@
|
|||||||
default = { };
|
default = { };
|
||||||
description = "List of subvolumes to define.";
|
description = "List of subvolumes to define.";
|
||||||
example = {
|
example = {
|
||||||
"subvolumes/home" = { };
|
"subvolumes/root" = {
|
||||||
|
mountpoint = "/";
|
||||||
|
extraFormatArgs = [
|
||||||
|
"--compression=lz4"
|
||||||
|
"--background_compression=lz4"
|
||||||
|
];
|
||||||
|
mountOptions = [
|
||||||
|
"verbose"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
"subvolumes/home" = {
|
||||||
|
mountpoint = "/home";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
_parent = lib.mkOption {
|
_parent = lib.mkOption {
|
||||||
@@ -291,11 +300,10 @@
|
|||||||
_config = lib.mkOption {
|
_config = lib.mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
# @todo Check that this implementation is correct:
|
|
||||||
default =
|
default =
|
||||||
(lib.optional (config.mountpoint != null) {
|
(lib.optional (config.mountpoint != null) {
|
||||||
fileSystems.${config.mountpoint} = {
|
fileSystems.${config.mountpoint} = {
|
||||||
device = "UUID=${config.uuid}";
|
device = "/dev/disk/by-uuid/${config.uuid}";
|
||||||
fsType = "bcachefs";
|
fsType = "bcachefs";
|
||||||
options = lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions);
|
options = lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions);
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
@@ -303,7 +311,7 @@
|
|||||||
})
|
})
|
||||||
++ (map (subvolume: {
|
++ (map (subvolume: {
|
||||||
fileSystems.${subvolume.mountpoint} = {
|
fileSystems.${subvolume.mountpoint} = {
|
||||||
device = "UUID=${config.uuid}";
|
device = "/dev/disk/by-uuid/${config.uuid}";
|
||||||
fsType = "bcachefs";
|
fsType = "bcachefs";
|
||||||
options = lib.unique (
|
options = lib.unique (
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -22,6 +22,11 @@
|
|||||||
type = diskoLib.optionTypes.absolute-pathname; # TODO check if subpath of /dev ? - No! eg: /.swapfile
|
type = diskoLib.optionTypes.absolute-pathname; # TODO check if subpath of /dev ? - No! eg: /.swapfile
|
||||||
description = "Device path";
|
description = "Device path";
|
||||||
};
|
};
|
||||||
|
destroy = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "If false, disko will not wipe or destroy this disk's contents during the destroy stage";
|
||||||
|
};
|
||||||
imageName = lib.mkOption {
|
imageName = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = config.name;
|
default = config.name;
|
||||||
|
|||||||
@@ -57,6 +57,27 @@ in
|
|||||||
or a fully specified GUID (see https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs).
|
or a fully specified GUID (see https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs).
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
attributes = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.int;
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
GPT partition entry attributes, according to UEFI specification
|
||||||
|
2.10 (see https://uefi.org/specs/UEFI/2.10_A/05_GUID_Partition_Table_Format.html#defined-gpt-partition-entry-attributes)
|
||||||
|
and `sgdisk`s man page:
|
||||||
|
|
||||||
|
- 0: Required Partition (`sgdisk`: system partition)
|
||||||
|
- 1: No Block IO Protocol (`sgdisk`: hide from EFI)
|
||||||
|
- 2: Legacy BIOS Bootable
|
||||||
|
- 3-47: Undefined and must be zero, reserved for future use
|
||||||
|
- 48-63: Reserved for GUID specific use. The use of these bits
|
||||||
|
will vary depending on the partition type
|
||||||
|
|
||||||
|
`sgdisk` describes some of the GUID-specific bits this way:
|
||||||
|
- 60: read only
|
||||||
|
- 62: hidden
|
||||||
|
- 63: do not automount
|
||||||
|
'';
|
||||||
|
};
|
||||||
device = lib.mkOption {
|
device = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default =
|
default =
|
||||||
@@ -208,6 +229,8 @@ in
|
|||||||
''}
|
''}
|
||||||
${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)}
|
||||||
|
udevadm trigger --subsystem-match=block
|
||||||
|
udevadm settle --timeout 120
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@@ -268,6 +291,14 @@ in
|
|||||||
}" \
|
}" \
|
||||||
--change-name="${toString partition._index}:${partition.label}" \
|
--change-name="${toString partition._index}:${partition.label}" \
|
||||||
--typecode=${toString partition._index}:${partition.type} \
|
--typecode=${toString partition._index}:${partition.type} \
|
||||||
|
--attributes=${toString partition._index}:=:0 \
|
||||||
|
${
|
||||||
|
lib.concatStringsSep " \\\n" (
|
||||||
|
builtins.map (bitNumber: "--attributes=${toString partition._index}:set:${toString bitNumber}") (
|
||||||
|
lib.unique partition.attributes
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} \
|
||||||
"${config.device}" \
|
"${config.device}" \
|
||||||
'';
|
'';
|
||||||
createArgs = ''
|
createArgs = ''
|
||||||
|
|||||||
+14
-8
@@ -130,7 +130,7 @@ in
|
|||||||
_create = diskoLib.mkCreateOption {
|
_create = diskoLib.mkCreateOption {
|
||||||
inherit config options;
|
inherit config options;
|
||||||
default = ''
|
default = ''
|
||||||
if ! blkid "${config.device}" >/dev/null || ! (blkid "${config.device}" -o export | grep -q '^TYPE='); then
|
if ! blkid "${config.device}" >/dev/null || ! cryptsetup isLuks "${config.device}"; then
|
||||||
${lib.optionalString config.askPassword ''
|
${lib.optionalString config.askPassword ''
|
||||||
promptSecret() {
|
promptSecret() {
|
||||||
prompt=$1
|
prompt=$1
|
||||||
@@ -147,7 +147,9 @@ in
|
|||||||
promptSecret "Enter password for ${config.device}: " password
|
promptSecret "Enter password for ${config.device}: " password
|
||||||
promptSecret "Enter password for ${config.device} again to be safe: " password_check
|
promptSecret "Enter password for ${config.device} again to be safe: " password_check
|
||||||
export password
|
export password
|
||||||
[ "$password" = "$password_check" ]
|
if [ "$password" != "$password_check" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
set -x
|
set -x
|
||||||
else
|
else
|
||||||
export password=disko
|
export password=disko
|
||||||
@@ -158,13 +160,17 @@ in
|
|||||||
done
|
done
|
||||||
''}
|
''}
|
||||||
cryptsetup -q luksFormat "${config.device}" ${toString config.extraFormatArgs} ${keyFileArgs}
|
cryptsetup -q luksFormat "${config.device}" ${toString config.extraFormatArgs} ${keyFileArgs}
|
||||||
${cryptsetupOpen} --persistent
|
|
||||||
${toString (
|
|
||||||
lib.forEach config.additionalKeyFiles (keyFile: ''
|
|
||||||
cryptsetup luksAddKey "${config.device}" ${keyFile} ${keyFileArgs}
|
|
||||||
'')
|
|
||||||
)}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! cryptsetup status "${config.name}" >/dev/null; then
|
||||||
|
${cryptsetupOpen} --persistent
|
||||||
|
fi
|
||||||
|
${toString (
|
||||||
|
lib.forEach config.additionalKeyFiles (keyFile: ''
|
||||||
|
cryptsetup luksAddKey "${config.device}" ${keyFile} ${keyFileArgs}
|
||||||
|
'')
|
||||||
|
)}
|
||||||
|
|
||||||
${lib.optionalString (config.content != null) config.content._create}
|
${lib.optionalString (config.content != null) config.content._create}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
+14
-2
@@ -9,19 +9,30 @@
|
|||||||
binlore,
|
binlore,
|
||||||
diskoVersion,
|
diskoVersion,
|
||||||
stdenv,
|
stdenv,
|
||||||
|
xcp,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
self = stdenvNoCC.mkDerivation (finalAttrs: {
|
self = stdenvNoCC.mkDerivation (finalAttrs: {
|
||||||
name = "disko";
|
name = "disko";
|
||||||
src = ./.;
|
src = lib.fileset.toSource {
|
||||||
|
root = ./.;
|
||||||
|
fileset = lib.fileset.unions [
|
||||||
|
./disko
|
||||||
|
./disko-install
|
||||||
|
./install-cli.nix
|
||||||
|
./cli.nix
|
||||||
|
./default.nix
|
||||||
|
./disk-deactivate
|
||||||
|
./lib
|
||||||
|
];
|
||||||
|
};
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
makeWrapper
|
makeWrapper
|
||||||
];
|
];
|
||||||
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
|
|
||||||
|
|
||||||
scripts=(disko)
|
scripts=(disko)
|
||||||
${lib.optionalString (!stdenv.isDarwin) ''
|
${lib.optionalString (!stdenv.isDarwin) ''
|
||||||
@@ -39,6 +50,7 @@ let
|
|||||||
[
|
[
|
||||||
nix
|
nix
|
||||||
coreutils
|
coreutils
|
||||||
|
xcp
|
||||||
]
|
]
|
||||||
++ lib.optional (!stdenv.isDarwin) nixos-install-tools
|
++ lib.optional (!stdenv.isDarwin) nixos-install-tools
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -45,7 +45,12 @@ fi
|
|||||||
nix-fast-build --no-link -j 2 --eval-workers 2 --flake .#checks
|
nix-fast-build --no-link -j 2 --eval-workers 2 --flake .#checks
|
||||||
|
|
||||||
# Update the version file
|
# Update the version file
|
||||||
echo "{ version = \"$version\"; released = true; }" > version.nix
|
cat > version.nix <<EOF
|
||||||
|
{
|
||||||
|
version = "$version";
|
||||||
|
released = false;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
# Commit and tag the release
|
# Commit and tag the release
|
||||||
git commit -am "release: v$version"
|
git commit -am "release: v$version"
|
||||||
|
|||||||
+110
-29
@@ -7,39 +7,120 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
name = "bcachefs";
|
name = "bcachefs";
|
||||||
disko-config = ../example/bcachefs.nix;
|
disko-config = ../example/bcachefs.nix;
|
||||||
enableOCR = true;
|
enableOCR = true;
|
||||||
|
bootCommands = ''
|
||||||
|
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");
|
||||||
|
'';
|
||||||
|
extraSystemConfig = {
|
||||||
|
environment.systemPackages = [
|
||||||
|
pkgs.jq
|
||||||
|
];
|
||||||
|
};
|
||||||
extraTestScript = ''
|
extraTestScript = ''
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
# @todo Verify all devices are part of the filesystem.
|
|
||||||
# @todo Check device labels and group assignments.
|
|
||||||
# Verify mount options were applied.
|
|
||||||
machine.succeed("mount | grep ' / ' | grep -q 'compression=lz4'");
|
|
||||||
machine.succeed("mount | grep ' / ' | grep -q 'background_compression=lz4'");
|
|
||||||
# @todo Verify mountpoint dependency order was respected.
|
|
||||||
# @todo Add tests for subvolumes.
|
|
||||||
# Print debug information.
|
# Print debug information.
|
||||||
|
machine.succeed("ls -la /subvolumes >&2");
|
||||||
machine.succeed("lsblk >&2");
|
machine.succeed("lsblk >&2");
|
||||||
machine.succeed("lsblk -f >&2");
|
machine.succeed("lsblk -f >&2");
|
||||||
machine.succeed("mount >&2");
|
machine.succeed("mount >&2");
|
||||||
'';
|
machine.succeed("bcachefs show-super /dev/vda2 >&2");
|
||||||
# extraSystemConfig = { pkgs, ... }: {
|
machine.succeed("bcachefs show-super /dev/vdd1 >&2");
|
||||||
# # @todo Do we need to add any attributes here?
|
machine.succeed("findmnt --json >&2");
|
||||||
# boot = {
|
|
||||||
# supportedFilesystems = [ "bcachefs" ];
|
# Verify subvolume structure.
|
||||||
# initrd = {
|
machine.succeed("test -d /subvolumes/root");
|
||||||
# supportedFilesystems = [ "bcachefs" ];
|
machine.succeed("test -d /subvolumes/home");
|
||||||
# # systemd.enable = false;
|
machine.succeed("test -d /subvolumes/home/user");
|
||||||
# };
|
machine.succeed("test -d /subvolumes/nix");
|
||||||
# };
|
machine.succeed("test -d /subvolumes/test");
|
||||||
# environment.systemPackages = [
|
machine.fail("test -d /subvolumes/non-existent");
|
||||||
# pkgs.bcachefs-tools
|
|
||||||
# pkgs.util-linux
|
# Verify existence of mountpoints.
|
||||||
# ];
|
machine.succeed("mountpoint /");
|
||||||
# };
|
machine.succeed("mountpoint /home");
|
||||||
# extraInstallerConfig = {
|
machine.succeed("mountpoint /nix");
|
||||||
# # @todo Do we need to add any attributes here?
|
machine.succeed("mountpoint /home/Documents");
|
||||||
# };
|
machine.fail("mountpoint /non-existent");
|
||||||
bootCommands = ''
|
|
||||||
machine.wait_for_text("enter passphrase for");
|
# Verify device membership and labels.
|
||||||
machine.send_chars("secretsecret\n");
|
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 -qE '^[[:space:]]+Label:[[:space:]]+vdb2[[:space:]]\([[:digit:]]+\)'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]+Label:[[:space:]]+vdc1[[:space:]]\([[:digit:]]+\)'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]+Label:[[:space:]]+vdd1[[:space:]]\([[:digit:]]+\)'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]+Label:[[:space:]]+vde1[[:space:]]\([[:digit:]]+\)'");
|
||||||
|
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/disk/by-uuid/64e50034-ebe2-eaf8-1f93-cf56266a8d86") \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.fail("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| select(.target == "/") \
|
||||||
|
| .source | split(":") \
|
||||||
|
| contains(["/dev/non-existent"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
version = "1.10.0";
|
version = "1.12.0";
|
||||||
released = false;
|
released = false;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user