clan-flash: --keymap option also sets xserver keymap now. renamed 'clan flash apply' to clan 'flash write'

This commit is contained in:
Qubasa
2024-10-11 20:51:59 +02:00
parent 42f4d8eff1
commit 02e148d2ea
8 changed files with 22 additions and 18 deletions

View File

@@ -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; };
};

View File

@@ -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 \

View File

@@ -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<X> --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<X> --ssh-pubkey ~/.ssh/id_rsa.pub
Will flash the machine 'mymachine' to the disk '/dev/sd<X>' 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")}
"""

View File

@@ -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)

View File

@@ -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 = []

View File

@@ -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,

View File

@@ -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",

View File

@@ -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 ];