Fix merge issue
Some checks failed
checks / check-links (pull_request) Successful in 14s
checks / checks-impure (pull_request) Successful in 1m53s
checks / checks (pull_request) Failing after 4m29s

This commit is contained in:
Luis Hebendanz 2024-04-06 11:56:06 +02:00
commit 91dddc2281
3 changed files with 53 additions and 29 deletions

View File

@ -6,33 +6,37 @@
example = "/dev/disk/by-id/ata-Samsung_SSD_850_EVO_250GB_S21PNXAGB12345"; example = "/dev/disk/by-id/ata-Samsung_SSD_850_EVO_250GB_S21PNXAGB12345";
}; };
}; };
config.disko.devices = { config = {
disk = { boot.loader.grub.efiSupport = lib.mkDefault true;
main = { boot.loader.grub.efiInstallAsRemovable = lib.mkDefault true;
type = "disk"; disko.devices = {
device = config.clan.diskLayouts.singleDiskExt4.device; disk = {
content = { main = {
type = "gpt"; type = "disk";
partitions = { device = config.clan.diskLayouts.singleDiskExt4.device;
boot = { content = {
size = "1M"; type = "gpt";
type = "EF02"; # for grub MBR partitions = {
}; boot = {
ESP = { size = "1M";
size = "512M"; type = "EF02"; # for grub MBR
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
}; };
}; ESP = {
root = { size = "512M";
size = "100%"; type = "EF00";
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "vfat";
mountpoint = "/"; mountpoint = "/boot";
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
}; };
}; };
}; };

View File

@ -22,7 +22,7 @@ in
description = "The directory containing the clan subdirectory"; description = "The directory containing the clan subdirectory";
}; };
specialArgs = mkOption { specialArgs = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.raw;
default = { }; default = { };
description = "Extra arguments to pass to nixosSystem i.e. useful to make self available"; description = "Extra arguments to pass to nixosSystem i.e. useful to make self available";
}; };

View File

@ -4,6 +4,7 @@ import logging
import os import os
import shlex import shlex
import shutil import shutil
import textwrap
from collections.abc import Sequence from collections.abc import Sequence
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
@ -20,7 +21,7 @@ log = logging.getLogger(__name__)
def flash_machine( def flash_machine(
machine: Machine, disks: dict[str, str], dry_run: bool, debug: bool machine: Machine, mode: str, disks: dict[str, str], dry_run: bool, debug: bool
) -> None: ) -> None:
secret_facts_module = importlib.import_module(machine.secret_facts_module) secret_facts_module = importlib.import_module(machine.secret_facts_module)
secret_facts_store: SecretStoreBase = secret_facts_module.SecretStore( secret_facts_store: SecretStoreBase = secret_facts_module.SecretStore(
@ -56,6 +57,7 @@ def flash_machine(
disko_install.extend(["--extra-files", str(local_dir), upload_dir]) disko_install.extend(["--extra-files", str(local_dir), upload_dir])
disko_install.extend(["--flake", str(machine.flake) + "#" + machine.name]) disko_install.extend(["--flake", str(machine.flake) + "#" + machine.name])
disko_install.extend(["--mode", str(mode)])
cmd = nix_shell( cmd = nix_shell(
["nixpkgs#disko"], ["nixpkgs#disko"],
@ -73,6 +75,7 @@ class FlashOptions:
dry_run: bool dry_run: bool
confirm: bool confirm: bool
debug: bool debug: bool
mode: str
class AppendDiskAction(argparse.Action): class AppendDiskAction(argparse.Action):
@ -99,6 +102,7 @@ def flash_command(args: argparse.Namespace) -> None:
dry_run=args.dry_run, dry_run=args.dry_run,
confirm=not args.yes, confirm=not args.yes,
debug=args.debug, debug=args.debug,
mode=args.mode,
) )
machine = Machine(opts.machine, flake=opts.flake) machine = Machine(opts.machine, flake=opts.flake)
if opts.confirm and not opts.dry_run: if opts.confirm and not opts.dry_run:
@ -110,7 +114,9 @@ def flash_command(args: argparse.Namespace) -> None:
ask = input(msg) ask = input(msg)
if ask != "y": if ask != "y":
return return
flash_machine(machine, disks=opts.disks, dry_run=opts.dry_run, debug=opts.debug) flash_machine(
machine, opts.mode, disks=opts.disks, dry_run=opts.dry_run, debug=opts.debug
)
def register_parser(parser: argparse.ArgumentParser) -> None: def register_parser(parser: argparse.ArgumentParser) -> None:
@ -128,6 +134,20 @@ def register_parser(parser: argparse.ArgumentParser) -> None:
help="device to flash to", help="device to flash to",
default={}, default={},
) )
mode_help = textwrap.dedent("""\
Specify the mode of operation. Valid modes are: format, mount."
Format will format the disk before installing.
Mount will mount the disk before installing.
Mount is useful for updating an existing system without losing data.
""")
parser.add_argument(
"--mode",
type=str,
help=mode_help,
choices=["format", "mount"],
default="format",
)
parser.add_argument( parser.add_argument(
"--yes", "--yes",
action="store_true", action="store_true",