Commit graph

102 commits

Author SHA1 Message Date
Michael Hoang
f2bba803a7 treewide: reformat 2025-12-14 04:58:58 +00:00
Jörg Thalheim
a19c2b6d3a tests: use nixpkgs qemu-common for proper machine type configuration
QEMU on aarch64 requires an explicit machine type (e.g., '-machine virt'),
unlike x86_64 which has a default. Previously, the test script hardcoded
'qemu-kvm' without machine type arguments, causing aarch64 tests to fail
with "No machine specified, and there is no default".

By importing and using nixpkgs' qemu-common.nix library, we reuse the
existing platform-specific QEMU configuration logic.
2025-11-20 13:42:11 +00:00
Glen Huang
3db2f04765 allow subtype definitions to be broken up 2025-07-21 12:13:55 +00:00
Philipp Schmitt
69265ccde5 Fix _destroy 2025-05-08 09:13:14 +00:00
Philipp Schmitt
aa5d53aee8 Add disk.destroy option 2025-05-08 09:13:14 +00:00
nothingnesses
ca27b88c88 Add bcachefs type with encryption and multi-disk support
This update introduces a bcachefs type with encryption support and advanced formatting options.
It includes a new example (`examples/bcachefs-multi-disk.nix`) to demonstrate multi-disk setups and available options.

Key changes:

- Deterministic UUID generation.
- Addressed limitations with multi-disk root setups due to bcachefs and systemd issues.
- Provided a systemd-mount alternative for fileSystems configuration.
- Added subvolume support and updated scripts for clarity and functionality.

---------

Co-authored-by: Jonas Heinrich <onny@project-insanity.org>
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
Co-authored-by: Kyle Petryszak <6314611+ProjectInitiative@users.noreply.github.com>

Update
* Add examples
* Improve descriptions

Remove debugging

Remove comment

Use `unique` to dedup lists
2025-04-24 13:41:42 +00:00
rszyma
19c1140419 fix schellcheck warning failing build 2025-02-25 12:19:28 +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
lassulus
85942f35d3 Revert "Fix: Device dependencies not sorting correctly"
This reverts commit 40da43e8e5.
2025-02-14 07:40:53 +00:00
Kyle Petryszak
40da43e8e5 Fix: Device dependencies not sorting correctly 2025-02-14 07:22:23 +00:00
lassulus
26ade10051 lib: fix recursiveUpdate not merging lists 2025-02-12 10:45:46 +01:00
Jörg Thalheim
b71e3faca9
Merge pull request #906 from nix-community/fix-904
make-disk-image: Compare against correct nixpkgs version
2024-11-29 23:29:22 +01: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
Jörg Thalheim
aa006252c8 add unmount feature 2024-11-29 14:44:15 +01:00
zimbatm
3a8a8713bf fix: restore nix 2.3 compatibility
Apparently nix 2.3 didn't support path interpolations.
2024-11-22 09:17:20 +01:00
Felix Uhl
9f97bd0995 lib: Fix jsonTypes evaluation
This will be very useful for generating documentation.

Backported from a5c646bd93 for #789
2024-11-16 08:21:10 +00:00
Felix Uhl
9c7de5582e destroy: Fix shellcheck warning in nixos 24.05
Regression introduced in 94bc0f5bb0,
because I developed against unstable, which has
https://github.com/NixOS/nixpkgs/pull/333744 merged, while 24.05
doesn't.

Partly shellchecks mistake, see
https://github.com/koalaman/shellcheck/issues/2891 but whatever, we
can't do much more about it than ignore the warning.

Fixes #868
2024-11-13 23:20:40 +01:00
Felix Uhl
94bc0f5bb0 mode destroy: Add confirmation dialogue
The new confirmation dialogue is only shown for the new outputs
introduced in the previous commits. The existing outputs do not change
behavior to keep backwards compatibility.

Fixes #725
2024-11-06 21:16:18 +01:00
Felix Uhl
daca7be309 outputs: make compatible with nix run and package lists
This adds new outpus like `format` and `formatNoDeps` which
are compatible with `nix run` so you can do something like

    nix run .#nixosConfigurations.myhostname.config.system.build.formatNoDeps

as originally intended in #78, or add disko to your configuration like

    environment.systemPackages = [
        config.system.build.format
        config.system.build.mount
        config.system.build.destroyFormatMount
    ];

as mentioned in #454.

Fixes part of #454
Supersedes #78

It also deprecates mode `disko` in favor of the clearer
`destroy,format,mount` and adds `format,mount` to allow easier in-place
updates.
2024-11-06 21:16:18 +01:00
Andrew Marshall
3979285062 treewide: Fix using pkgs.{build,host}Platform alias
This was recently changed in nixpkgs to be an alias; if nixpkgs is
configured to disable aliases, this usage will fail.
2024-10-29 09:32:41 +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
65c851cd75,
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
phaer
09a776702b fix: avoid calling splitString ""...
because it breaks evaluation on darwin with at least nix 2.18.

