Merge pull request 'cli: merge nix options correctly; ruff format' (#451) from maddy into main
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
nodes.machine = { self, ... }: {
|
||||
imports = [
|
||||
../../clanModules/deltachat.nix
|
||||
self.clanModules.deltachat
|
||||
self.nixosModules.clanCore
|
||||
{
|
||||
clanCore.machineName = "machine";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{ extraPythonPackages, buildPythonApplication, self, setuptools, util-linux, systemd }:
|
||||
{ extraPythonPackages, python3Packages, buildPythonApplication, setuptools, util-linux, systemd }:
|
||||
buildPythonApplication {
|
||||
pname = "test-driver";
|
||||
version = "0.0.1";
|
||||
propagatedBuildInputs = [ util-linux systemd ] ++ extraPythonPackages self;
|
||||
propagatedBuildInputs = [ util-linux systemd ] ++ extraPythonPackages python3Packages;
|
||||
nativeBuildInputs = [ setuptools ];
|
||||
format = "pyproject";
|
||||
src = ./.;
|
||||
|
||||
@@ -21,11 +21,6 @@ line-length = 88
|
||||
select = ["E", "F", "I", "U", "N"]
|
||||
ignore = ["E501"]
|
||||
|
||||
[tool.black]
|
||||
line-length = 88
|
||||
target-version = ['py39']
|
||||
include = '\.pyi?$'
|
||||
|
||||
[tool.mypy]
|
||||
python_version = "3.10"
|
||||
warn_redundant_casts = true
|
||||
|
||||
8
flake.lock
generated
8
flake.lock
generated
@@ -98,16 +98,16 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1696051733,
|
||||
"narHash": "sha256-fEC8/6wJOWgCSvBjPwMBdaYtp57OUfQd3dJgp0D/It4=",
|
||||
"lastModified": 1699007274,
|
||||
"narHash": "sha256-m0NH2trnW8cOhona6m3hWkeDZ28BV/wAGPd/YWik23g=",
|
||||
"owner": "Mic92",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c3bd4f19ef0062d4462444aa413e26c917187ae9",
|
||||
"rev": "fcb19bae00e9d3fd5ecf4a1f80cf33248bf7f714",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Mic92",
|
||||
"ref": "fakeroot",
|
||||
"ref": "deltachat",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
nixConfig.extra-trusted-public-keys = [ "cache.clan.lol-1:3KztgSAB5R1M+Dz7vzkBGzXdodizbgLXGXKXlcQLA28=" ];
|
||||
|
||||
inputs = {
|
||||
#nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
# https://github.com/NixOS/nixpkgs/pull/257462
|
||||
nixpkgs.url = "github:Mic92/nixpkgs/fakeroot";
|
||||
#nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
|
||||
# https://github.com/NixOS/nixpkgs/pull/265024
|
||||
nixpkgs.url = "github:Mic92/nixpkgs/deltachat";
|
||||
floco.url = "github:aakropotkin/floco";
|
||||
floco.inputs.nixpkgs.follows = "nixpkgs";
|
||||
disko.url = "github:nix-community/disko";
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
"-eucx"
|
||||
''
|
||||
${lib.getExe pkgs.ruff} --fix "$@"
|
||||
${lib.getExe pkgs.black} "$@"
|
||||
${lib.getExe pkgs.ruff} format "$@"
|
||||
''
|
||||
"--" # this argument is ignored by bash
|
||||
];
|
||||
|
||||
@@ -2,7 +2,7 @@ import argparse
|
||||
import logging
|
||||
import sys
|
||||
from types import ModuleType
|
||||
from typing import Optional
|
||||
from typing import Any, Optional, Sequence
|
||||
|
||||
from . import config, flakes, join, machines, secrets, vms, webui
|
||||
from .custom_logger import setup_logging
|
||||
@@ -17,6 +17,24 @@ except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
class AppendOptionAction(argparse.Action):
|
||||
def __init__(self, option_strings: str, dest: str, **kwargs: Any) -> None:
|
||||
super().__init__(option_strings, dest, **kwargs)
|
||||
|
||||
def __call__(
|
||||
self,
|
||||
parser: argparse.ArgumentParser,
|
||||
namespace: argparse.Namespace,
|
||||
values: str | Sequence[str] | None,
|
||||
option_string: Optional[str] = None,
|
||||
) -> None:
|
||||
lst = getattr(namespace, self.dest)
|
||||
lst.append("--option")
|
||||
assert isinstance(values, list), "values must be a list"
|
||||
lst.append(values[0])
|
||||
lst.append(values[1])
|
||||
|
||||
|
||||
def create_parser(prog: Optional[str] = None) -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(prog=prog, description="cLAN tool")
|
||||
|
||||
@@ -29,9 +47,9 @@ def create_parser(prog: Optional[str] = None) -> argparse.ArgumentParser:
|
||||
parser.add_argument(
|
||||
"--option",
|
||||
help="Nix option to set",
|
||||
action="append",
|
||||
nargs=2,
|
||||
metavar=("name", "value"),
|
||||
action=AppendOptionAction,
|
||||
default=[],
|
||||
)
|
||||
|
||||
|
||||
@@ -153,27 +153,44 @@ class BuildVmTask(BaseTask):
|
||||
"console=tty0",
|
||||
]
|
||||
qemu_command = [
|
||||
# fmt: off
|
||||
"qemu-kvm",
|
||||
"-name", machine,
|
||||
"-m", f'{vm_config["memorySize"]}M',
|
||||
"-smp", str(vm_config["cores"]),
|
||||
"-device", "virtio-rng-pci",
|
||||
"-net", "nic,netdev=user.0,model=virtio", "-netdev", "user,id=user.0",
|
||||
"-virtfs", "local,path=/nix/store,security_model=none,mount_tag=nix-store",
|
||||
"-virtfs", f"local,path={xchg_dir},security_model=none,mount_tag=shared",
|
||||
"-virtfs", f"local,path={xchg_dir},security_model=none,mount_tag=xchg",
|
||||
"-virtfs", f"local,path={secrets_dir},security_model=none,mount_tag=secrets",
|
||||
"-drive", f'cache=writeback,file={disk_img},format=raw,id=drive1,if=none,index=1,werror=report',
|
||||
"-device", "virtio-blk-pci,bootindex=1,drive=drive1,serial=root",
|
||||
"-device", "virtio-keyboard",
|
||||
"-vga", "virtio",
|
||||
"-name",
|
||||
machine,
|
||||
"-m",
|
||||
f'{vm_config["memorySize"]}M',
|
||||
"-smp",
|
||||
str(vm_config["cores"]),
|
||||
"-device",
|
||||
"virtio-rng-pci",
|
||||
"-net",
|
||||
"nic,netdev=user.0,model=virtio",
|
||||
"-netdev",
|
||||
"user,id=user.0",
|
||||
"-virtfs",
|
||||
"local,path=/nix/store,security_model=none,mount_tag=nix-store",
|
||||
"-virtfs",
|
||||
f"local,path={xchg_dir},security_model=none,mount_tag=shared",
|
||||
"-virtfs",
|
||||
f"local,path={xchg_dir},security_model=none,mount_tag=xchg",
|
||||
"-virtfs",
|
||||
f"local,path={secrets_dir},security_model=none,mount_tag=secrets",
|
||||
"-drive",
|
||||
f"cache=writeback,file={disk_img},format=raw,id=drive1,if=none,index=1,werror=report",
|
||||
"-device",
|
||||
"virtio-blk-pci,bootindex=1,drive=drive1,serial=root",
|
||||
"-device",
|
||||
"virtio-keyboard",
|
||||
"-vga",
|
||||
"virtio",
|
||||
"-usb",
|
||||
"-device", "usb-tablet,bus=usb-bus.0",
|
||||
"-kernel", f'{vm_config["toplevel"]}/kernel',
|
||||
"-initrd", vm_config["initrd"],
|
||||
"-append", " ".join(cmdline),
|
||||
# fmt: on
|
||||
"-device",
|
||||
"usb-tablet,bus=usb-bus.0",
|
||||
"-kernel",
|
||||
f'{vm_config["toplevel"]}/kernel',
|
||||
"-initrd",
|
||||
vm_config["initrd"],
|
||||
"-append",
|
||||
" ".join(cmdline),
|
||||
]
|
||||
if not self.vm.graphics:
|
||||
qemu_command.append("-nographic")
|
||||
|
||||
@@ -9,7 +9,8 @@ from ..errors import ClanError
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def clan_error_handler(request: Request, exc: ClanError) -> JSONResponse:
|
||||
def clan_error_handler(request: Request, exc: Exception) -> JSONResponse:
|
||||
assert isinstance(exc, ClanError)
|
||||
log.error("ClanError: %s", exc)
|
||||
detail = [
|
||||
{
|
||||
|
||||
@@ -58,25 +58,3 @@ line-length = 88
|
||||
|
||||
select = [ "E", "F", "I", "N"]
|
||||
ignore = [ "E501" ]
|
||||
|
||||
[tool.black]
|
||||
line-length = 88
|
||||
target-version = [ "py310" ]
|
||||
include = "\\.pyi?$"
|
||||
exclude = '''
|
||||
/(
|
||||
\.git
|
||||
| \.hg
|
||||
| \.mypy_cache
|
||||
| \.tox
|
||||
| \.venv
|
||||
| _build
|
||||
| buck-out
|
||||
| build
|
||||
| dist
|
||||
# The following are specific to Black, you probably don't want those.
|
||||
| blib2to3
|
||||
| tests/data
|
||||
| profiling
|
||||
)/
|
||||
'''
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[tool.mypy]
|
||||
python_version = "3.10"
|
||||
pretty = true
|
||||
warn_redundant_casts = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_defs = true
|
||||
@@ -11,25 +12,3 @@ line-length = 88
|
||||
|
||||
select = [ "E", "F", "I", "U", "N"]
|
||||
ignore = [ "E501" ]
|
||||
|
||||
[tool.black]
|
||||
line-length = 88
|
||||
target-version = [ "py310" ]
|
||||
include = "\\.pyi?$"
|
||||
exclude = '''
|
||||
/(
|
||||
\.git
|
||||
| \.hg
|
||||
| \.mypy_cache
|
||||
| \.tox
|
||||
| \.venv
|
||||
| _build
|
||||
| buck-out
|
||||
| build
|
||||
| dist
|
||||
# The following are specific to Black, you probably don't want those.
|
||||
| blib2to3
|
||||
| tests/data
|
||||
| profiling
|
||||
)/
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user