Commit graph

277 commits

Author SHA1 Message Date
Leonie Marcy Vack
c53bfaa13a zfs_volume: fix eval of _unmount if content is null 2025-01-16 14:46:04 +01:00
whs
ade21e2c96 Fix typo 2025-01-11 09:56:21 +00:00
Sávio
fe89f379e7 make-disk-image: fix function precedence breaks customQemu 2025-01-10 20:23:13 -03:00
Jörg Thalheim
7ea6edd857 zfs-with-vdevs: add an example for using absolute device paths
This is the only way to assign devices rather than fixed gpt partitions.
Without reading the code it's not very obvious how disko actually
assigns devices to zpools.
2024-12-24 14:45:56 +01:00
Jörg Thalheim
2ee76c861a
Merge pull request #921 from nix-community/zfs-fix
zfs: run load-key on mount/unmount
2024-12-20 14:26:41 +01:00
Jörg Thalheim
d8f3cfc582 zfs: run load-key on mount 2024-12-20 14:24:53 +01:00
Jörg Thalheim
dcd15a37f7 make-disk-image fix virtiofs support 2024-12-16 09:27:07 +01:00
Jörg Thalheim
2097ca7a9e
Merge pull request #916 from 0x450x6c/zvol_extra_args
Add extraArgs to zfs_volume.
2024-12-13 12:07:58 +01:00
neox
a0c967fef4 Add extraArgs to zfs_volume.
Update lib/types/zfs_volume.nix
2024-12-13 11:16:40 +01:00
Jörg Thalheim
22cd4b7e49 check for db.sqlite rather than /nix/store
since we initialize the database last, it's safe to use the database as
a sentinel path
2024-12-05 13:05:22 +01:00
Jörg Thalheim
98894c8598 make-disk-image: create directories images in out path
In case we are crossing some filesystem boundary (i.e. /tmp -> /nix/store),
this is faster. Also tmpfs might be probelemantic regarding memory usage.
2024-12-05 13:05:22 +01:00
Felix Uhl
67a130b984 tree-wide: Remove all uses of lib.mdDoc
This was deprecated in 24.05 already, and removed in 24.11.
2024-12-02 20:28:17 +01:00
Felix Uhl
3faa300212 disk-image: Fix compatibility with nixpkgs unstable
Fixes #900

This was caused by https://github.com/NixOS/nixpkgs/pull/354535
originally. The breaking changes introduced there have been resolved by
https://github.com/NixOS/nixpkgs/pull/360413, but one addition survived,
which was the line `source $stdenv/setup`.

Because we used `>` instead of `>>`, `saved-env` was overwritten, so
even with the second PR, the script failed with the following error:

    /nix/store/pw...ykc-vm-run-stage2: line 16: stdenv: unbound variable

Once this and the second PR mentioned above are merged, #903 will be
unblocked.
2024-11-30 17:36:29 +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
Gary Guo
3e83c11038 Fix evaluation when a GPT partition is left unformatted 2024-11-25 02:10:48 +00:00
Jörg Thalheim
47bc8dfb6f
Merge pull request #895 from nix-community/fix-mountoptions
also passthrough rootfs mountoptions
2024-11-24 22:11:48 +01:00
Jörg Thalheim
0433c7e883 also passthrough rootfs mountoptions 2024-11-24 18:39:57 +01:00
Jörg Thalheim
abc8baff33
Merge pull request #890 from nix-community/disko-install
disko-install: dry-run improvements
2024-11-22 15:10:44 +01:00
Jörg Thalheim
fd3e326e9a disable swap in disko-install
Update disko-install

Co-authored-by: Michael Hoang <Enzime@users.noreply.github.com>
2024-11-22 12:45:57 +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
Michon van Dooren
92ad678418
Add examples for all special zpool vdev types 2024-11-18 22:50:10 +01:00
Michon van Dooren
caad548415
Make vdev sort only move empty modes to the start 2024-11-18 22:49:51 +01:00
Michon van Dooren
d192ffd944
Fix zpool create for disk vdev after mirror vdev
A config like

```nix
{
  vdev = [
    {
      mode = "mirror";
      members = [ "data1" "data2" ];
    }
    {
      members = [ "data3" ];
    }
  ];
}
```

would result in the following command:

```shell
zpool create -f <name> mirror /dev/data1 /dev/data2 /dev/data3
```

which would result in a single vdev with a 3-way mirror, rather than a
vdev with a 2-way mirror and a second vdev with a single disk. By
reordering the vdevs to handle those with an empty mode first we
transform this into:

```shell
zpool create -f <name> /dev/data3 mirror /dev/data1 /dev/data2
```

which does have the desired outcome.
2024-11-18 01:33:49 +01:00
Michon van Dooren
6a472cc248
Fix zpool create with > 1 log/dedup/special vdev
The type keyword was included before every vdev:

```shell
zpool create -f <name> /dev/sda log mirror /dev/sdb /dev/sdc log mirror /dev/sdd /dev/sde
```

but this is incorrect and should instead be:

```shell
zpool create -f <name> /dev/sda log mirror /dev/sdb /dev/sdc mirror /dev/sdd /dev/sde
```
2024-11-17 22:19:33 +01:00
Michon van Dooren
9b56c1afdb
Add support for ZFS spare, log & dedup vdevs 2024-11-17 15:52:28 +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
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
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
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