From 389235b63f8488229559a1217351826f1d3dd7b3 Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Wed, 30 Oct 2024 23:43:26 +0100 Subject: [PATCH] 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. --- default.nix | 43 +---- disko | 2 +- disko-install | 2 +- disko2 | 165 +----------------- doc.nix | 2 +- docs/reference.md | 2 +- docs/testing.md | 2 +- flake.nix | 5 +- module.nix | 6 +- package-disko2.nix | 42 +++++ package.nix | 2 +- pyproject.toml | 19 +- cli.nix => src/cli.nix | 2 +- .../disk-deactivate}/disk-deactivate | 0 .../disk-deactivate}/disk-deactivate.jq | 0 src/disko/__init__.py | 5 + src/disko/__main__.py | 4 + src/disko/cli.py | 157 +++++++++++++++++ {lib => src/disko_lib}/__init__.py | 0 {lib => src/disko_lib}/ansi.py | 4 - {lib => src/disko_lib}/default.nix | 70 +++++++- {lib => src/disko_lib}/eval-config.nix | 2 +- {lib => src/disko_lib}/eval_config.py | 4 +- {lib => src/disko_lib}/interactive-vm.nix | 0 {lib => src/disko_lib}/logging.py | 2 +- {lib => src/disko_lib}/make-disk-image.nix | 0 {lib => src/disko_lib}/result.py | 2 +- {lib => src/disko_lib}/run_cmd.py | 4 +- {lib => src/disko_lib}/tests.nix | 6 +- {lib => src/disko_lib}/types/__init__.py | 0 {lib => src/disko_lib}/types/btrfs.nix | 0 {lib => src/disko_lib}/types/device.py | 4 +- {lib => src/disko_lib}/types/disk.nix | 0 {lib => src/disko_lib}/types/disk.py | 8 +- {lib => src/disko_lib}/types/filesystem.nix | 0 {lib => src/disko_lib}/types/filesystem.py | 4 +- {lib => src/disko_lib}/types/gpt.nix | 0 {lib => src/disko_lib}/types/gpt.py | 8 +- {lib => src/disko_lib}/types/luks.nix | 0 {lib => src/disko_lib}/types/lvm_pv.nix | 0 {lib => src/disko_lib}/types/lvm_vg.nix | 0 {lib => src/disko_lib}/types/mdadm.nix | 0 {lib => src/disko_lib}/types/mdraid.nix | 0 {lib => src/disko_lib}/types/nodev.nix | 0 {lib => src/disko_lib}/types/swap.nix | 0 {lib => src/disko_lib}/types/table.nix | 0 {lib => src/disko_lib}/types/zfs.nix | 0 {lib => src/disko_lib}/types/zfs_fs.nix | 0 {lib => src/disko_lib}/types/zfs_volume.nix | 0 {lib => src/disko_lib}/types/zpool.nix | 0 install-cli.nix => src/install-cli.nix | 0 tests/bcachefs.nix | 2 +- tests/boot-raid1.nix | 2 +- tests/btrfs-only-root-subvolume.nix | 2 +- tests/btrfs-subvolumes.nix | 2 +- tests/cli.nix | 2 +- tests/complex.nix | 2 +- tests/default.nix | 2 +- tests/f2fs.nix | 2 +- tests/gpt-bios-compat.nix | 2 +- tests/gpt-name-with-special-chars.nix | 2 +- tests/hybrid-mbr.nix | 2 +- tests/hybrid-tmpfs-on-root.nix | 2 +- tests/hybrid.nix | 2 +- tests/legacy-table-with-whitespace.nix | 2 +- tests/legacy-table.nix | 2 +- tests/long-device-name.nix | 2 +- tests/luks-btrfs-raid.nix | 6 +- tests/luks-btrfs-subvolumes.nix | 2 +- tests/luks-interactive-login.nix | 2 +- tests/luks-lvm.nix | 2 +- tests/luks-on-mdadm.nix | 2 +- tests/lvm-raid.nix | 2 +- tests/lvm-sizes-sort.nix | 2 +- tests/lvm-thin.nix | 2 +- tests/mdadm-raid0.nix | 2 +- tests/mdadm.nix | 2 +- tests/module.nix | 2 +- tests/multi-device-no-deps.nix | 2 +- tests/negative-size.nix | 2 +- tests/non-root-zfs.nix | 2 +- tests/simple-efi.nix | 2 +- tests/swap.nix | 2 +- tests/tmpfs.nix | 2 +- tests/with-lib.nix | 2 +- tests/zfs-over-legacy.nix | 2 +- tests/zfs-with-vdevs.nix | 2 +- tests/zfs.nix | 2 +- 88 files changed, 374 insertions(+), 282 deletions(-) create mode 100644 package-disko2.nix rename cli.nix => src/cli.nix (98%) rename {disk-deactivate => src/disk-deactivate}/disk-deactivate (100%) rename {disk-deactivate => src/disk-deactivate}/disk-deactivate.jq (100%) create mode 100644 src/disko/__init__.py create mode 100644 src/disko/__main__.py create mode 100644 src/disko/cli.py rename {lib => src/disko_lib}/__init__.py (100%) rename {lib => src/disko_lib}/ansi.py (98%) rename {lib => src/disko_lib}/default.nix (89%) rename {lib => src/disko_lib}/eval-config.nix (97%) rename {lib => src/disko_lib}/eval_config.py (96%) rename {lib => src/disko_lib}/interactive-vm.nix (100%) rename {lib => src/disko_lib}/logging.py (99%) rename {lib => src/disko_lib}/make-disk-image.nix (100%) rename {lib => src/disko_lib}/result.py (93%) rename {lib => src/disko_lib}/run_cmd.py (88%) rename {lib => src/disko_lib}/tests.nix (98%) rename {lib => src/disko_lib}/types/__init__.py (100%) rename {lib => src/disko_lib}/types/btrfs.nix (100%) rename {lib => src/disko_lib}/types/device.py (97%) rename {lib => src/disko_lib}/types/disk.nix (100%) rename {lib => src/disko_lib}/types/disk.py (91%) rename {lib => src/disko_lib}/types/filesystem.nix (100%) rename {lib => src/disko_lib}/types/filesystem.py (81%) rename {lib => src/disko_lib}/types/gpt.nix (100%) rename {lib => src/disko_lib}/types/gpt.py (91%) rename {lib => src/disko_lib}/types/luks.nix (100%) rename {lib => src/disko_lib}/types/lvm_pv.nix (100%) rename {lib => src/disko_lib}/types/lvm_vg.nix (100%) rename {lib => src/disko_lib}/types/mdadm.nix (100%) rename {lib => src/disko_lib}/types/mdraid.nix (100%) rename {lib => src/disko_lib}/types/nodev.nix (100%) rename {lib => src/disko_lib}/types/swap.nix (100%) rename {lib => src/disko_lib}/types/table.nix (100%) rename {lib => src/disko_lib}/types/zfs.nix (100%) rename {lib => src/disko_lib}/types/zfs_fs.nix (100%) rename {lib => src/disko_lib}/types/zfs_volume.nix (100%) rename {lib => src/disko_lib}/types/zpool.nix (100%) rename install-cli.nix => src/install-cli.nix (100%) diff --git a/default.nix b/default.nix index 65e4903..19ff77b 100644 --- a/default.nix +++ b/default.nix @@ -1,45 +1,8 @@ { lib ? import , rootMountPoint ? "/mnt" , checked ? false -, diskoLib ? import ./lib { inherit lib rootMountPoint; } +, diskoLib ? import ./src/disko_lib { inherit lib rootMountPoint; } }: -let - eval = cfg: lib.evalModules { - modules = lib.singleton { - # _file = toString input; - imports = lib.singleton { disko.devices = cfg.disko.devices; }; - options = { - disko.devices = lib.mkOption { - type = diskoLib.toplevel; - }; - }; - }; - }; -in -{ - inherit eval; - lib = lib.warn "the .lib.lib output is deprecated" diskoLib; - - # legacy alias - create = cfg: builtins.trace "the create output is deprecated, use format instead" (eval cfg).config.disko.devices._create; - createScript = cfg: pkgs: builtins.trace "the create output is deprecated, use format instead" ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).formatScript; - createScriptNoDeps = cfg: pkgs: builtins.trace "the create output is deprecated, use format instead" ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).formatScriptNoDeps; - - format = cfg: (eval cfg).config.disko.devices._create; - formatScript = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).formatScript; - formatScriptNoDeps = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).formatScriptNoDeps; - - mount = cfg: (eval cfg).config.disko.devices._mount; - mountScript = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).mountScript; - mountScriptNoDeps = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).mountScriptNoDeps; - - disko = cfg: (eval cfg).config.disko.devices._disko; - diskoScript = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).diskoScript; - diskoScriptNoDeps = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).diskoScriptNoDeps; - - # we keep this old output for backwards compatibility - diskoNoDeps = cfg: pkgs: builtins.trace "the diskoNoDeps output is deprecated, please use disko instead" ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).diskoScriptNoDeps; - - config = cfg: (eval cfg).config.disko.devices._config; - packages = cfg: (eval cfg).config.disko.devices._packages; +diskoLib.outputs { + inherit lib checked rootMountPoint; } diff --git a/disko b/disko index 4ef771a..af97de3 100755 --- a/disko +++ b/disko @@ -153,7 +153,7 @@ else fi # The "--impure" is still pure, as the path is within the nix store. -script=$(nixBuild "${libexec_dir}"/cli.nix \ +script=$(nixBuild "${libexec_dir}"/src/cli.nix \ --no-out-link \ --impure \ --argstr mode "$mode" \ diff --git a/disko-install b/disko-install index a10ff80..9c3fc8a 100755 --- a/disko-install +++ b/disko-install @@ -197,7 +197,7 @@ main() { # shellcheck disable=SC2064 trap "cleanupMountPoint ${escapeMountPoint}" EXIT - outputs=$(nixBuild "${libexec_dir}"/install-cli.nix \ + outputs=$(nixBuild "${libexec_dir}"/src/install-cli.nix \ "${nix_args[@]}" \ --no-out-link \ --impure \ diff --git a/disko2 b/disko2 index ccf9ade..18b1f6b 100755 --- a/disko2 +++ b/disko2 @@ -1,157 +1,10 @@ -#!/usr/bin/env python3 +#!/usr/bin/env bash +# This script only exists so you can run `./disko2` directly +# It should not be be installed as part of the package! +# Check src/disko/cli.py for the actual entrypoint -import argparse -import json -from pathlib import Path -from typing import Any, Literal, assert_never - -from lib.ansi import disko_dev_ansi -from lib.eval_config import eval_disko_file, eval_flake -from lib.logging import LOGGER, debug, info -from lib.result import DiskoError, DiskoSuccess, DiskoResult, exit_on_error -from lib.types.disk import generate_config -from lib.types.device import disko_dev_lsblk - -Mode = Literal[ - "destroy", - "format", - "mount", - "destroy,format,mount", - "format,mount", - "generate", - "dev", -] - - -# Modes to apply an existing configuration -APPLY_MODES: list[Mode] = [ - "destroy", - "format", - "mount", - "destroy,format,mount", - "format,mount", -] -ALL_MODES: list[Mode] = APPLY_MODES + ["generate", "dev"] - -MODE_DESCRIPTION: dict[Mode, str] = { - "destroy": "Destroy the partition tables on the specified disks", - "format": "Change formatting and filesystems on the specified disks", - "mount": "Mount the specified disks", - "destroy,format,mount": "Run destroy, format and mount in sequence", - "format,mount": "Run format and mount in sequence", - "generate": "Generate a disko configuration file from the system's current state", - "dev": "Print information useful for developers", -} - - -def run_apply( - *, mode: str, disko_file: str | None, flake: str | None, **_kwargs: dict[str, Any] -) -> DiskoResult[dict[str, Any]]: - # match would be nicer, but mypy doesn't understand type narrowing in tuples - if not disko_file and not flake: - return DiskoError.single_message("ERR_MISSING_ARGUMENTS", {}, "validate args") - if not disko_file and flake: - return eval_flake(flake) - if disko_file and not flake: - return eval_disko_file(Path(disko_file)) - - return DiskoError.single_message("ERR_TOO_MANY_ARGUMENTS", {}, "validate args") - - -def run_generate() -> DiskoResult[dict[str, Any]]: - return generate_config() - - -def run_dev(args: argparse.Namespace) -> DiskoResult[None]: - match args.dev_command: - case "lsblk": - return disko_dev_lsblk() - case "ansi": - return DiskoSuccess(None, disko_dev_ansi()) - case _: - assert_never(args.dev_command) - - -def run( - args: argparse.Namespace, -) -> DiskoResult[None | dict[str, Any]]: - if args.verbose: - LOGGER.setLevel("DEBUG") - debug("Enabled debug logging.") - - match args.mode: - case None: - return DiskoError.single_message( - "ERR_MISSING_MODE", {"valid_modes": ALL_MODES}, "select mode" - ) - case "generate": - return run_generate() - case "dev": - return run_dev(args) - case _: - return run_apply(**vars(args)) - - -def parse_args() -> argparse.Namespace: - root_parser = argparse.ArgumentParser( - prog="disko2", - description="Automated disk partitioning and formatting tool for NixOS", - ) - - root_parser.add_argument( - "--verbose", - "-v", - action="store_true", - default=False, - help="Print more detailed output, helpful for debugging", - ) - - mode_parsers = root_parser.add_subparsers(dest="mode") - - def create_apply_parser(mode: Mode) -> argparse.ArgumentParser: - parser = mode_parsers.add_parser( - mode, - help=MODE_DESCRIPTION[mode], - ) - parser.add_argument( - "disko_file", - nargs="?", - default=None, - help="Path to the disko configuration file", - ) - parser.add_argument( - "--flake", - "-f", - help="Flake to fetch the disko configuration from", - ) - return parser - - # Commands to apply an existing configuration - apply_parsers = [create_apply_parser(mode) for mode in APPLY_MODES] - - # Other commands - generate_parser = mode_parsers.add_parser( - "generate", - help=MODE_DESCRIPTION["generate"], - ) - - # Commands for developers - dev_parsers = mode_parsers.add_parser( - "dev", - help=MODE_DESCRIPTION["dev"], - ).add_subparsers(dest="dev_command") - dev_parsers.add_parser("lsblk", help="List block devices the way disko sees them") - dev_parsers.add_parser("ansi", help="Print defined ansi color codes") - return root_parser.parse_args() - - -def main() -> None: - args = parse_args() - result = run(args) - output = exit_on_error(result) - if output: - info("Output:\n" + json.dumps(output, indent=2)) - - -if __name__ == "__main__": - main() +set -euo pipefail +( + cd "$(dirname "$(realpath "$0")")"/src + python3 -m disko "$@" +) \ No newline at end of file diff --git a/doc.nix b/doc.nix index d07f8f3..fae176f 100644 --- a/doc.nix +++ b/doc.nix @@ -1,7 +1,7 @@ { lib, nixosOptionsDoc, runCommand, fetchurl, pandoc }: let - diskoLib = import ./lib { + diskoLib = import ./src/disko_lib { inherit lib; rootMountPoint = "/mnt"; }; diff --git a/docs/reference.md b/docs/reference.md index 104ba1d..2ae8842 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -4,7 +4,7 @@ We are currently having issues being able to generate proper module option documentation for our recursive disko types. However you can read the available -options [here](https://github.com/nix-community/disko/tree/master/lib/types). +options [here](https://github.com/nix-community/disko/tree/master/src/disko_lib/types). Combined with the [examples](https://github.com/nix-community/disko/tree/master/example) this hopefully gives you an overview. diff --git a/docs/testing.md b/docs/testing.md index 769b1a3..152270a 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -7,7 +7,7 @@ the example is working in [the tests directory](../tests/). They utilize the We use a wrapper around this called `makeDiskoTest`. There is currently (as of 2024-10-16) no documentation for all its arguments, but you can have a look at -[its current code](https://github.com/nix-community/disko/blob/master/lib/tests.nix#L44C5-L58C10), +[its current code](https://github.com/nix-community/disko/blob/master/src/disko_lib/tests.nix#L44C5-L58C10), that should already be helpful. However, you don't need to know about all of the inner workings to interact with diff --git a/flake.nix b/flake.nix index 5d7d4ba..e93bfb1 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ { nixosModules.default = self.nixosModules.disko; # convention nixosModules.disko.imports = [ ./module.nix ]; - lib = import ./lib { + lib = import ./src/disko_lib { inherit (nixpkgs) lib; }; packages = forAllSystems (system: @@ -32,6 +32,7 @@ in { disko = pkgs.callPackage ./package.nix { diskoVersion = version; }; + disko2 = pkgs.callPackage ./package-disko2.nix { diskoVersion = version; }; # alias to make `nix run` more convenient disko-install = self.packages.${system}.disko.overrideAttrs (_old: { name = "disko-install"; @@ -61,7 +62,7 @@ shellcheck = pkgs.runCommand "shellcheck" { nativeBuildInputs = [ pkgs.shellcheck ]; } '' cd ${./.} - shellcheck disk-deactivate/disk-deactivate disko + shellcheck src/disk-deactivate/disk-deactivate disko disko2 touch $out ''; in diff --git a/module.nix b/module.nix index 3f444de..a7a9e56 100644 --- a/module.nix +++ b/module.nix @@ -4,13 +4,13 @@ let vmVariantWithDisko = extendModules { modules = [ - ./lib/interactive-vm.nix + ./src/disko_lib/interactive-vm.nix config.disko.tests.extraConfig ]; }; in { - imports = [ ./lib/make-disk-image.nix ]; + imports = [ ./src/disko_lib/make-disk-image.nix ]; options.disko = { imageBuilder = { @@ -205,7 +205,7 @@ in } ]; - _module.args.diskoLib = import ./lib { + _module.args.diskoLib = import ./src/disko_lib { inherit lib; rootMountPoint = config.disko.rootMountPoint; makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix"); diff --git a/package-disko2.nix b/package-disko2.nix new file mode 100644 index 0000000..3c9dc92 --- /dev/null +++ b/package-disko2.nix @@ -0,0 +1,42 @@ +{ python3Packages, lib, lix, coreutils, nixos-install-tools, binlore, diskoVersion }: + +let + self = python3Packages.buildPythonApplication { + pname = "disko2"; + version = diskoVersion; + src = ./.; + pyproject = true; + + build-system = [ python3Packages.setuptools ]; + dependencies = [ + lix # lix instead of nix because it produces way better eval errors + coreutils + nixos-install-tools + ]; + + # Otherwise resholve thinks that disko and disko-install might be able to execute their arguments + passthru.binlore.out = binlore.synthesize self '' + execer cannot bin/.disko2-wrapped + ''; + postInstall = '' + mkdir -p $out/share/disko/ + cp example/simple-efi.nix $out/share/disko/ + ''; + + makeWrapperArgs = [ "--set DISKO_VERSION ${diskoVersion}" ]; + + doCheck = true; + # installCheckPhase = '' + # $out/bin/disko2 mount $out/share/disko/simple-efi.nix + # ''; + meta = with lib; { + description = "Format disks with nix-config"; + homepage = "https://github.com/nix-community/disko"; + license = licenses.mit; + maintainers = with maintainers; [ lassulus ]; + platforms = platforms.linux; + mainProgram = "disko2"; + }; + }; +in +self diff --git a/package.nix b/package.nix index 3464854..f1dd6e3 100644 --- a/package.nix +++ b/package.nix @@ -9,7 +9,7 @@ let ]; installPhase = '' mkdir -p $out/bin $out/share/disko - cp -r install-cli.nix cli.nix default.nix disk-deactivate lib $out/share/disko + cp -r default.nix src $out/share/disko for i in disko disko-install; do sed -e "s|libexec_dir=\".*\"|libexec_dir=\"$out/share/disko\"|" "$i" > "$out/bin/$i" diff --git a/pyproject.toml b/pyproject.toml index 4934e1d..9d968b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,23 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "disko2" +version = "2.0.0-preview" + +[project.scripts] +disko2 = "disko:main" + +[tool.setuptools] +package-dir = { "" = "src" } + +[tool.setuptools.package-data] +"*" = ["*.nix"] + [tool.mypy] strict = true [tool.autoflake] remove_all_unused_imports = true -in_place = true \ No newline at end of file +in_place = true diff --git a/cli.nix b/src/cli.nix similarity index 98% rename from cli.nix rename to src/cli.nix index 3203ced..cf8d9aa 100644 --- a/cli.nix +++ b/src/cli.nix @@ -9,7 +9,7 @@ , ... }@args: let - disko = import ./. { + disko = import ../. { inherit rootMountPoint; inherit lib; }; diff --git a/disk-deactivate/disk-deactivate b/src/disk-deactivate/disk-deactivate similarity index 100% rename from disk-deactivate/disk-deactivate rename to src/disk-deactivate/disk-deactivate diff --git a/disk-deactivate/disk-deactivate.jq b/src/disk-deactivate/disk-deactivate.jq similarity index 100% rename from disk-deactivate/disk-deactivate.jq rename to src/disk-deactivate/disk-deactivate.jq diff --git a/src/disko/__init__.py b/src/disko/__init__.py new file mode 100644 index 0000000..9595be4 --- /dev/null +++ b/src/disko/__init__.py @@ -0,0 +1,5 @@ +from . import cli + + +def main() -> None: + cli.main() diff --git a/src/disko/__main__.py b/src/disko/__main__.py new file mode 100644 index 0000000..868d99e --- /dev/null +++ b/src/disko/__main__.py @@ -0,0 +1,4 @@ +from . import main + +if __name__ == "__main__": + main() diff --git a/src/disko/cli.py b/src/disko/cli.py new file mode 100644 index 0000000..3adc8d5 --- /dev/null +++ b/src/disko/cli.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python3 + +import argparse +import json +from pathlib import Path +from typing import Any, Literal, assert_never + +from disko_lib.ansi import disko_dev_ansi +from disko_lib.eval_config import eval_disko_file, eval_flake +from disko_lib.logging import LOGGER, debug, info +from disko_lib.result import DiskoError, DiskoSuccess, DiskoResult, exit_on_error +from disko_lib.types.disk import generate_config +from disko_lib.types.device import disko_dev_lsblk + +Mode = Literal[ + "destroy", + "format", + "mount", + "destroy,format,mount", + "format,mount", + "generate", + "dev", +] + + +# Modes to apply an existing configuration +APPLY_MODES: list[Mode] = [ + "destroy", + "format", + "mount", + "destroy,format,mount", + "format,mount", +] +ALL_MODES: list[Mode] = APPLY_MODES + ["generate", "dev"] + +MODE_DESCRIPTION: dict[Mode, str] = { + "destroy": "Destroy the partition tables on the specified disks", + "format": "Change formatting and filesystems on the specified disks", + "mount": "Mount the specified disks", + "destroy,format,mount": "Run destroy, format and mount in sequence", + "format,mount": "Run format and mount in sequence", + "generate": "Generate a disko configuration file from the system's current state", + "dev": "Print information useful for developers", +} + + +def run_apply( + *, mode: str, disko_file: str | None, flake: str | None, **_kwargs: dict[str, Any] +) -> DiskoResult[dict[str, Any]]: + # match would be nicer, but mypy doesn't understand type narrowing in tuples + if not disko_file and not flake: + return DiskoError.single_message("ERR_MISSING_ARGUMENTS", {}, "validate args") + if not disko_file and flake: + return eval_flake(flake) + if disko_file and not flake: + return eval_disko_file(Path(disko_file)) + + return DiskoError.single_message("ERR_TOO_MANY_ARGUMENTS", {}, "validate args") + + +def run_generate() -> DiskoResult[dict[str, Any]]: + return generate_config() + + +def run_dev(args: argparse.Namespace) -> DiskoResult[None]: + match args.dev_command: + case "lsblk": + return disko_dev_lsblk() + case "ansi": + return DiskoSuccess(None, disko_dev_ansi()) + case _: + assert_never(args.dev_command) + + +def run( + args: argparse.Namespace, +) -> DiskoResult[None | dict[str, Any]]: + if args.verbose: + LOGGER.setLevel("DEBUG") + debug("Enabled debug logging.") + + match args.mode: + case None: + return DiskoError.single_message( + "ERR_MISSING_MODE", {"valid_modes": ALL_MODES}, "select mode" + ) + case "generate": + return run_generate() + case "dev": + return run_dev(args) + case _: + return run_apply(**vars(args)) + + +def parse_args() -> argparse.Namespace: + root_parser = argparse.ArgumentParser( + prog="disko2", + description="Automated disk partitioning and formatting tool for NixOS", + ) + + root_parser.add_argument( + "--verbose", + "-v", + action="store_true", + default=False, + help="Print more detailed output, helpful for debugging", + ) + + mode_parsers = root_parser.add_subparsers(dest="mode") + + def create_apply_parser(mode: Mode) -> argparse.ArgumentParser: + parser = mode_parsers.add_parser( + mode, + help=MODE_DESCRIPTION[mode], + ) + parser.add_argument( + "disko_file", + nargs="?", + default=None, + help="Path to the disko configuration file", + ) + parser.add_argument( + "--flake", + "-f", + help="Flake to fetch the disko configuration from", + ) + return parser + + # Commands to apply an existing configuration + apply_parsers = [create_apply_parser(mode) for mode in APPLY_MODES] + + # Other commands + generate_parser = mode_parsers.add_parser( + "generate", + help=MODE_DESCRIPTION["generate"], + ) + + # Commands for developers + dev_parsers = mode_parsers.add_parser( + "dev", + help=MODE_DESCRIPTION["dev"], + ).add_subparsers(dest="dev_command") + dev_parsers.add_parser("lsblk", help="List block devices the way disko sees them") + dev_parsers.add_parser("ansi", help="Print defined ansi color codes") + return root_parser.parse_args() + + +def main() -> None: + args = parse_args() + result = run(args) + output = exit_on_error(result) + if output: + info("Output:\n" + json.dumps(output, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/lib/__init__.py b/src/disko_lib/__init__.py similarity index 100% rename from lib/__init__.py rename to src/disko_lib/__init__.py diff --git a/lib/ansi.py b/src/disko_lib/ansi.py similarity index 98% rename from lib/ansi.py rename to src/disko_lib/ansi.py index e33c918..e031f10 100644 --- a/lib/ansi.py +++ b/src/disko_lib/ansi.py @@ -4,9 +4,6 @@ # See https://gist.github.com/rene-d/9e584a7dd2935d0f461904b9f2950007 -from typing import Any - - class Colors: """ ANSI escape sequences @@ -180,7 +177,6 @@ class Colors: def disko_dev_ansi() -> str: import inspect - from lib.result import DiskoSuccess # Import here to avoid circular dependency for name, value in inspect.getmembers(Colors): if value != "_" and not name.startswith("_") and name != "RESET": diff --git a/lib/default.nix b/src/disko_lib/default.nix similarity index 89% rename from lib/default.nix rename to src/disko_lib/default.nix index d19acac..4014334 100644 --- a/lib/default.nix +++ b/src/disko_lib/default.nix @@ -4,7 +4,6 @@ , eval-config ? import }: let - outputs = import ../default.nix { inherit lib diskoLib; }; diskoLib = { testLib = import ./tests.nix { inherit lib makeTest eval-config; }; # like lib.types.oneOf but instead of a list takes an attrset @@ -79,7 +78,7 @@ let then "${dev}p${toString index}" # /dev/mapper/vg-lv1 style else abort '' - ${dev} seems not to be a supported disk format. Please add this to disko in https://github.com/nix-community/disko/blob/master/lib/default.nix + ${dev} seems not to be a supported disk format. Please add this to disko in https://github.com/nix-community/disko/blob/master/src/disko_lib/default.nix ''; /* Escape a string as required to be used in udev symlinks @@ -213,11 +212,11 @@ let isAttrsOfSubmodule = o: o.type.name == "attrsOf" && o.type.nestedTypes.elemType.name == "submodule"; isSerializable = n: o: !( lib.hasPrefix "_" n - || lib.hasSuffix "Hook" n - || isAttrsOfSubmodule o - # TODO don't hardcode diskoLib.subType options. - || n == "content" || n == "partitions" || n == "datasets" || n == "swap" - || n == "mode" + || lib.hasSuffix "Hook" n + || isAttrsOfSubmodule o + # TODO don't hardcode diskoLib.subType options. + || n == "content" || n == "partitions" || n == "datasets" || n == "swap" + || n == "mode" ); in lib.toShellVars @@ -297,6 +296,23 @@ let }; + /* Evaluate a disko configuration + + eval :: lib.types.devices -> AttrSet + */ + eval-disko = cfg: lib.evalModules { + modules = lib.singleton { + # _file = toString input; + imports = lib.singleton { disko.devices = cfg.disko.devices; }; + options = { + disko.devices = lib.mkOption { + type = diskoLib.toplevel; + }; + }; + }; + }; + + /* Takes a disko device specification, returns an attrset with metadata meta :: lib.types.devices -> AttrSet @@ -638,6 +654,44 @@ let (lib.attrNames (builtins.readDir ./types)) ); - } // outputs; + + }; + outputs = + { lib ? import + , rootMountPoint ? "/mnt" + , checked ? false + , diskoLib ? import ./. { inherit lib rootMountPoint; } + }: + let + eval = diskoLib.eval-disko; + in + { + # legacy alias + create = cfg: builtins.trace "the create output is deprecated, use format instead" (eval cfg).config.disko.devices._create; + createScript = cfg: pkgs: builtins.trace "the create output is deprecated, use format instead" ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).formatScript; + createScriptNoDeps = cfg: pkgs: builtins.trace "the create output is deprecated, use format instead" ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).formatScriptNoDeps; + + format = cfg: (eval cfg).config.disko.devices._create; + formatScript = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).formatScript; + formatScriptNoDeps = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).formatScriptNoDeps; + + mount = cfg: (eval cfg).config.disko.devices._mount; + mountScript = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).mountScript; + mountScriptNoDeps = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).mountScriptNoDeps; + + disko = cfg: (eval cfg).config.disko.devices._disko; + diskoScript = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).diskoScript; + diskoScriptNoDeps = cfg: pkgs: ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).diskoScriptNoDeps; + + # we keep this old output for backwards compatibility + diskoNoDeps = cfg: pkgs: builtins.trace "the diskoNoDeps output is deprecated, please use disko instead" ((eval cfg).config.disko.devices._scripts { inherit pkgs checked; }).diskoScriptNoDeps; + + config = cfg: (eval cfg).config.disko.devices._config; + packages = cfg: (eval cfg).config.disko.devices._packages; + }; in diskoLib +// (outputs { + inherit lib rootMountPoint; +}) # Compatibility alias + // { inherit outputs; } diff --git a/lib/eval-config.nix b/src/disko_lib/eval-config.nix similarity index 97% rename from lib/eval-config.nix rename to src/disko_lib/eval-config.nix index 8866213..9225f2c 100644 --- a/lib/eval-config.nix +++ b/src/disko_lib/eval-config.nix @@ -36,7 +36,7 @@ let evaluatedConfig = if hasDiskoFile || hasFlakeDiskoConfig then - disko.eval diskFormat + disko.eval-disko diskFormat else if (lib.traceValSeq hasFlakeDiskoModule) then flake'.nixosConfigurations.${flakeAttr} else diff --git a/lib/eval_config.py b/src/disko_lib/eval_config.py similarity index 96% rename from lib/eval_config.py rename to src/disko_lib/eval_config.py index 5715e85..b3a81fe 100644 --- a/lib/eval_config.py +++ b/src/disko_lib/eval_config.py @@ -3,8 +3,8 @@ from pathlib import Path import re from typing import Any -from lib.run_cmd import run -from lib.result import DiskoError, DiskoResult, DiskoSuccess +from .run_cmd import run +from .result import DiskoError, DiskoResult, DiskoSuccess NIX_BASE_CMD = [ "nix", diff --git a/lib/interactive-vm.nix b/src/disko_lib/interactive-vm.nix similarity index 100% rename from lib/interactive-vm.nix rename to src/disko_lib/interactive-vm.nix diff --git a/lib/logging.py b/src/disko_lib/logging.py similarity index 99% rename from lib/logging.py rename to src/disko_lib/logging.py index c099506..3609f59 100644 --- a/lib/logging.py +++ b/src/disko_lib/logging.py @@ -5,7 +5,7 @@ import logging import re from typing import Any, Literal, assert_never -from lib.ansi import Colors +from .ansi import Colors logging.basicConfig(format="%(message)s", level=logging.INFO) LOGGER = logging.getLogger("disko_logger") diff --git a/lib/make-disk-image.nix b/src/disko_lib/make-disk-image.nix similarity index 100% rename from lib/make-disk-image.nix rename to src/disko_lib/make-disk-image.nix diff --git a/lib/result.py b/src/disko_lib/result.py similarity index 93% rename from lib/result.py rename to src/disko_lib/result.py index b11d4c4..49b4e21 100644 --- a/lib/result.py +++ b/src/disko_lib/result.py @@ -1,7 +1,7 @@ from dataclasses import dataclass from typing import Any, Generic, Literal, TypeVar -from lib.logging import DiskoMessage, debug, print_msg, MessageCode +from .logging import DiskoMessage, debug, print_msg, MessageCode T = TypeVar("T", covariant=True) diff --git a/lib/run_cmd.py b/src/disko_lib/run_cmd.py similarity index 88% rename from lib/run_cmd.py rename to src/disko_lib/run_cmd.py index 9cc3fd4..308a16c 100644 --- a/lib/run_cmd.py +++ b/src/disko_lib/run_cmd.py @@ -1,7 +1,7 @@ import subprocess -from lib.logging import debug -from lib.result import DiskoError, DiskoResult, DiskoSuccess +from .logging import debug +from .result import DiskoError, DiskoResult, DiskoSuccess def run(args: list[str]) -> DiskoResult[str]: diff --git a/lib/tests.nix b/src/disko_lib/tests.nix similarity index 98% rename from lib/tests.nix rename to src/disko_lib/tests.nix index 0aff420..58501d4 100644 --- a/lib/tests.nix +++ b/src/disko_lib/tests.nix @@ -79,7 +79,7 @@ let # so /dev/vdb becomes /dev/vda etc. testConfigBooted = testLib.prepareDiskoConfig diskoConfigWithArgs testLib.devices; - tsp-generator = pkgs.callPackage ../. { checked = true; }; + tsp-generator = pkgs.callPackage ../../. { checked = true; }; tsp-format = (tsp-generator.formatScript testConfigInstall) pkgs; tsp-mount = (tsp-generator.mountScript testConfigInstall) pkgs; tsp-disko = (tsp-generator.diskoScript testConfigInstall) pkgs; @@ -92,7 +92,7 @@ let (lib.optionalAttrs (testMode == "module") { disko.enableConfig = true; imports = [ - ../module.nix + ../../module.nix testConfigBooted ]; }) @@ -168,7 +168,7 @@ let imports = [ (lib.optionalAttrs (testMode == "module") { imports = [ - ../module.nix + ../../module.nix ]; disko = { enableConfig = false; diff --git a/lib/types/__init__.py b/src/disko_lib/types/__init__.py similarity index 100% rename from lib/types/__init__.py rename to src/disko_lib/types/__init__.py diff --git a/lib/types/btrfs.nix b/src/disko_lib/types/btrfs.nix similarity index 100% rename from lib/types/btrfs.nix rename to src/disko_lib/types/btrfs.nix diff --git a/lib/types/device.py b/src/disko_lib/types/device.py similarity index 97% rename from lib/types/device.py rename to src/disko_lib/types/device.py index 00779a2..db3a15e 100644 --- a/lib/types/device.py +++ b/src/disko_lib/types/device.py @@ -3,8 +3,8 @@ import json from pathlib import Path from typing import Any -from lib.result import DiskoError, DiskoResult, DiskoSuccess -from lib.run_cmd import run +from ..result import DiskoError, DiskoResult, DiskoSuccess +from ..run_cmd import run # To see what other fields are available in the lsblk output and what # sort of values you can expect from them, run: diff --git a/lib/types/disk.nix b/src/disko_lib/types/disk.nix similarity index 100% rename from lib/types/disk.nix rename to src/disko_lib/types/disk.nix diff --git a/lib/types/disk.py b/src/disko_lib/types/disk.py similarity index 91% rename from lib/types/disk.py rename to src/disko_lib/types/disk.py index 6c1bbf6..2b74cef 100644 --- a/lib/types/disk.py +++ b/src/disko_lib/types/disk.py @@ -1,9 +1,9 @@ from typing import Any -from lib.logging import DiskoMessage, debug -from lib.result import DiskoError, DiskoResult, DiskoSuccess -from lib.types.device import BlockDevice, list_block_devices -import lib.types.gpt as gpt +from ..logging import DiskoMessage, debug +from ..result import DiskoError, DiskoResult, DiskoSuccess +from ..types.device import BlockDevice, list_block_devices +from . import gpt def _generate_content(device: BlockDevice) -> DiskoResult[dict[str, Any]]: diff --git a/lib/types/filesystem.nix b/src/disko_lib/types/filesystem.nix similarity index 100% rename from lib/types/filesystem.nix rename to src/disko_lib/types/filesystem.nix diff --git a/lib/types/filesystem.py b/src/disko_lib/types/filesystem.py similarity index 81% rename from lib/types/filesystem.py rename to src/disko_lib/types/filesystem.py index 168df87..2fb080d 100644 --- a/lib/types/filesystem.py +++ b/src/disko_lib/types/filesystem.py @@ -1,6 +1,6 @@ from typing import Any -from lib.types.device import BlockDevice -from lib.result import DiskoResult, DiskoSuccess +from .device import BlockDevice +from ..result import DiskoResult, DiskoSuccess def generate_config(device: BlockDevice) -> DiskoResult[dict[str, Any]]: diff --git a/lib/types/gpt.nix b/src/disko_lib/types/gpt.nix similarity index 100% rename from lib/types/gpt.nix rename to src/disko_lib/types/gpt.nix diff --git a/lib/types/gpt.py b/src/disko_lib/types/gpt.py similarity index 91% rename from lib/types/gpt.py rename to src/disko_lib/types/gpt.py index b5cc5c8..eafac99 100644 --- a/lib/types/gpt.py +++ b/src/disko_lib/types/gpt.py @@ -1,8 +1,8 @@ from typing import Any -from lib.logging import debug -from lib.types import filesystem -from lib.types.device import BlockDevice -from lib.result import DiskoError, DiskoResult, DiskoSuccess +from ..logging import debug +from . import filesystem +from .device import BlockDevice +from ..result import DiskoError, DiskoResult, DiskoSuccess def _add_type_if_required( diff --git a/lib/types/luks.nix b/src/disko_lib/types/luks.nix similarity index 100% rename from lib/types/luks.nix rename to src/disko_lib/types/luks.nix diff --git a/lib/types/lvm_pv.nix b/src/disko_lib/types/lvm_pv.nix similarity index 100% rename from lib/types/lvm_pv.nix rename to src/disko_lib/types/lvm_pv.nix diff --git a/lib/types/lvm_vg.nix b/src/disko_lib/types/lvm_vg.nix similarity index 100% rename from lib/types/lvm_vg.nix rename to src/disko_lib/types/lvm_vg.nix diff --git a/lib/types/mdadm.nix b/src/disko_lib/types/mdadm.nix similarity index 100% rename from lib/types/mdadm.nix rename to src/disko_lib/types/mdadm.nix diff --git a/lib/types/mdraid.nix b/src/disko_lib/types/mdraid.nix similarity index 100% rename from lib/types/mdraid.nix rename to src/disko_lib/types/mdraid.nix diff --git a/lib/types/nodev.nix b/src/disko_lib/types/nodev.nix similarity index 100% rename from lib/types/nodev.nix rename to src/disko_lib/types/nodev.nix diff --git a/lib/types/swap.nix b/src/disko_lib/types/swap.nix similarity index 100% rename from lib/types/swap.nix rename to src/disko_lib/types/swap.nix diff --git a/lib/types/table.nix b/src/disko_lib/types/table.nix similarity index 100% rename from lib/types/table.nix rename to src/disko_lib/types/table.nix diff --git a/lib/types/zfs.nix b/src/disko_lib/types/zfs.nix similarity index 100% rename from lib/types/zfs.nix rename to src/disko_lib/types/zfs.nix diff --git a/lib/types/zfs_fs.nix b/src/disko_lib/types/zfs_fs.nix similarity index 100% rename from lib/types/zfs_fs.nix rename to src/disko_lib/types/zfs_fs.nix diff --git a/lib/types/zfs_volume.nix b/src/disko_lib/types/zfs_volume.nix similarity index 100% rename from lib/types/zfs_volume.nix rename to src/disko_lib/types/zfs_volume.nix diff --git a/lib/types/zpool.nix b/src/disko_lib/types/zpool.nix similarity index 100% rename from lib/types/zpool.nix rename to src/disko_lib/types/zpool.nix diff --git a/install-cli.nix b/src/install-cli.nix similarity index 100% rename from install-cli.nix rename to src/install-cli.nix diff --git a/tests/bcachefs.nix b/tests/bcachefs.nix index f8806d5..9a9b6c1 100644 --- a/tests/bcachefs.nix +++ b/tests/bcachefs.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/boot-raid1.nix b/tests/boot-raid1.nix index e020fdd..3ed42a8 100644 --- a/tests/boot-raid1.nix +++ b/tests/boot-raid1.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/btrfs-only-root-subvolume.nix b/tests/btrfs-only-root-subvolume.nix index 818aec7..33f0d17 100644 --- a/tests/btrfs-only-root-subvolume.nix +++ b/tests/btrfs-only-root-subvolume.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/btrfs-subvolumes.nix b/tests/btrfs-subvolumes.nix index 7059c1a..df01a44 100644 --- a/tests/btrfs-subvolumes.nix +++ b/tests/btrfs-subvolumes.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/cli.nix b/tests/cli.nix index 76cc2b1..3f81ec6 100644 --- a/tests/cli.nix +++ b/tests/cli.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/complex.nix b/tests/complex.nix index 26cc5e9..613d5fe 100644 --- a/tests/complex.nix +++ b/tests/complex.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/default.nix b/tests/default.nix index cb9d47d..af0c906 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -4,7 +4,7 @@ }: let lib = pkgs.lib; - diskoLib = import ../lib { inherit lib makeTest eval-config; }; + diskoLib = import ../src/disko_lib { inherit lib makeTest eval-config; }; allTestFilenames = builtins.map (lib.removeSuffix ".nix") ( diff --git a/tests/f2fs.nix b/tests/f2fs.nix index ebcf8d8..98c79de 100644 --- a/tests/f2fs.nix +++ b/tests/f2fs.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/gpt-bios-compat.nix b/tests/gpt-bios-compat.nix index de45d3b..08a6ec5 100644 --- a/tests/gpt-bios-compat.nix +++ b/tests/gpt-bios-compat.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/gpt-name-with-special-chars.nix b/tests/gpt-name-with-special-chars.nix index 48b4304..73a8a1a 100644 --- a/tests/gpt-name-with-special-chars.nix +++ b/tests/gpt-name-with-special-chars.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/hybrid-mbr.nix b/tests/hybrid-mbr.nix index de68b26..3559dd4 100644 --- a/tests/hybrid-mbr.nix +++ b/tests/hybrid-mbr.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/hybrid-tmpfs-on-root.nix b/tests/hybrid-tmpfs-on-root.nix index 09d15d6..0b3e301 100644 --- a/tests/hybrid-tmpfs-on-root.nix +++ b/tests/hybrid-tmpfs-on-root.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/hybrid.nix b/tests/hybrid.nix index adf7ccd..b8c2cdd 100644 --- a/tests/hybrid.nix +++ b/tests/hybrid.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/legacy-table-with-whitespace.nix b/tests/legacy-table-with-whitespace.nix index 300c641..f053a60 100644 --- a/tests/legacy-table-with-whitespace.nix +++ b/tests/legacy-table-with-whitespace.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/legacy-table.nix b/tests/legacy-table.nix index 2c7b646..cd74116 100644 --- a/tests/legacy-table.nix +++ b/tests/legacy-table.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/long-device-name.nix b/tests/long-device-name.nix index e328a9f..d3bea86 100644 --- a/tests/long-device-name.nix +++ b/tests/long-device-name.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/luks-btrfs-raid.nix b/tests/luks-btrfs-raid.nix index 6e12749..33e035a 100644 --- a/tests/luks-btrfs-raid.nix +++ b/tests/luks-btrfs-raid.nix @@ -1,6 +1,6 @@ -{ - pkgs ? import { }, - diskoLib ? pkgs.callPackage ../lib { }, +{ pkgs ? import { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } +, }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/luks-btrfs-subvolumes.nix b/tests/luks-btrfs-subvolumes.nix index 6a4e64b..ccd4418 100644 --- a/tests/luks-btrfs-subvolumes.nix +++ b/tests/luks-btrfs-subvolumes.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/luks-interactive-login.nix b/tests/luks-interactive-login.nix index 6fae2e1..54d06c6 100644 --- a/tests/luks-interactive-login.nix +++ b/tests/luks-interactive-login.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/luks-lvm.nix b/tests/luks-lvm.nix index 848a5b7..4b95085 100644 --- a/tests/luks-lvm.nix +++ b/tests/luks-lvm.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/luks-on-mdadm.nix b/tests/luks-on-mdadm.nix index bd49762..4a23fbf 100644 --- a/tests/luks-on-mdadm.nix +++ b/tests/luks-on-mdadm.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/lvm-raid.nix b/tests/lvm-raid.nix index b30332a..5d3debf 100644 --- a/tests/lvm-raid.nix +++ b/tests/lvm-raid.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/lvm-sizes-sort.nix b/tests/lvm-sizes-sort.nix index 83ed472..88252cb 100644 --- a/tests/lvm-sizes-sort.nix +++ b/tests/lvm-sizes-sort.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/lvm-thin.nix b/tests/lvm-thin.nix index bfbcfc1..149efc2 100644 --- a/tests/lvm-thin.nix +++ b/tests/lvm-thin.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/mdadm-raid0.nix b/tests/mdadm-raid0.nix index 7d40109..3356cf6 100644 --- a/tests/mdadm-raid0.nix +++ b/tests/mdadm-raid0.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/mdadm.nix b/tests/mdadm.nix index 3bd9037..bfff5e5 100644 --- a/tests/mdadm.nix +++ b/tests/mdadm.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/module.nix b/tests/module.nix index c6eb092..419f4df 100644 --- a/tests/module.nix +++ b/tests/module.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/multi-device-no-deps.nix b/tests/multi-device-no-deps.nix index 77e3477..3138f69 100644 --- a/tests/multi-device-no-deps.nix +++ b/tests/multi-device-no-deps.nix @@ -1,6 +1,6 @@ # this is a regression test for https://github.com/nix-community/disko/issues/52 { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/negative-size.nix b/tests/negative-size.nix index b891b08..1d948e5 100644 --- a/tests/negative-size.nix +++ b/tests/negative-size.nix @@ -1,6 +1,6 @@ # this is a regression test for https://github.com/nix-community/disko/issues/52 { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/non-root-zfs.nix b/tests/non-root-zfs.nix index 2338483..292cdcc 100644 --- a/tests/non-root-zfs.nix +++ b/tests/non-root-zfs.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/simple-efi.nix b/tests/simple-efi.nix index f3b9071..b16416b 100644 --- a/tests/simple-efi.nix +++ b/tests/simple-efi.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/swap.nix b/tests/swap.nix index 7d1678b..0ae4b23 100644 --- a/tests/swap.nix +++ b/tests/swap.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/tmpfs.nix b/tests/tmpfs.nix index 21cb217..6fff602 100644 --- a/tests/tmpfs.nix +++ b/tests/tmpfs.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/with-lib.nix b/tests/with-lib.nix index d8274b7..c78e4fd 100644 --- a/tests/with-lib.nix +++ b/tests/with-lib.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/zfs-over-legacy.nix b/tests/zfs-over-legacy.nix index af78060..2cdebc3 100644 --- a/tests/zfs-over-legacy.nix +++ b/tests/zfs-over-legacy.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/zfs-with-vdevs.nix b/tests/zfs-with-vdevs.nix index da301a0..7dda11a 100644 --- a/tests/zfs-with-vdevs.nix +++ b/tests/zfs-with-vdevs.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs; diff --git a/tests/zfs.nix b/tests/zfs.nix index da2e49c..81ab7b8 100644 --- a/tests/zfs.nix +++ b/tests/zfs.nix @@ -1,5 +1,5 @@ { pkgs ? import { } -, diskoLib ? pkgs.callPackage ../lib { } +, diskoLib ? pkgs.callPackage ../src/disko_lib { } }: diskoLib.testLib.makeDiskoTest { inherit pkgs;