71 Commits
Author SHA1 Message Date
lassulus f15bcc27b4 luks: don't define boot.initrd.systemd.enable where the option was removed
NixOS 26.11 dropped scripted stage 1 (NixOS/nixpkgs#573038) and replaced
boot.initrd.systemd.enable with mkRemovedOptionModule, whose assertion
fails as soon as the option is defined. The luks type set it for
enrollFido2, so FIDO2 configs stopped evaluating (#1303). The old
mkIf would also break once the removal shim is dropped, because mkIf
cannot define an option that is not declared at all.

Emit the definition via lib.optional only when
diskoLib.systemdInitrdToggleable says the option still has its bool
type. The removed-option stub is untyped; renamed or hidden
declarations keep bool, so unlike checking `visible` this does not
misfire on aliases. Where the option is gone, stage 1 is always
systemd, so nothing needs to be set.

The flag reaches the types through globals.canToggleSystemdInitrd:
- module.nix derives it from the system's options;
- default.nix accepts canToggleSystemdInitrd (default true, the
  pre-26.11 behaviour) for direct callers of the legacy outputs;
- the test harness probes the nixpkgs under test for direct mode.

The test harness itself read config.boot.initrd.systemd.enable, which
throws on 26.11; guard it as done in lib/tests.nix of
https://github.com/nix-community/disko/pull/1304/changes#diff-605c7b66854ad3072529f715252655bb5b4e5e5b53a99edec9dc929fd85162cd
2026-11-10 13:14:11 +01:00
June Stepp 10f31ba086 make-disk-image: add useVirtualDevices option 2026-06-14 15:03:34 -05:00
Jörg Thalheim 8e68aa819d disko-images: add copyNixStoreThreads option for configurable parallelism
Allow users to override the automatic thread count detection for nix
store copying. The default "auto" behavior remains unchanged (min of
nproc and 8), but users can now specify a fixed thread count for
environments where the automatic detection isn't optimal.
2025-12-09 08:59:57 +00:00
Jörg Thalheim e86a890795 stop using pkgs.path
pkgs.path is an expensive copy operation that slow down evaluation by a
lot.
2025-11-20 15:07:44 +00:00
DavHau ff2d853a84 treewide: format all files 2025-02-15 10:08:56 +00:00
Sávio 6438340415 make-disk-image: add binfmt emulation 2025-02-14 10:39:29 +00:00
Jörg Thalheim 79a12e659b disko: fix postVM beeing empty 2025-01-11 09:56:21 +00:00
Felix Uhl 5655a13ac9 make-disk-image: Compare against correct nixpkgs version
It seems that there is a difference between how `pkgs` and `lib` get
passed to NixOS modules: `pkgs` is the unmodified original, `lib` is the
final version after overrides etc.

This causes `pkgs.lib.version` to be `24.11git` in some cases, while
`lib.version` is `24.11.20241123.0c58267`.
Maybe this can be fixed in nixpkgs? Either way, this change fixes that
issue.

Fixes #904
2024-11-29 19:38:31 +01:00
lassulus 255e11e831 module: add default for tests.bootCommand 2024-11-26 18:21:37 +01:00
Andrew Marshall c3b83db725 module: Expose tests.enableOCR
Given we now have tests.bootCommands, in some cases the test script
given will need OCR enabled.
2024-11-20 07:19:25 +01:00
Andrew Marshall feeb365e31 module: Expose tests.bootCommands
Useful for e.g. interactive input during VM boot.
2024-11-20 07:19:25 +01:00
Felix Uhl bba79f6b5e disk-image: Fix "unexpected argument 'customQemu'" eval error
Previously, an error like

    error: function 'anonymous lambda' called with unexpected argument 'customQemu'

    at /nix/store/lbqj1cndic4121whnx8xm0jgb1c8x4xx-source/pkgs/build-support/vm/default.nix:1:1:

was printed when trying to evaluate `config.system.build.vmWithDisko` or
`config.system.build.diskoImagesScript` with nixpkgs 24.05 (and below).

This argument was added in
https://github.com/NixOS/nixpkgs/commit/65c851cd7523c669b8fb25236b1c48283a2f43ec,
so technically the minimum version is 24.11.20240708.65c851c. However,
`versionAtLeast` only compares versions alphabetically, so the comparison's
result will be incorrect for other commits made on the same day.

Instead, we compare against 24.11.20240709, which is the next day.
This means this function returns false for some commits that DO support the
customQemu argument, but if it returns true, we can be 100% certain that this
is correct, and we can pass the customQemu argument to vmTools without an
evaluation error.

Fixes #850
2024-10-28 14:38:07 +01:00
qbisi 9938afb435 options: make extraPostVM mergable. 2024-10-14 16:16:13 +00:00
Felix Uhl 72c867c439 Run nix fmt 2024-09-26 15:36:54 +02:00
Jörg Thalheim 51994df8ba imageBuilder: add defaultText
otherwise documentation depends on the hostname to be set
2024-09-20 14:23:16 +00:00
Michael Hoang c5853dcb32 module: throw if no disks are defined 2024-09-19 07:41:06 +07:00
Michael Hoang 706a1722f6 module: always populate system.build attributes 2024-09-19 06:53:45 +07:00
Michael Hoang cc4d4a4b91 make-disk-image: convert into NixOS module
As `makeDiskImages` always requires a NixOS configuration, we can
simplify the code by convering it into a NixOS module. Then we can make
it responsible for populating `system.build.diskoImages` and
`system.build.diskoImagesScript`.
2024-09-14 19:35:44 +10:00
Michael Hoang 0943a50ee7 interactive-vm: convert into NixOS module 2024-09-09 16:06:20 +10:00
Michael Hoang ba66c22ec1 Add virtualisation.vmVariantWithDisko option 2024-09-09 16:06:20 +10:00
lassulus 74a12fdf53 Merge pull request #742 from dasJ/fix/manual
Fix the manual by fixing string escape
2024-08-21 17:07:16 +02:00
lassulus 6433571556 Merge pull request #713 from nix-community/interactiveVM
add interactive VMs
2024-08-21 16:12:23 +02:00
Janne Heß 5b36e65c7c Fix the manual by fixing string escape 2024-08-21 12:56:32 +02:00
Maximilian Bosch ffc718f154 module: fix options.json rendering again 2024-08-20 14:06:57 +02:00
Sandro 1a0a69e2aa Fix options.json rendering 2024-08-18 17:36:27 +02:00
matthewcroughan d8a1d5e1f0 make-disk-image: allow vmTools qemu usage to be overriden by disko configuration
This is needed to prevent two layers of emulation when offering a build for a host running binfmt such as an x86 host trying to compile for aarch64 via binfmt
2024-08-14 20:05:56 +01:00
matthewcroughan de015d2a44 make-disk-image: allow pkgs to be overriden by disko configuration
This is needed when the nixosConfig you're building for modifies nixpkgs options that lead to evaluation failing unnecessarily
2024-08-14 20:05:56 +01:00
matthewcroughan f5cc4b55e5 make-disk-image: allow kernel to be overriden by disko configuration
This is especially useful when trying to build images for embedded systems such as the pi, which have a vendor kernel that can't be booted as part of the disko image builder process
2024-08-14 20:05:56 +01:00
lassulus a574d68d37 module: add vmWithDisko output to system 2024-08-01 13:00:08 +02:00
lassulus dd4d1663cc document extraRootModules better 2024-06-24 13:36:20 +00:00
matthewcroughan 23c63fb093 module: fix typo pkgs -> lib 2024-05-22 16:09:32 +00:00
matthewcroughan 4444751300 make-disk-image: make extraPostVM configurable from module.nix 2024-05-19 14:38:05 +01:00
fricklerhandwerk 2890a8c922 fix broken fallback
fixes an error when using this minimal configuration:

```nix
let
  pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11") { };
  disko = fetchTarball "https://github.com/nix-community/disko/tarball/master";
in
pkgs.nixos {
  imports = [
    "${disko}/module.nix"
    "${disko}/example/hybrid.nix"
  ];
}
```

when running:

```console
$ nix-build
...
error: 'default' at /nix/store/y981rwszq9yi36rvvz2vrr6hb22si0hc-source/lib/default.nix:391:23 called with unexpected argument 'system'
```
2023-12-24 18:44:46 +01:00
matthewcroughan 4c4634bbcb make-disk-image: allow extra dependencies to be passed into image builder 2023-12-14 14:24:37 +00:00
matthewcroughan bb75ad0b1d make-disk-image: inherit kernel from nixosConfiguration 2023-12-14 14:05:13 +00:00
matthewcroughan bd8fbc3f27 make-disk-image: make memSize configurable per disk
Sometimes the VM builder can run out of memory and fail to allocate memory when installing the system toplevel
2023-12-13 15:02:45 +00:00
Maximilian Bosch 6ad5c9c17c module: use defaultText to not depend on the configuration when building the manual
I do build my workstation with `documentation.nixos.includeAllModules`
to also have private modules and external stuff in my local options'
reference.

Not sure why exactly this breaks with

    error: attribute 'loader' missing

    at /nix/store/h6qicay9fgggx9nf6apdl6zkdpdp28xx-source/module.nix:46:19:

        45|         type = lib.types.bool;
        46|         default = config.boot.loader.systemd-boot.enable || config.boot.loader.grub.efiSupport;
          |                   ^
        47|       };

but using defaultText is the usual fix that also works here.
2023-10-13 20:57:40 +00:00
lassulus 9f29cedac7 rename makeDiskImage -> makeDiskImages 2023-09-18 12:16:33 +00:00
lassulus 56e6cad143 module: add images to system.build 2023-09-18 12:16:33 +00:00
Jörg Thalheim 9ab96378f8 reformat tree 2023-09-17 04:43:25 +00:00
lassulus f9907fcf6d module: add extraTestConfig 2023-09-09 13:32:33 +00:00
lassulus dd5cdd852c module: add tests.extraChecks 2023-09-02 10:14:48 +00:00
lassulus d53cd437d3 module: fix legacy aliases 2023-08-31 10:00:56 +00:00
Jörg Thalheim b32f0e2876 apply treefmt 2023-08-11 08:45:46 +00:00
a-kenji 4015740375 fix: typos 2023-07-30 17:43:54 +00:00
lassulus 1ddcff717c module: pass makeTest and eval-config to diskoLib 2023-07-20 21:32:53 +02:00
lassulus 4cad47f3fa module: expose diskoTest via system.build 2023-07-20 18:43:30 +02:00
lassulus cdaff66b57 lib: refactor outputs into toplevel 2023-07-19 19:07:40 +00:00
lassulus 1e7098ee04 diskoScript: add bash to PATH 2023-06-24 09:19:17 +00:00
lassulus 8e50c6da0d diskoNoDeps -> diskoScriptNoDeps 2023-06-24 09:19:17 +00:00