This commit is contained in:
Qyriad 2026-02-16 18:02:39 +01:00
parent da509d97c7
commit 3765e918d6
18 changed files with 348 additions and 226 deletions

View file

@ -55,6 +55,27 @@ def get_config_file() -> dict[str, Any]:
config_file_path.unlink()
return config_data
@beartype
def dynix_append(option: str, value: Any):
machine.succeed(f'''
dynix append {shlex.quote(option)} {shlex.quote(str(value))}
'''.strip())
@beartype
def do_apply():
expr = textwrap.dedent("""
let
nixos = import <nixpkgs/nixos> { };
in nixos.config.dynamicism.applyDynamicConfiguration {
baseConfiguration = /etc/nixos/configuration.nix;
newConfiguration = /etc/nixos/dynamic.nix;
}
""").strip()
machine.succeed(rf"""
nix run --show-trace --log-format raw-with-logs --impure -E {shlex.quote(expr)}
""".strip())
machine.wait_for_unit("default.target")
assert "lix" in machine.succeed("nix --version").lower()
machine.log("INIT")
@ -75,17 +96,8 @@ assert int(config_toml['workers']) == 4, f"{config_toml['workers']=} != 4"
assert int(config_toml['max_connection_rate']) == 256, f"{config_toml['max_connection_rate']=} != 256"
new_workers = 20
expr = textwrap.dedent(f"""
let
nixos = import <nixpkgs/nixos> {{ }};
in nixos.config.dynamicism.doChange {{
option = "services.harmonia.settings.workers";
value = {new_workers};
}}
""").strip()
machine.succeed(rf"""
nix run --show-trace --log-format raw-with-logs --impure -E {shlex.quote(expr)}
""".strip())
dynix_append("services.harmonia.settings.workers", new_workers)
do_apply()
# Workers, but not max connection rate, should have changed.
config_toml = get_config_file()
@ -94,17 +106,8 @@ assert int(config_toml['workers']) == new_workers, f"{config_toml['workers']=} !
assert int(config_toml['max_connection_rate']) == 256, f"{config_toml['max_connection_rate']=} != 256"
new_max_connection_rate = 100
expr = textwrap.dedent(f"""
let
nixos = import <nixpkgs/nixos> {{ }};
in nixos.config.dynamicism.doChange {{
option = [ "services" "harmonia" "settings" "max_connection_rate" ];
value = {new_max_connection_rate};
}}
""").strip()
machine.succeed(rf"""
nix run --show-trace --log-format raw-with-logs --impure -E {shlex.quote(expr)}
""".strip())
dynix_append("services.harmonia.settings.max_connection_rate", new_max_connection_rate)
do_apply()
# Max connection rate should have changed, but workers should have reverted.
config_toml = get_config_file()