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, ... }: {
|
nodes.machine = { self, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
../../clanModules/deltachat.nix
|
self.clanModules.deltachat
|
||||||
self.nixosModules.clanCore
|
self.nixosModules.clanCore
|
||||||
{
|
{
|
||||||
clanCore.machineName = "machine";
|
clanCore.machineName = "machine";
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{ extraPythonPackages, buildPythonApplication, self, setuptools, util-linux, systemd }:
|
{ extraPythonPackages, python3Packages, buildPythonApplication, setuptools, util-linux, systemd }:
|
||||||
buildPythonApplication {
|
buildPythonApplication {
|
||||||
pname = "test-driver";
|
pname = "test-driver";
|
||||||
version = "0.0.1";
|
version = "0.0.1";
|
||||||
propagatedBuildInputs = [ util-linux systemd ] ++ extraPythonPackages self;
|
propagatedBuildInputs = [ util-linux systemd ] ++ extraPythonPackages python3Packages;
|
||||||
nativeBuildInputs = [ setuptools ];
|
nativeBuildInputs = [ setuptools ];
|
||||||
format = "pyproject";
|
format = "pyproject";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|||||||
@@ -21,11 +21,6 @@ line-length = 88
|
|||||||
select = ["E", "F", "I", "U", "N"]
|
select = ["E", "F", "I", "U", "N"]
|
||||||
ignore = ["E501"]
|
ignore = ["E501"]
|
||||||
|
|
||||||
[tool.black]
|
|
||||||
line-length = 88
|
|
||||||
target-version = ['py39']
|
|
||||||
include = '\.pyi?$'
|
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
python_version = "3.10"
|
python_version = "3.10"
|
||||||
warn_redundant_casts = true
|
warn_redundant_casts = true
|
||||||
|
|||||||
8
flake.lock
generated
8
flake.lock
generated
@@ -98,16 +98,16 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696051733,
|
"lastModified": 1699007274,
|
||||||
"narHash": "sha256-fEC8/6wJOWgCSvBjPwMBdaYtp57OUfQd3dJgp0D/It4=",
|
"narHash": "sha256-m0NH2trnW8cOhona6m3hWkeDZ28BV/wAGPd/YWik23g=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "c3bd4f19ef0062d4462444aa413e26c917187ae9",
|
"rev": "fcb19bae00e9d3fd5ecf4a1f80cf33248bf7f714",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"ref": "fakeroot",
|
"ref": "deltachat",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
nixConfig.extra-trusted-public-keys = [ "cache.clan.lol-1:3KztgSAB5R1M+Dz7vzkBGzXdodizbgLXGXKXlcQLA28=" ];
|
nixConfig.extra-trusted-public-keys = [ "cache.clan.lol-1:3KztgSAB5R1M+Dz7vzkBGzXdodizbgLXGXKXlcQLA28=" ];
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
#nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
#nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
|
||||||
# https://github.com/NixOS/nixpkgs/pull/257462
|
# https://github.com/NixOS/nixpkgs/pull/265024
|
||||||
nixpkgs.url = "github:Mic92/nixpkgs/fakeroot";
|
nixpkgs.url = "github:Mic92/nixpkgs/deltachat";
|
||||||
floco.url = "github:aakropotkin/floco";
|
floco.url = "github:aakropotkin/floco";
|
||||||
floco.inputs.nixpkgs.follows = "nixpkgs";
|
floco.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
disko.url = "github:nix-community/disko";
|
disko.url = "github:nix-community/disko";
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"-eucx"
|
"-eucx"
|
||||||
''
|
''
|
||||||
${lib.getExe pkgs.ruff} --fix "$@"
|
${lib.getExe pkgs.ruff} --fix "$@"
|
||||||
${lib.getExe pkgs.black} "$@"
|
${lib.getExe pkgs.ruff} format "$@"
|
||||||
''
|
''
|
||||||
"--" # this argument is ignored by bash
|
"--" # this argument is ignored by bash
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import argparse
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Optional
|
from typing import Any, Optional, Sequence
|
||||||
|
|
||||||
from . import config, flakes, join, machines, secrets, vms, webui
|
from . import config, flakes, join, machines, secrets, vms, webui
|
||||||
from .custom_logger import setup_logging
|
from .custom_logger import setup_logging
|
||||||
@@ -17,6 +17,24 @@ except ImportError:
|
|||||||
pass
|
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:
|
def create_parser(prog: Optional[str] = None) -> argparse.ArgumentParser:
|
||||||
parser = argparse.ArgumentParser(prog=prog, description="cLAN tool")
|
parser = argparse.ArgumentParser(prog=prog, description="cLAN tool")
|
||||||
|
|
||||||
@@ -29,9 +47,9 @@ def create_parser(prog: Optional[str] = None) -> argparse.ArgumentParser:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--option",
|
"--option",
|
||||||
help="Nix option to set",
|
help="Nix option to set",
|
||||||
action="append",
|
|
||||||
nargs=2,
|
nargs=2,
|
||||||
metavar=("name", "value"),
|
metavar=("name", "value"),
|
||||||
|
action=AppendOptionAction,
|
||||||
default=[],
|
default=[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -153,27 +153,44 @@ class BuildVmTask(BaseTask):
|
|||||||
"console=tty0",
|
"console=tty0",
|
||||||
]
|
]
|
||||||
qemu_command = [
|
qemu_command = [
|
||||||
# fmt: off
|
|
||||||
"qemu-kvm",
|
"qemu-kvm",
|
||||||
"-name", machine,
|
"-name",
|
||||||
"-m", f'{vm_config["memorySize"]}M',
|
machine,
|
||||||
"-smp", str(vm_config["cores"]),
|
"-m",
|
||||||
"-device", "virtio-rng-pci",
|
f'{vm_config["memorySize"]}M',
|
||||||
"-net", "nic,netdev=user.0,model=virtio", "-netdev", "user,id=user.0",
|
"-smp",
|
||||||
"-virtfs", "local,path=/nix/store,security_model=none,mount_tag=nix-store",
|
str(vm_config["cores"]),
|
||||||
"-virtfs", f"local,path={xchg_dir},security_model=none,mount_tag=shared",
|
"-device",
|
||||||
"-virtfs", f"local,path={xchg_dir},security_model=none,mount_tag=xchg",
|
"virtio-rng-pci",
|
||||||
"-virtfs", f"local,path={secrets_dir},security_model=none,mount_tag=secrets",
|
"-net",
|
||||||
"-drive", f'cache=writeback,file={disk_img},format=raw,id=drive1,if=none,index=1,werror=report',
|
"nic,netdev=user.0,model=virtio",
|
||||||
"-device", "virtio-blk-pci,bootindex=1,drive=drive1,serial=root",
|
"-netdev",
|
||||||
"-device", "virtio-keyboard",
|
"user,id=user.0",
|
||||||
"-vga", "virtio",
|
"-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",
|
"-usb",
|
||||||
"-device", "usb-tablet,bus=usb-bus.0",
|
"-device",
|
||||||
"-kernel", f'{vm_config["toplevel"]}/kernel',
|
"usb-tablet,bus=usb-bus.0",
|
||||||
"-initrd", vm_config["initrd"],
|
"-kernel",
|
||||||
"-append", " ".join(cmdline),
|
f'{vm_config["toplevel"]}/kernel',
|
||||||
# fmt: on
|
"-initrd",
|
||||||
|
vm_config["initrd"],
|
||||||
|
"-append",
|
||||||
|
" ".join(cmdline),
|
||||||
]
|
]
|
||||||
if not self.vm.graphics:
|
if not self.vm.graphics:
|
||||||
qemu_command.append("-nographic")
|
qemu_command.append("-nographic")
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ from ..errors import ClanError
|
|||||||
log = logging.getLogger(__name__)
|
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)
|
log.error("ClanError: %s", exc)
|
||||||
detail = [
|
detail = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,25 +58,3 @@ line-length = 88
|
|||||||
|
|
||||||
select = [ "E", "F", "I", "N"]
|
select = [ "E", "F", "I", "N"]
|
||||||
ignore = [ "E501" ]
|
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]
|
[tool.mypy]
|
||||||
python_version = "3.10"
|
python_version = "3.10"
|
||||||
|
pretty = true
|
||||||
warn_redundant_casts = true
|
warn_redundant_casts = true
|
||||||
disallow_untyped_calls = true
|
disallow_untyped_calls = true
|
||||||
disallow_untyped_defs = true
|
disallow_untyped_defs = true
|
||||||
@@ -11,25 +12,3 @@ line-length = 88
|
|||||||
|
|
||||||
select = [ "E", "F", "I", "U", "N"]
|
select = [ "E", "F", "I", "U", "N"]
|
||||||
ignore = [ "E501" ]
|
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