Evaluating `lib.splitString "" "foo"` throws the following:
`error: invalid regular expression ''`.

We could avoid that by using lib.stringToCharacters, but as
we are mapping over it anyway, lib.stringAsChars seems to be
an even better fit.

I tested the examples in hexEscapeUdevSymlinks docstring manually
in a nix repl.
2024-10-23 19:46:38 +00:00
Felix Uhl
ca47da60e5 disko: fix improper handling of whitespace
Fixes #130

This should fix pretty much all cases where spaces or other special
characters would break disko due to improper quoting. I searched for all
instances of '.label', '.device' and '.name', so I believe I caught
whatever I could.

In some cases I changed single quotes to double quotes for consistency.

I know we don't usually fix bugs in the legacy table type, but it was so
easy I couldn't resist.
2024-10-22 09:10:08 +00:00
Felix Uhl
a6a3179ddf cli: stop using system dependencies in destroy step
re-applying 15aa78e9a5 because I
accidentally overwrote it in 15aa78e9a5.
2024-10-18 21:59:08 +02:00
Felix Uhl
15aa78e9a5 lib: Remove global with lib;
This is generally regarded as a code-smell. I did utilize `with lib;`
in some places where I felt it aided readability, but it's very clearly
scoped in those situations.

See https://github.com/nix-community/disko/pull/835#issuecomment-2416126497
2024-10-16 17:17:32 +00:00
Felix Uhl
c8760cee70 cli: stop using system dependencies in destroy step
Fixes #815
2024-10-16 09:22:47 +00:00
Jörg Thalheim
da8bfaf1d5 shellcheck: also disable SC2054 2024-09-20 14:55:36 +02:00
Michael Hoang
c5853dcb32 module: throw if no disks are defined 2024-09-19 07:41:06 +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
Jörg Thalheim
37c83c08d1
Merge pull request #723 from dmadisetti/dm/zfs-extra
zfs: add ZFS "topology" features like explicit vdevs, cache, and special
2024-09-03 17:07:39 +02:00
dylan madisetti
cc2e247193
zfs: make topology a mode type 2024-08-26 12:27:04 -04:00
dylan madisetti
b2a106f8ed
zfs: Add topology attribute to zpool 2024-08-01 15:41:09 -04:00
lassulus
a574d68d37 module: add vmWithDisko output to system 2024-08-01 13:00:08 +02:00
name_snrl
48580409a2 also add indentation to the hooks 2024-06-19 18:46:17 +00:00
name_snrl
248f65b9c4 fix option type in mkHook 2024-06-19 18:46:17 +00:00
Jared Baur
e9dd5abae3
Add coreutils to list of dependencies
This allows for the disko scripts to be ran in more foreign environments
where we can't assume the basic utilities coreutils provides are
available or aren't 1-for-1 compatible (e.g. busybox utilities).
2024-05-15 09:57:53 -07:00
Jared Baur
27c40e5381
Add missing gawk dependency 2024-05-15 09:57:25 -07:00
Sizhe Zhao
874c83c948 fix(lib): fix typo 2024-05-07 07:34:02 +00:00
Qubasa
9f5d4e45cd nix fmt 2024-04-29 14:57:02 +00:00
Jared Baur
8d4ae698ea Use existing bash instance when running destroyScript
The destroy script already has a bash interpreter in use, but when the
`disk-deactivate` script is ran, it calls out to /usr/bin/env to query
for a bash interpreter. When running the destroyScript in unique places
(such as the stage-1 initrd), /usr/bin/env might not exist, so we can
make destroyScript more self-contained by reusing the same bash.
2024-04-12 18:51:46 +00:00
Jared Baur
0a17298c0d Add missing dependency gnused
gnused is used in the disk-deactivate.jq script, but was not defined in
the list of dependencies.
2024-04-05 22:34:38 +00:00
danjujan
f7424625dc
Rework Hybrid MBR https://github.com/nix-community/disko/pull/168 (#508)
Add hybrid MBR functionality to the gpt type
2024-01-26 21:59:23 +01:00
Andrew Marshall
2d7d77878c Implement preMountHook & postMountHook
These options previously existed but had no effect. Now they are
implemented. They only affect mount during disko’s filesystem creation,
not during any later mounts.

Adding test case to existing “complex” example and test mostly because
couldn’t think of any better place to put it.
2023-11-12 09:36:50 +00:00
Aleksander Heintz
72bc152626 add btrfs swap support 2023-11-08 22:36:40 +00:00
lassulus
2bf4fc166b flake: deprecate .lib.lib 2023-09-26 14:00:14 +00:00
lassulus
9f29cedac7 rename makeDiskImage -> makeDiskImages 2023-09-18 12:16:33 +00:00
Jörg Thalheim
9ab96378f8 reformat tree 2023-09-17 04:43:25 +00:00