Commit Graph
250 Commits
Author SHA1 Message Date
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
Jörg Thalheim 6bfa3a18d4 tests/interactive-cryptsetup: make waiting for passphrase more robust 2024-11-08 11:07:09 +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
Pablo Ovelleiro Corral 380847d94f Add kmod to dependencies
Fixes #857
2024-11-04 00:11:01 +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
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
DavHau 58cd832497 lvm_vg: fix size=100% leading to crash
lvcreate -l does not accept a '100%' parameter which currently leads to a crash. THis change automatically changes `100%` to `100%FREE` leading to the intended behavior.
2024-10-26 11:42:42 +00: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 4be2aadf13 lib: use lib.escapeShellArg for concatenated paths 2024-10-22 09:10:08 +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 dcabccaad6 swap: fix partition type
Fixes #391
2024-10-16 17:05:43 +00:00
Felix Uhl c8760cee70 cli: stop using system dependencies in destroy step
Fixes #815
2024-10-16 09:22:47 +00:00
qbisi ef408f7f9a options: add imageName option to disk type.
For disk type, option name used in disk partlabel
naming should be short. While setting a specialized
option imageName allow us to create image with long name
without side-effects.
2024-10-14 16:16:13 +00:00
Jörg Thalheim 28c5af1e16 interactive-vm: allow to override virtualisation.memorySize
Users might set this value for building images but than need different
values when they run interactive virtual machines.
2024-10-05 06:23:52 +00:00
Jörg Thalheim fc3ba6985f only set boot.initrd.preDeviceCommands if we boot with script-based stage1 2024-10-01 09:58:39 +02:00
Jörg Thalheim 91cd091669 zpool: fix default value for cache
we want an empty list instead of null
2024-10-01 08:55:41 +02:00
Michael Hoang b709e1cc33 interactive-vm: override forceImportRoot
Some users will have `boot.zfs.forceImportRoot = false;` in their
configurations which conflicts with `boot.zfs.forceImportAll = true;`,
so we set it to `true` to match.
2024-09-28 13:50:34 +00:00
Felix Uhl 72c867c439 Run nix fmt 2024-09-26 15:36:54 +02:00
danjujan 18c5410fdf make-disk-image: use memSize as default build-memory in diskoImagesScript 2024-09-26 12:28:15 +02:00
r-vdp 1f8e67e945 Always add dm-snapshot when LVM is used
The lvm_type is only set on RAID and thinly provisioned LVM volumes, but
regular LVM volumes without a type can also have snapshots.
2024-09-25 09:30:14 +02:00
Jörg Thalheim 6d42596a35 lvm: add missing dm-snapshot
Usually this is added by nixos-generate-config.
However now that we run nixos-generate-config before disko or we even
run nixos-facter, we likely not see the LVM block devices anymore.
2024-09-24 16:53:30 +00:00
zerox b1d6bed240 interactive-vm: use host pkgs in the launcher script. 2024-09-23 13:23:58 +00:00
Jörg Thalheim da8bfaf1d5 shellcheck: also disable SC2054 2024-09-20 14:55:36 +02:00
Jörg Thalheim bc7fd7238a filesystem: escape shell args 2024-09-20 14:47:45 +02:00
Michael Hoang c5853dcb32 module: throw if no disks are defined 2024-09-19 07:41:06 +07:00
Michael Hoang d32d1504c7 zpool: support updating zfsprops on root dataset 2024-09-17 16:35:12 +00:00
Michael Hoang a9eeea3379 zfs_fs: support updating mountpoint properly
Use `zfs set -u` to update the `mountpoint` flag without mounting or
unmounting the filesystem. This flag was added in OpenZFS 2.2.0, which
was released October 2023.

The previous logic would not update `mountpoint` if `config.options` was
empty or only contained `mountpoint`.
2024-09-17 16:35:12 +00:00
Michael Hoang 88b015b9eb make-disk-image: fix spelling for --help 2024-09-17 14:02:43 +00: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 59fb64b36b make-disk-image: automatically add ZFS to kernel
Fixes #461
2024-09-12 15:06:25 +00: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 8f0f75f1a8 zpool: better error message if zpool has no assigned devices 2024-09-03 17:11:42 +02: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
Sergey Kazenyuk 099b6cca33 btrfs: add swap priority, options 2024-09-03 14:06:14 +00:00
Sergey Kazenyuk 39b4091769 swap: add mountOptions 2024-09-03 14:06:14 +00:00
zerox 70a22d25a2 Switch to qcow2 in the interactive VM. 2024-08-31 09:57:41 +05:00
whs 517664d2fd Fix writeDashBin 2024-08-27 21:03:36 +08:00
Dylan MadisettiandJörg Thalheim 071306e76a tidy: apply suggestions from code review
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2024-08-26 14:13:07 -04:00
dylan madisetti c9d3bc3755 fix: properly apply oneOf 2024-08-26 14:00:44 -04:00
dylan madisetti ea3ce722ea zfs: fix test and add documentation 2024-08-26 13:03:25 -04:00
dylan madisetti cc2e247193 zfs: make topology a mode type 2024-08-26 12:27:04 -04:00
zerox 540cd416f6 zfs: add ability to specify full path of to the disk. 2024-08-26 09:48:53 +05:00
Felix Uhl 435737144b swap: don't create filesystem if randomEncryption is enabled
This is not an issue when initially creating the partition because
device mapper will just map on top of the filesystem, but it breaks
incremental updates because the check for `TYPE=` will fail, and the
subsequent attempt to run `mkswap` also fails:

mkswap: cannot open /dev/disk/by-partlabel/disk-nix-store-swap: Device or resource busy

Instead, just don't do anything, NixOS will take care of it.
2024-08-22 17:59:43 +00:00
Felix Uhl f6b2e0052d zfs_fs: Fix errors when not changing mountpoint
Running `zfs set mountpoint=/mnt/my-ds tank/my-ds`, ZFS may try to
unmount the dataset even if the mountpoint didn't change.
To avoid the confusing error message, this command is now only run when
the mountpoint actually changes.
2024-08-22 17:50:13 +00:00
lassulus 6433571556 Merge pull request #713 from nix-community/interactiveVM
add interactive VMs
2024-08-21 16:12:23 +02:00