Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nix-community/disko
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.7.0
Choose a base ref
...
head repository: nix-community/disko
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 5,214 additions and 2,028 deletions.
  1. +1 −0 .envrc
  2. +35 −0 .git-blame-ignore-revs
  3. +2 −2 .github/workflows/update-flake-lock.yml
  4. +5 −0 .gitignore
  5. +2 −5 .mergify.yml
  6. +39 −0 CONTRIBUTING.md
  7. +7 −5 README.md
  8. +92 −39 cli.nix
  9. +91 −27 default.nix
  10. +51 −10 disko
  11. +36 −9 disko-install
  12. +18 −10 doc.nix
  13. +2 −1 docs/HowTo.md
  14. +7 −1 docs/INDEX.md
  15. +38 −13 docs/disko-images.md
  16. +16 −8 docs/disko-install.md
  17. +18 −9 docs/interactive-vm.md
  18. BIN docs/logo.jpeg
  19. BIN docs/logo.png
  20. +3 −3 docs/quickstart.md
  21. +8 −4 docs/reference.md
  22. +4 −2 docs/table-to-gpt.md
  23. +160 −0 docs/testing.md
  24. +1 −0 example/bcachefs.nix
  25. +1 −0 example/boot-raid1.nix
  26. +5 −2 example/btrfs-only-root-subvolume.nix
  27. +5 −2 example/btrfs-subvolumes.nix
  28. +2 −0 example/complex.nix
  29. +8 −1 example/f2fs.nix
  30. +49 −0 example/gpt-name-with-whitespace.nix
  31. +37 −0 example/gpt-unformatted.nix
  32. +1 −0 example/hybrid-mbr.nix
  33. +1 −0 example/hybrid-tmpfs-on-root.nix
  34. +1 −1 example/hybrid.nix
  35. +51 −0 example/legacy-table-with-whitespace.nix
  36. +1 −1 example/legacy-table.nix
  37. +1 −1 example/long-device-name.nix
  38. +78 −0 example/luks-btrfs-raid.nix
  39. +13 −6 example/luks-btrfs-subvolumes.nix
  40. +1 −0 example/luks-interactive-login.nix
  41. +2 −4 example/luks-lvm.nix
  42. +1 −1 example/luks-on-mdadm.nix
  43. +1 −0 example/lvm-raid.nix
  44. +1 −0 example/lvm-sizes-sort.nix
  45. +1 −3 example/lvm-thin.nix
  46. +1 −1 example/non-root-zfs.nix
  47. +1 −1 example/simple-efi.nix
  48. +4 −3 example/stand-alone/configuration.nix
  49. +1 −0 example/swap.nix
  50. +1 −1 example/tmpfs.nix
  51. +6 −1 example/with-lib.nix
  52. +37 −0 example/xfs-with-quota.nix
  53. +63 −0 example/zfs-encrypted-root.nix
  54. +2 −4 example/zfs-over-legacy.nix
  55. +215 −11 example/zfs-with-vdevs.nix
  56. +22 −2 example/zfs.nix
  57. +3 −3 flake.lock
  58. +64 −37 flake.nix
  59. +21 −23 install-cli.nix
  60. +181 −0 lib/binfmt.nix
  61. +819 −273 lib/default.nix
  62. +66 −68 lib/interactive-vm.nix
  63. +158 −91 lib/make-disk-image.nix
  64. +315 −244 lib/tests.nix
  65. +175 −123 lib/types/btrfs.nix
  66. +31 −7 lib/types/disk.nix
  67. +51 −18 lib/types/filesystem.nix
  68. +296 −188 lib/types/gpt.nix
  69. +82 −39 lib/types/luks.nix
  70. +20 −5 lib/types/lvm_pv.nix
  71. +140 −82 lib/types/lvm_vg.nix
  72. +67 −25 lib/types/mdadm.nix
  73. +14 −2 lib/types/mdraid.nix
  74. +19 −2 lib/types/nodev.nix
  75. +54 −27 lib/types/swap.nix
  76. +222 −157 lib/types/table.nix
  77. +14 −2 lib/types/zfs.nix
  78. +105 −63 lib/types/zfs_fs.nix
  79. +56 −17 lib/types/zfs_volume.nix
  80. +281 −102 lib/types/zpool.nix
  81. +206 −86 module.nix
  82. +52 −27 package.nix
  83. +18 −0 scripts/create-release.nix
  84. +67 −0 scripts/create-release.sh
  85. +3 −2 tests/bcachefs.nix
  86. +3 −2 tests/boot-raid1.nix
  87. +3 −2 tests/btrfs-only-root-subvolume.nix
  88. +3 −3 tests/btrfs-subvolumes.nix
  89. +7 −3 tests/cli.nix
  90. +8 −4 tests/complex.nix
  91. +19 −11 tests/default.nix
  92. +23 −6 tests/disko-install/configuration.nix
  93. +11 −2 tests/disko-install/default.nix
  94. +3 −2 tests/f2fs.nix
  95. +3 −2 tests/gpt-bios-compat.nix
  96. +14 −0 tests/gpt-name-with-special-chars.nix
  97. +12 −0 tests/gpt-unformatted.nix
  98. +3 −2 tests/hybrid-mbr.nix
  99. +3 −2 tests/hybrid-tmpfs-on-root.nix
  100. +3 −2 tests/hybrid.nix
  101. +13 −0 tests/legacy-table-with-whitespace.nix
  102. +3 −2 tests/legacy-table.nix
  103. +3 −2 tests/long-device-name.nix
  104. +14 −0 tests/luks-btrfs-raid.nix
  105. +3 −2 tests/luks-btrfs-subvolumes.nix
  106. +6 −4 tests/luks-interactive-login.nix
  107. +3 −2 tests/luks-lvm.nix
  108. +3 −2 tests/luks-on-mdadm.nix
  109. +8 −3 tests/lvm-raid.nix
  110. +3 −2 tests/lvm-sizes-sort.nix
  111. +3 −2 tests/lvm-thin.nix
  112. +14 −12 tests/make-disk-image-impure.nix
  113. +14 −10 tests/make-disk-image.nix
  114. +3 −2 tests/mdadm-raid0.nix
  115. +3 −2 tests/mdadm.nix
  116. +7 −3 tests/module.nix
  117. +3 −2 tests/multi-device-no-deps.nix
  118. +3 −2 tests/negative-size.nix
  119. +3 −2 tests/non-root-zfs.nix
  120. +3 −2 tests/simple-efi.nix
  121. +3 −2 tests/standalone.nix
  122. +18 −5 tests/swap.nix
  123. +3 −2 tests/tmpfs.nix
  124. +3 −2 tests/with-lib.nix
  125. +14 −0 tests/xfs.nix
  126. +17 −0 tests/zfs-encrypted-root.nix
  127. +3 −3 tests/zfs-over-legacy.nix
  128. +47 −2 tests/zfs-with-vdevs.nix
  129. +8 −4 tests/zfs.nix
  130. +11 −0 treefmt.toml
  131. +4 −0 version.nix
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
35 changes: 35 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file contains a list of commits that are not likely what you
# are looking for in a blame, such as mass reformatting or renaming.
#
# If a commit's line ends with `# !autorebase <command>`,
# where <command> is an idempotent bash command that reapplies the changes from the commit,
# the `https://github.com/NixOS/nixpkgs/blob/master/maintainers/scripts/auto-rebase/run.sh` script can be used to rebase
# across that commit while automatically resolving merge conflicts caused by the commit.
#
# You can set this file as a default ignore file for blame by running
# the following command.
#
# $ git config blame.ignoreRevsFile .git-blame-ignore-revs
#
# To temporarily not use this file add
# --ignore-revs-file=""
# to your blame command.
#
# The ignoreRevsFile can't be set globally due to blame failing if the file isn't present.
# To not have to set the option in every repository it is needed in,
# save the following script in your path with the name "git-bblame"
# now you can run
# $ git bblame $FILE
# to use the .git-blame-ignore-revs file if it is present.
#
# #!/usr/bin/env bash
# repo_root=$(git rev-parse --show-toplevel)
# if [[ -e $repo_root/.git-blame-ignore-revs ]]; then
# git blame --ignore-revs-file="$repo_root/.git-blame-ignore-revs" $@
# else
# git blame $@
# fi


