From 02e148d2ea28fb165fd3456f8d502a8f9d9ccd42 Mon Sep 17 00:00:00 2001 From: Qubasa Date: Fri, 11 Oct 2024 20:51:59 +0200 Subject: [PATCH] clan-flash: --keymap option also sets xserver keymap now. renamed 'clan flash apply' to clan 'flash write' --- checks/flash/flake-module.nix | 2 +- docs/site/getting-started/installer.md | 2 +- pkgs/clan-cli/clan_cli/__init__.py | 5 ++--- pkgs/clan-cli/clan_cli/flash/cli.py | 14 ++++++++------ pkgs/clan-cli/clan_cli/flash/flash.py | 7 +++++-- pkgs/clan-cli/clan_cli/flash/flash_cmd.py | 2 +- pkgs/clan-cli/clan_cli/flash/list.py | 6 +++--- pkgs/installer/flake-module.nix | 2 +- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/checks/flash/flake-module.nix b/checks/flash/flake-module.nix index ab061c01c..29a3d7c26 100644 --- a/checks/flash/flake-module.nix +++ b/checks/flash/flake-module.nix @@ -42,7 +42,7 @@ testScript = '' start_all() - machine.succeed("clan flash apply --debug --flake ${../..} --yes --disk main /dev/vdb test-install-machine") + machine.succeed("clan flash write --debug --flake ${../..} --yes --disk main /dev/vdb test-install-machine") ''; } { inherit pkgs self; }; }; diff --git a/docs/site/getting-started/installer.md b/docs/site/getting-started/installer.md index 30839a055..6ea2a09d1 100644 --- a/docs/site/getting-started/installer.md +++ b/docs/site/getting-started/installer.md @@ -46,7 +46,7 @@ sudo umount /dev/sdb1 It also allows to set language and keymap in the installer image. ```bash - clan flash apply --flake git+https://git.clan.lol/clan/clan-core \ + clan flash write --flake git+https://git.clan.lol/clan/clan-core \ --ssh-pubkey $HOME/.ssh/id_ed25519.pub \ --keymap us \ --language en_US.UTF-8 \ diff --git a/pkgs/clan-cli/clan_cli/__init__.py b/pkgs/clan-cli/clan_cli/__init__.py index b676f7a48..ff12d13e7 100644 --- a/pkgs/clan-cli/clan_cli/__init__.py +++ b/pkgs/clan-cli/clan_cli/__init__.py @@ -182,9 +182,8 @@ For more detailed information, visit: {help_hyperlink("getting-started", "https: epilog=( f""" Examples: - $ clan flash import installer - $ clan flash apply installer --disk main /dev/sd --ssh-pubkey ~/.ssh/id_rsa.pub - Will create and flash a custom installer nixos image onto a drive + $ clan flash write mymachine --disk main /dev/sd --ssh-pubkey ~/.ssh/id_rsa.pub + Will flash the machine 'mymachine' to the disk '/dev/sd' with the ssh public key '~/.ssh/id_rsa.pub'. For more detailed information, visit: {help_hyperlink("getting-started", "https://docs.clan.lol/getting-started/installer")} """ diff --git a/pkgs/clan-cli/clan_cli/flash/cli.py b/pkgs/clan-cli/clan_cli/flash/cli.py index 193e0c491..e4d093be2 100644 --- a/pkgs/clan-cli/clan_cli/flash/cli.py +++ b/pkgs/clan-cli/clan_cli/flash/cli.py @@ -1,7 +1,7 @@ # !/usr/bin/env python3 import argparse -from .flash_cmd import register_flash_apply_parser +from .flash_cmd import register_flash_write_parser from .list import register_flash_list_parser @@ -14,11 +14,13 @@ def register_parser(parser: argparse.ArgumentParser) -> None: required=True, ) - apply_parser = subparser.add_parser( - "apply", - help="Flash a machine", + write_parser = subparser.add_parser( + "write", + help="Flash a machine to a disk", ) - register_flash_apply_parser(apply_parser) + register_flash_write_parser(write_parser) - list_parser = subparser.add_parser("list", help="List options") + list_parser = subparser.add_parser( + "list", help="List possible keymaps or languages" + ) register_flash_list_parser(list_parser) diff --git a/pkgs/clan-cli/clan_cli/flash/flash.py b/pkgs/clan-cli/clan_cli/flash/flash.py index 326619d30..74b7cdfcf 100644 --- a/pkgs/clan-cli/clan_cli/flash/flash.py +++ b/pkgs/clan-cli/clan_cli/flash/flash.py @@ -73,7 +73,7 @@ def flash_machine( if system_config.language not in list_possible_languages(): msg = ( f"Language '{system_config.language}' is not a valid language. " - f"Run 'clan flash --list-languages' to see a list of possible languages." + f"Run 'clan flash list languages' to see a list of possible languages." ) raise ClanError(msg) system_config_nix["i18n"] = {"defaultLocale": system_config.language} @@ -82,10 +82,13 @@ def flash_machine( if system_config.keymap not in list_possible_keymaps(): msg = ( f"Keymap '{system_config.keymap}' is not a valid keymap. " - f"Run 'clan flash --list-keymaps' to see a list of possible keymaps." + f"Run 'clan flash list keymaps' to see a list of possible keymaps." ) raise ClanError(msg) system_config_nix["console"] = {"keyMap": system_config.keymap} + system_config_nix["services"] = { + "xserver": {"xkb": {"layout": system_config.keymap}} + } if system_config.ssh_keys_path: root_keys = [] diff --git a/pkgs/clan-cli/clan_cli/flash/flash_cmd.py b/pkgs/clan-cli/clan_cli/flash/flash_cmd.py index 6b5fc443e..c636d7b5a 100644 --- a/pkgs/clan-cli/clan_cli/flash/flash_cmd.py +++ b/pkgs/clan-cli/clan_cli/flash/flash_cmd.py @@ -101,7 +101,7 @@ def flash_command(args: argparse.Namespace) -> None: ) -def register_flash_apply_parser(parser: argparse.ArgumentParser) -> None: +def register_flash_write_parser(parser: argparse.ArgumentParser) -> None: machines_parser = parser.add_argument( "machine", type=str, diff --git a/pkgs/clan-cli/clan_cli/flash/list.py b/pkgs/clan-cli/clan_cli/flash/list.py index d7d31b536..29c9c2163 100644 --- a/pkgs/clan-cli/clan_cli/flash/list.py +++ b/pkgs/clan-cli/clan_cli/flash/list.py @@ -60,11 +60,11 @@ def list_possible_keymaps() -> list[str]: def list_command(args: argparse.Namespace) -> None: - if args.options == "languages": + if args.cmd == "languages": languages = list_possible_languages() for language in languages: print(language) - elif args.options == "keymaps": + elif args.cmd == "keymaps": keymaps = list_possible_keymaps() for keymap in keymaps: print(keymap) @@ -72,7 +72,7 @@ def list_command(args: argparse.Namespace) -> None: def register_flash_list_parser(parser: argparse.ArgumentParser) -> None: parser.add_argument( - "OPTION", + "cmd", choices=["languages", "keymaps"], type=str, help="list possible languages or keymaps", diff --git a/pkgs/installer/flake-module.nix b/pkgs/installer/flake-module.nix index c3afd2940..02eef1146 100644 --- a/pkgs/installer/flake-module.nix +++ b/pkgs/installer/flake-module.nix @@ -70,7 +70,7 @@ in { clan = { # To directly flash the installer to a disk, use the following command: - # $ clan flash flash-installer --disk main /dev/sdX --yes + # $ clan flash write flash-installer --disk main /dev/sdX --yes # This will include your ssh public keys in the installer. machines.flash-installer = { imports = [ flashInstallerModule ];