Commit graph

145 commits

Author SHA1 Message Date
Felix Uhl
db57281c83 disko2: Fix dedenting bug 2024-11-27 23:18:54 +01:00
Felix Uhl
cfcc518b70 disko2: Add rudimentary plan generation 2024-11-27 23:18:54 +01:00
Felix Uhl
6651792c28 disko2: Validate config for type-safety in python 2024-11-17 21:37:39 +01:00
Felix Uhl
ae7891e21f disko2: Fix all mypy type checking errors
Belongs to d382a3cccf, but I authored that
on another machine.

Making sure vscode uses mypy from the environment is very important now,
because some of these errors get triggered in different ways depending
on the version.
2024-11-17 19:39:07 +01:00
Felix Uhl
70efb0a658 lib: Evaluate partition's _index parameter
This is required to be able to generate sgdisk invocations that are
equivalent to what's currently generated in nix.
2024-11-10 17:39:39 +01:00
Felix Uhl
4f16850ca4 lib: Detect and show new keys in dict_diff 2024-11-10 17:31:44 +01:00
Felix Uhl
c5d1a42af7 tests: Put tests with snapshots into directories
This makes the tests more readable and easier to browse.
Making sure the tests always run fine, no matter from which directory
they're started is a little detail we should either test for or
document.
2024-11-08 21:39:34 +01:00
Felix Uhl
6b360a2534 tests: Add simple tests for eval_config.py 2024-11-08 20:22:46 +01:00
Felix Uhl
963b49d314 lib: Add dict_diff
This allows to create plans only based on the things that changed in the
configuration.
2024-11-08 20:12:05 +01:00
Felix Uhl
da8a997397 dev: Switch to ruff for python linting & formatting
It combines multiple tools and is much faster.
2024-11-08 20:12:05 +01:00
Felix Uhl
a6944c6bea disko2: Make messages type-safe and modular
Using untyped dicts was not a safe way to pass arguments to error
message rendering. Also, having one giant match statement wouldn't scale
well. Using function pointers and kwargs, mypy can now properly check
whether all required arguments are passed to DiskoMessage().

As a bonus, it's now easy to use the "Go to definition" LSP command for
error codes, which wasn't possible before.
2024-11-03 22:35:06 +01:00
Felix Uhl
0cd949092d disko2: Add test for generate_config 2024-11-03 20:59:56 +01:00
Felix Uhl
737e045f53 tests: Move example tests to dedicated folder 2024-10-31 17:03:52 +01:00
Felix Uhl
389235b63f disko2: Create package
This requires a lot of restructuring. The .nix files have to be bundled
together with the python files, so they need to follow python's module
system structure.

I ran `nix-fast-build --no-link -j 2 --eval-workers 3 --flake .#checks`
and it succeeded, so I'm reasonably confident I changed everything as
required.
2024-10-30 23:54:41 +01: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
Chris Scutcher
78d685c123 tests: Add failing test to demonstrate issues with whitespace in part names
Reproduces #130.

For new style table the generated script has a few problems for example;

```sh
    sgdisk \
      --new=2:0:+100M \
      --change-name=2:disk-vdb-name with spaces \
      --typecode=2:EF00 \
      /dev/vdb
```

and

```sh
mkfs.vfat \
         \
        /dev/disk/by-partlabel/disk-vdb-name with spaces
```

Legacy table style generates slightly different problems e.g.;

```sh
parted -s /dev/vdb -- mkpart name with spaces  1MiB 100MiB
```
2024-10-22 09:10:08 +00:00
Felix Uhl
dcabccaad6 swap: fix partition type
Fixes #391
2024-10-16 17:05:43 +00:00
Felix Uhl
aee84b5fb3 disko cli: add --version command
Fixes #745

This adds a script to create a release. Running it will create two
commits that would appear like this in `git log --oneline`:

    67b5fff (master) release: reset released flag
    0b808f3 (tag: v1.8.1) release: v1.8.1
    100d2f3 docs: last change before release

It also re-creates the `version.nix` file, which is used by the flake
to determine the final version the disko CLI will print.

