Commit graph

244 commits

Author SHA1 Message Date
Felix Uhl
21539593db disko2: Add rudimenatary "generate" mode 2024-10-27 20:44:53 +01:00
Felix Uhl
6f579bd98a disko2: Handle too many arguments error 2024-10-27 20:40:47 +01:00
Felix Uhl
196c746f7e disko2: Make CLI errors testable as well 2024-10-27 20:40:47 +01:00
Felix Uhl
47081e80ea disko2: Fix error type definitions 2024-10-27 16:15:09 +01:00
Felix Uhl
f2618b5490 disko2: Move to error codes and dedicated error rendering
This splits the concern of how to display errors off from the business
logic. This should make it easier to test functionality and allow us
to concentrate on how to actually display and communicate errors to the
user. At some point this might also make i18n feasible, because you only
have to swap out a single file.

This hasn't quite fixed the debug/trace story yet. It should be possible
to simply insert a "debug" command into any pipeline and see the context
and state at that point.
2024-10-25 23:10:57 +02:00
Felix Uhl
f34c39ec45 disko2: Add flake-output and package
This allows running `nix run .#disko2` for testing
2024-10-25 11:37:47 +02:00
Felix Uhl
62581f38f5 disko2: Split into modules 2024-10-25 11:13:10 +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 Madisetti
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
matthewcroughan
cc86fe1a7c f2fs: init 2024-08-20 10:26:29 +01: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
dylan madisetti
8d071db09b
test: fix and add stub test for zfs-with-vdevs 2024-08-05 12:11:35 -04:00
dylan madisetti
6bebcc728e
tidy: move relevant variables and format script block 2024-08-01 15:59:33 -04:00