# treewide: format all files
bd9da344ab53d297bd3e2baab0805b2e51b31136
4 changes: 2 additions & 2 deletions .github/workflows/update-flake-lock.yml
Original file line number Diff line number Diff line change
@@ -13,9 +13,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@V27
uses: cachix/install-nix-action@v30
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@v23
uses: DeterminateSystems/update-flake-lock@v24
with:
pr-labels: |
merge-queue
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
result
result-*
.direnv/

# Created by the NixOS interactive test driver
.nixos-test-history
7 changes: 2 additions & 5 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
queue_rules:
- name: default
merge_conditions:
- check-success=buildbot/nix-eval
defaults:
actions:
queue:
merge_method: rebase
- check-success=buildbot/nix-build
merge_method: rebase
pull_request_rules:
- name: merge using the merge queue
conditions:
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing

We welcome contributions of all kinds, be it in terms of bug fixes,
reproductions, features or documentation.

In general, PRs are more likely to be merged quickly if they contain tests which
prove that a feature is working as intended or that a bug was indeed present and
has now been fixed. Creating a draft PR that reproduces a bug is also a great
way to help us fix issues quickly. Check out
[this PR](https://github.com/nix-community/disko/pull/330) as an example.

For more information on how to run and debug tests, check out
[Running and debugging tests](./docs/testing.md).

## How to find issues to work on

If you're looking for a low-hanging fruit, check out
[this list of `good first issue`s](https://github.com/nix-community/disko/labels/good%20first%20issue).
These are issues that we have confirmed to be real and which have a strategy for
a fix already lined out in the comments. All you need to do is implement.

If you're looking for something more challenging, check out
[this list of issues tagged `contributions welcome`](https://github.com/nix-community/disko/labels/contributions%20welcome).
These are issues that we have confirmed to be real and we know we want to be
fixed.

For the real though nuts, we also have
[the `help wanted` label](https://github.com/nix-community/disko/labels/help%20wanted)
for issues that we feel like we need external help with. If you want a real
challenge, take a look there!

If you're looking for bugs that still need to be reproduced, have a look at
[this list of non-`confirmed` bugs](https://github.com/nix-community/disko/issues?q=is%3Aissue+is%3Aopen+label%3Abug+-label%3Aconfirmed+).
These are things that look like bugs but that we haven't reproduced yet.

If you're looking to contribute to the documentation, check out
[the `documentation` tag](https://github.com/nix-community/disko/issues?q=is%3Aissue+is%3Aopen+label%3Adocumentation)
or just read through [our docs](./docs/INDEX.md) and see if you can find any
issues.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# disko - Declarative disk partitioning

<!-- Generated with bing image generator (which uses dall-e-2): edge-gpt-image --prompt "Disco ball shooting a laser beam at one hard drive" -->

<img title="" src="./docs/logo.jpeg" alt="Project logo" width="274">
<img title="" src="./docs/logo.png" alt="Project logo" width="274">

[Documentation Index](./docs/INDEX.md)

@@ -42,7 +40,8 @@ recursive layouts.
Disko doesn't require installation: it can be run directly from nix-community
repository. The [Quickstart Guide](./docs/quickstart.md) documents how to run
Disko in its simplest form when installing NixOS. Alternatively, you can also
use the new [disko-install](./docs/disko-install.md) tool, which combines `disko` and `nixos-install` into one step.
use the new [disko-install](./docs/disko-install.md) tool, which combines
`disko` and `nixos-install` into one step.

For information on other use cases, including upgrading from an older version of
**disko**, using **disko** without NixOS and downloading the module, see the
@@ -77,6 +76,7 @@ A simple disko configuration may look like this:
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
root = {
@@ -100,7 +100,7 @@ a disk named /dev/sda, you would run the following command to partition, format
and mount the disk.

```console
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko /tmp/disk-config.nix
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount /tmp/disk-config.nix
```

## Related Tools
@@ -117,6 +117,8 @@ this project.
This software is provided free under the
[MIT Licence](https://opensource.org/licenses/MIT).

If you want to contribute, check out [CONTRIBUTING.md](./CONTRIBUTING.md).

## Get in touch

We have a public matrix channel at
131 changes: 92 additions & 39 deletions cli.nix
Original file line number Diff line number Diff line change
@@ -1,70 +1,123 @@
{ pkgs ? import <nixpkgs> { }
, lib ? pkgs.lib
, mode ? "mount"
, flake ? null
, flakeAttr ? null
, diskoFile ? null
, rootMountPoint ? "/mnt"
, noDeps ? false
, ...
{
pkgs ? import <nixpkgs> { },
lib ? pkgs.lib,
mode ? "mount",
flake ? null,
flakeAttr ? null,
diskoFile ? null,
rootMountPoint ? "/mnt",
noDeps ? false,
...
}@args:
let
disko = import ./. {
inherit rootMountPoint;
inherit lib;
};

hasDiskoFile = diskoFile != null;

diskoAttr =
if noDeps then
{
format = "formatScriptNoDeps";
mount = "mountScriptNoDeps";
disko = "diskoScriptNoDeps";
(
if noDeps then
(
if hasDiskoFile then
{
destroy = "_cliDestroyNoDeps";
format = "_cliFormatNoDeps";
mount = "_cliMountNoDeps";
unmount = "_cliUnmountNoDeps";

# legacy aliases
create = "createScriptNoDeps";
zap_create_mount = "diskoScriptNoDeps";
}.${mode}
else
{
format = "formatScript";
mount = "mountScript";
disko = "diskoScript";
"format,mount" = "_cliFormatMountNoDeps";
"destroy,format,mount" = "_cliDestroyFormatMountNoDeps";
}
else
{
destroy = "destroyNoDeps";
format = "formatNoDeps";
mount = "mountNoDeps";
unmount = "unmountNoDeps";

"format,mount" = "formatMountNoDeps";
"destroy,format,mount" = "destroyFormatMountNoDeps";
}
)
// {
# legacy aliases
disko = "diskoScriptNoDeps";
create = "createScriptNoDeps";
zap_create_mount = "diskoScriptNoDeps";
}
else
(
if hasDiskoFile then
{
destroy = "_cliDestroy";
format = "_cliFormat";
mount = "_cliMount";
unmount = "_cliUnmount";

# legacy aliases
create = "createScript";
zap_create_mount = "diskoScript";
}.${mode};
"format,mount" = "_cliFormatMount";
"destroy,format,mount" = "_cliDestroyFormatMount";
}
else
{
destroy = "destroy";
format = "format";
mount = "mount";
unmount = "unmount";

"format,mount" = "formatMount";
"destroy,format,mount" = "destroyFormatMount";
}
)
// {
# legacy aliases
disko = "diskoScript";
create = "createScript";
zap_create_mount = "diskoScript";
}
).${mode};

hasDiskoConfigFlake =
diskoFile != null || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
hasDiskoFile || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);

hasDiskoModuleFlake =
lib.hasAttrByPath [ "nixosConfigurations" flakeAttr "config" "disko" "devices" ] (builtins.getFlake flake);
hasDiskoModuleFlake = lib.hasAttrByPath [
"nixosConfigurations"
flakeAttr
"config"
"disko"
"devices"
] (builtins.getFlake flake);

diskFormat =
let
diskoConfig =
if diskoFile != null then
if hasDiskoFile then
import diskoFile
else
(builtins.getFlake flake).diskoConfigurations.${flakeAttr};
in
if builtins.isFunction diskoConfig then
diskoConfig ({ inherit lib; } // args)
else
diskoConfig;
if builtins.isFunction diskoConfig then diskoConfig ({ inherit lib; } // args) else diskoConfig;

diskoEval =
disko.${diskoAttr} diskFormat pkgs;
diskoEval = disko.${diskoAttr} diskFormat pkgs;

diskoScript =
if hasDiskoConfigFlake then
diskoEval
else if (lib.traceValSeq hasDiskoModuleFlake) then
else if hasDiskoModuleFlake then
(builtins.getFlake flake).nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr}
or (pkgs.writeShellScriptBin "disko-compat-error" ''
echo 'Error: Attribute `nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr}` >&2
echo ' not found in flake `${flake}`!' >&2
echo ' This is probably caused by the locked version of disko in the flake' >&2
echo ' being different from the version of disko you executed.' >&2
echo 'EITHER set the `disko` input of your flake to `github:nix-community/disko/latest`,' >&2
echo ' run `nix flake update disko` in the flake directory and then try again,' >&2
echo 'OR run `nix run github:nix-community/disko/v1.9.0 -- --help` and use one of its modes.' >&2
exit 1;'')
else
(builtins.abort "neither diskoConfigurations.${flakeAttr} nor nixosConfigurations.${flakeAttr} found");
(builtins.abort "couldn't find `diskoConfigurations.${flakeAttr}` or `nixosConfigurations.${flakeAttr}.config.disko.devices`");

in
diskoScript
Loading