If `disko --version` is run from exactly the commit tagged `v1.8.1`, it
will print `1.8.1`. If it is run from any commit past that (like
master), it will print `1.8.1-67b5fff`, and if it is run from a local
folder with uncommitted changes, it will print `1.8.1-67b5fff-dirty`.
2024-10-11 15:14:56 +00:00
Felix Uhl
ba436edc9d Test luks-encrypted btrfs raid 2024-10-01 19:34:46 +02:00
Jörg Thalheim
4e30bc7921 zfs-with-vdevs: increase pool import timeout
Fix fixes a long-standing test failures we have with the zfs-with-vdevs.
2024-10-01 10:08:10 +02:00
Felix Uhl
72c867c439 Run nix fmt 2024-09-26 15:36:54 +02: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
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
cf5d451adc
test: Add cache specific test 2024-08-27 08:29:31 -04:00
matthewcroughan
cc86fe1a7c f2fs: init 2024-08-20 10:26:29 +01:00
dylan madisetti
8d071db09b
test: fix and add stub test for zfs-with-vdevs 2024-08-05 12:11:35 -04:00
Matthew_Cash
b6a1262796 lvm_vg: add lvm thinpool/thinlv support
Co-authored-by: ajs124 <git@ajs124.de>
2024-06-26 11:36:52 +00:00
Jörg Thalheim
804ab2de77 treewide: reformat with nix fmt 2024-06-09 06:40:59 +00:00
Jörg Thalheim
398acc470f update to new nixos test api 2024-06-07 14:20:40 +00:00
Jörg Thalheim
babc1554e8 drop duplicated disko-install definition 2024-05-07 08:53:10 +02:00
Jörg Thalheim
cdefe26742 load database with checksum again but do the same in disko-install 2024-05-07 08:53:10 +02:00
Kira Bruneau
79eab0e82c types btrfs: fix format without swap or subvolumes 2024-04-08 21:37:04 +00:00
lassulus
e18e85ba3f tests/make-disk-image: increase memSize 2024-04-08 18:40:31 +02:00
Jörg Thalheim
72818e54ec move disko-install into disko package 2024-03-09 07:05:35 +00:00
Jörg Thalheim
0d11aa8d64 disko-install: add extra-files option 2024-03-05 09:52:34 +00:00
lassulus
05f0e3fd56 lib/tests: use startCommand for create_machine 2024-03-05 08:56:58 +01:00
Jörg Thalheim
0c9b003a48 bcachefs: drop zfs hack 2024-03-05 08:56:58 +01:00
lassulus
561579a631 add long-device-name test & example 2024-03-04 14:55:56 +01:00
Jörg Thalheim
bde7dd352c add disko-install command
disko-install combines disko and nixos-install into a single command.

Example usage:

  sudo ./disko-install --flake /someflake#eva --disk sda /dev/zvol/zroot/test
2024-03-01 09:48:08 +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
Jörg Thalheim
c12719812d bcachefs: stick to nixos's default bcachefs kernel 2024-01-26 09:38:59 +00:00
Jörg Thalheim
38af7137e0 tests/bcachefs: switch to linux_latest 2024-01-15 14:29:04 +00:00
Michael Hoang
583bdf4fc6 tests: check canmount ZFS flag is respected 2024-01-01 01:09:11 +00:00
Michael Hoang
4346558fd4 tests: add test for running ZFS as not the rootfs 2023-12-19 23:49:20 +11:00
Jörg Thalheim
98ab911097 bcachefs: set testing kernel for bcachefs
still waiting for the slow upstream review...
2023-12-14 16:02:39 +00:00
lassulus
e7ed2e9239 tests bcachefs: use linux_testing 2023-12-14 16:02:39 +00:00
lassulus
41d3be72d7 tests *: don't test for zfs in /dev 2023-12-14 16:02:39 +00:00
Jörg Thalheim
1144887c6f lvm: update kernel modules when creating raid 2023-12-06 23:28:45 +00:00
Jörg Thalheim
3cb78c93e6 swap: don't activate random encrypted swap files
This requires more code and is not implemented just now.
2023-11-25 15:47:29 +00: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