Commit graph

84 commits

Author SHA1 Message Date
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
lassulus
7036bb8b30 disk-deactivate: execute directly instead of echoing script 2023-09-12 08:41:56 +00:00
Jörg Thalheim
c4f2de908d fix evaluation of checks on non-x86_64-linux
run nix fmt
2023-09-02 18:37:01 +02:00
Jörg Thalheim
b32f0e2876 apply treefmt 2023-08-11 08:45:46 +00:00
ktrinh-anduril
ceabbec315
Added missing dependency to destroyScript (#318)
* Added bash to destroScript dep

* Added jq directly as dep for destroyScript
2023-08-10 22:29:40 +02:00
lassulus
ab5f8eea75 make-disk-image: add impure variant 2023-08-07 15:57:14 +00:00
Jörg Thalheim
493b347d8f disko: drop binPrefix when building destroyScript
This seems to cause eval errors and I also don't know where this is supposed to come from
2023-08-06 16:28:59 +00:00
lassulus
a8834f94f3 lib: add makeDiskImage 2023-07-28 12:43:42 +00:00
lassulus
97b09a791f lib toplevel._scripts: set mountScriptNoDeps in correct namespace 2023-07-20 18:05:23 +02:00
lassulus
480d61c3f7 lib: rename umount to destroy 2023-07-19 19:07:40 +00:00
lassulus
056637d3c9 move tests/lib.nix into diskoLib.testLib 2023-07-19 19:07:40 +00:00
lassulus
cdaff66b57 lib: refactor outputs into toplevel 2023-07-19 19:07:40 +00:00
lassulus
c9c2fa9d3a lib: better formatting of generated shell output 2023-07-04 16:02:25 +00:00
lassulus
c52e425b02 lib: add indexOf function 2023-07-04 16:02:25 +00:00
lassulus
ab9b880db2 lib.types: turn _create, _mount and _config into values 2023-07-04 16:02:25 +00:00
lassulus
c230584db3 types: init table_gpt 2023-06-16 21:11:44 +02:00
lassulus
62f939e213 types: pass parent node to all subTypes 2023-06-16 21:11:44 +02:00
Jörg Thalheim
a8d85d9f89 apply deadnix 2023-06-06 13:32:47 +02:00
Lassulus
40f3218b14
Merge pull request #248 from nix-community/json-serializer 2023-06-03 16:47:15 +02:00