Compare commits

..
Author SHA1 Message Date
Jörg Thalheim ff442f5d14 release: v1.12.0 2025-05-08 20:14:14 +02:00
23 changed files with 70 additions and 257 deletions

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
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 }}"
+2 -2
View File
@@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@v27
uses: DeterminateSystems/update-flake-lock@v24
with:
pr-labels: |
merge-queue
-37
View File
@@ -12,43 +12,6 @@ way to help us fix issues quickly. Check out
For more information on how to run and debug tests, check out
[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
If you're looking for a low-hanging fruit, check out
+5 -5
View File
@@ -17,14 +17,11 @@ let
hasDiskoFile = diskoFile != null;
hasDiskoConfigFlake =
hasDiskoFile || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
diskoAttr =
(
if noDeps then
(
if hasDiskoFile || hasDiskoConfigFlake then
if hasDiskoFile then
{
destroy = "_cliDestroyNoDeps";
format = "_cliFormatNoDeps";
@@ -53,7 +50,7 @@ let
}
else
(
if hasDiskoFile || hasDiskoConfigFlake then
if hasDiskoFile then
{
destroy = "_cliDestroy";
format = "_cliFormat";
@@ -82,6 +79,9 @@ let
}
).${mode};
hasDiskoConfigFlake =
hasDiskoFile || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
hasDiskoModuleFlake = lib.hasAttrByPath [
"nixosConfigurations"
flakeAttr
+1 -1
View File
@@ -127,7 +127,7 @@ fi
echo "disko version $DISKO_VERSION"
nixBuild() {
if command -v nom-build > /dev/null && [ -t 1 ]; then
if command -v nom-build > /dev/null; then
nom-build "$@"
else
nix-build "$@"
+6 -31
View File
@@ -164,7 +164,7 @@ cleanupMountPoint() {
}
nixBuild() {
if command -v nom-build > /dev/null && [ -t 1 ]; then
if command -v nom-build > /dev/null; then
nom-build "$@"
else
nix-build "$@"
@@ -198,24 +198,10 @@ main() {
flakeAttr="${BASH_REMATCH[2]}"
fi
# Resolve flake to nix store path to respect git tracking
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
if [[ -e "$flake" ]]; then
flake=$(realpath "$flake")
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
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
@@ -229,7 +215,7 @@ main() {
trap cleanupMountPoint EXIT
fi
if ! outputs=$(nixBuild "${libexec_dir}"/install-cli.nix \
outputs=$(nixBuild "${libexec_dir}"/install-cli.nix \
"${nix_args[@]}" \
--no-out-link \
--impure \
@@ -241,20 +227,9 @@ main() {
--argstr extraSystemConfig "$extraSystemConfig" \
-A installToplevel \
-A closureInfo \
-A "$diskoAttr"); then
echo "Failed to build NixOS configuration" >&2
exit 1
fi
-A "$diskoAttr")
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]}
closure_info=${artifacts[1]}
disko_script=${artifacts[2]}
@@ -281,7 +256,7 @@ main() {
if [[ ! -f "${mountPoint}/nix/var/nix/db/db.sqlite" ]]; then
echo "Copying store paths" >&2
mkdir -p "${mountPoint}/nix/store"
xargs xcp --recursive --target-directory "${mountPoint}/nix/store" < "${closure_info}/store-paths"
xargs cp --recursive --target "${mountPoint}/nix/store" < "${closure_info}/store-paths"
echo "Loading nix database" >&2
NIX_STATE_DIR=${mountPoint}/nix/var/nix nix-store --load-db < "${closure_info}/registration"
fi
+2 -13
View File
@@ -197,19 +197,8 @@ Add this to your flake.nix output:
```nix
# `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.
{ lib, pkgs, self, ... }:
{ pkgs, self, ... }:
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 = [
self.nixosConfigurations.your-machine.config.system.build.toplevel
self.nixosConfigurations.your-machine.config.system.build.diskoScript
@@ -221,7 +210,7 @@ let
self.nixosConfigurations.your-machine.pkgs.perlPackages.FileSlurp
(self.nixosConfigurations.your-machine.pkgs.closureInfo { rootPaths = [ ]; }).drvPath
] ++ flakeOutPaths;
] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
in
-1
View File
@@ -11,7 +11,6 @@
boot = {
size = "1M";
type = "EF02"; # for grub MBR
attributes = [ 0 ]; # partition attribute
};
root = {
size = "100%";
+1 -1
View File
@@ -244,7 +244,7 @@
type = "topology";
vdev = [
{
# This syntax expects a disk called 'data1' with a gpt partition called 'zfs'.
# This syntax expects a disk called 'data3' with a gpt partition called 'zfs'.
members = [ "data1" ];
# It's also possible to use the full path of the device or partition
# members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ];
-43
View File
@@ -1,43 +0,0 @@
{ 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
View File
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1752596105,
"narHash": "sha256-lFNVsu/mHLq3q11MuGkMhUUoSXEdQjCHvpReaGP1S2k=",
"lastModified": 1746576598,
"narHash": "sha256-FshoQvr6Aor5SnORVvh/ZdJ1Sa2U4ZrIMwKBX5k2wu0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "dab3a6e781554f965bde3def0aa2fda4eb8f1708",
"rev": "b3582c75c7f21ce0b429898980eddbbf05c68e55",
"type": "github"
},
"original": {
-3
View File
@@ -29,9 +29,6 @@
{
nixosModules.default = self.nixosModules.disko; # convention
nixosModules.disko = ./module.nix;
flakeModule = self.flakeModules.default;
flakeModules.default = self.flakeModules.disko;
flakeModules.disko = ./flake-module.nix;
lib = diskoLib;
packages = forAllSystems (
system:
+12 -31
View File
@@ -23,40 +23,21 @@ let
lib.mkOptionType {
name = "subType";
description = "one of ${lib.concatStringsSep "," (lib.attrNames types)}";
check = x: lib.isAttrs x;
check =
x:
if x ? type then
types.${x.type}.check x
else
throw "No type option set in:\n${lib.generators.toPretty { } x}";
merge =
loc: defs:
let
evaled = lib.evalModules {
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 (
[
loc:
lib.foldl' (
_res: def:
types.${def.value.type}.merge loc [
# we add a dummy root parent node to render documentation
{
file = "";
value._module.args = extraArgs;
}
(lib.recursiveUpdate { value._module.args = extraArgs; } def)
]
++ defs
);
) { };
nestedTypes = types;
};
+1 -1
View File
@@ -82,6 +82,6 @@ in
-F qcow2 "$tmp"/${lib.escapeShellArg disk.imageName}.qcow2
'') disks}
set +f
${config.system.build.vm}/bin/run-*-vm "$@"
${config.system.build.vm}/bin/run-*-vm
'';
}
+3 -14
View File
@@ -14,7 +14,6 @@ let
checked = diskoCfg.checkScripts;
configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
configSupportsBcachefs = config.boot.supportedFilesystems.bcachefs or false;
binfmt = diskoLib.binfmt {
inherit
diskoLib
@@ -42,20 +41,12 @@ let
"virtio_rng"
]
++ (lib.optional configSupportsZfs "zfs")
++ (lib.optional configSupportsBcachefs "bcachefs")
++ cfg.extraRootModules;
kernel = pkgs.aggregateModules (
[
cfg.kernelPackages.kernel
]
++ lib.optional (cfg.kernelPackages.kernel ? modules) cfg.kernelPackages.kernel.modules
[ cfg.kernelPackages.kernel ]
++ lib.optional (
lib.elem "zfs" cfg.extraRootModules || configSupportsZfs
) 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) {
@@ -82,7 +73,6 @@ let
disko.testMode = true;
disko.devices = lib.mkForce cleanedConfig.disko.devices;
boot.loader.grub.devices = lib.mkForce cleanedConfig.boot.loader.grub.devices;
boot.kernelPackages = cfg.kernelPackages;
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
nixpkgs.buildPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
}
@@ -102,7 +92,6 @@ let
util-linux
findutils
kmod
xcp
]
++ cfg.extraDependencies;
preVM = ''
@@ -154,7 +143,7 @@ let
# We copy files with cp because `nix copy` seems to have a large memory leak
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
xargs xcp --recursive --target-directory ${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 ""
umount -Rv ${lib.escapeShellArg systemToInstall.config.disko.rootMountPoint}
@@ -278,7 +267,7 @@ in
# shellcheck disable=SC2016
QEMU_OPTS=${lib.escapeShellArg QEMU_OPTS}
# replace quoted $out with the actual path
QEMU_OPTS=''${QEMU_OPTS//\$out/$out}
QEUM_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"
export QEMU_OPTS
+2 -8
View File
@@ -89,7 +89,7 @@ let
args:
makeTest args {
inherit pkgs;
system = pkgs.stdenv.hostPlatform.system;
inherit (pkgs) system;
};
# for installation we skip /dev/vda because it is the test runner disk
@@ -140,7 +140,7 @@ let
installed-system-eval = eval-config {
modules = [ installed-system ];
system = pkgs.stdenv.hostPlatform.system;
inherit (pkgs) system;
};
installedTopLevel =
@@ -181,9 +181,6 @@ let
};
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
# 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;
@@ -251,10 +248,7 @@ let
(
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;
# remove warning about unset mail
boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
}
else
{
+1 -1
View File
@@ -66,7 +66,7 @@
default = ''
# 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}
printf '%s\n' '${config.device}';
} >> "$disko_devices_dir/bcachefs-${lib.escapeShellArg config.filesystem}";
-31
View File
@@ -57,27 +57,6 @@ in
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 {
type = lib.types.str;
default =
@@ -229,8 +208,6 @@ in
''}
${lib.optionalString hp.config.mbrBootableFlag ''
sfdisk --label-nested dos --activate "${parent.device}" ${(toString partition.config._index)}
udevadm trigger --subsystem-match=block
udevadm settle --timeout 120
''}
'';
};
@@ -291,14 +268,6 @@ in
}" \
--change-name="${toString partition._index}:${partition.label}" \
--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}" \
'';
createArgs = ''
+1 -3
View File
@@ -147,9 +147,7 @@ in
promptSecret "Enter password for ${config.device}: " password
promptSecret "Enter password for ${config.device} again to be safe: " password_check
export password
if [ "$password" != "$password_check" ]; then
exit 1
fi
[ "$password" = "$password_check" ]
set -x
else
export password=disko
+2 -14
View File
@@ -9,30 +9,19 @@
binlore,
diskoVersion,
stdenv,
xcp,
}:
let
self = stdenvNoCC.mkDerivation (finalAttrs: {
name = "disko";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./disko
./disko-install
./install-cli.nix
./cli.nix
./default.nix
./disk-deactivate
./lib
];
};
src = ./.;
nativeBuildInputs = [
makeWrapper
];
installPhase = ''
mkdir -p $out/bin $out/share/disko
cp -r install-cli.nix cli.nix default.nix disk-deactivate lib $out/share/disko
set -x
scripts=(disko)
${lib.optionalString (!stdenv.isDarwin) ''
@@ -50,7 +39,6 @@ let
[
nix
coreutils
xcp
]
++ lib.optional (!stdenv.isDarwin) nixos-install-tools
)
+1 -6
View File
@@ -45,12 +45,7 @@ fi
nix-fast-build --no-link -j 2 --eval-workers 2 --flake .#checks
# Update the version file
cat > version.nix <<EOF
{
version = "$version";
released = false;
}
EOF
echo "{ version = \"$version\"; released = true; }" > version.nix
# Commit and tag the release
git commit -am "release: v$version"
+4 -4
View File
@@ -48,10 +48,10 @@ diskoLib.testLib.makeDiskoTest {
# 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 -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.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.
+1 -4
View File
@@ -1,4 +1 @@
{
version = "1.12.0";
released = false;
}
{ version = "1.12.0"; released = true; }