Compare commits

..

1 Commits

Author SHA1 Message Date
7b24ac3edb locked linux-firmware and 6.12.52 2025-11-23 11:17:36 -05:00
24 changed files with 238 additions and 660 deletions

View File

@@ -1,9 +0,0 @@
---
description: Format code using treefmt
---
// turbo
1. Run treefmt
```bash
treefmt
```

View File

@@ -1,48 +0,0 @@
name: Fix Evaluation Warnings
on:
workflow_run:
workflows: ["build_systems"]
types:
- completed
permissions:
contents: write
pull-requests: write
actions: read
jobs:
analyze-and-fix:
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download logs
env:
GH_TOKEN: ${{ github.token }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
gh run view $RUN_ID --log > build.log
- name: Run Fix Script
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
RUN_ID: ${{ github.event.workflow_run.id }}
PYTHONPATH: .
run: |
python3 python/tools/fix_eval_warnings.py build.log
- name: Create Pull Request
if: hashFiles('fix_suggestions.md') != ''
uses: peter-evans/create-pull-request@v6
with:
token: ${{ github.token }}
commit-message: "fix: automated evaluation warning fixes"
title: "fix: automated evaluation warning fixes"
body-path: fix_suggestions.md
branch: "auto-fix-eval-warnings-${{ github.event.workflow_run.id }}"
base: main
labels: "automated-fix"

1
.gitignore vendored
View File

@@ -165,4 +165,3 @@ test.*
# syncthing # syncthing
.stfolder .stfolder
fix_suggestions.md

View File

@@ -1,12 +0,0 @@
## Dev environment tips
- use treefmt to format all files
- keep new code consistent with the existing style
### Python
- make code `ruff` compliant
- use pytest to test python code tests should be put in `tests` directory
- dont use global state
- use google style docstrings
- use typer over argparse

View File

@@ -22,7 +22,22 @@
boot = { boot = {
tmp.useTmpfs = true; tmp.useTmpfs = true;
kernelPackages = lib.mkDefault pkgs.linuxPackages_6_12; kernelPackages = lib.mkDefault (
pkgs.linuxPackages_6_12.extend (
self: super: {
kernel = super.kernel.override {
argsOverride = {
version = "6.12.52";
modDirVersion = "6.12.52";
src = pkgs.fetchurl {
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.52.tar.xz";
sha256 = "sha256-tIUM9nCgMscPOLcTon1iBGxfdHyvAoxfULGPmGBqnrE=";
};
};
};
}
)
);
zfs.package = lib.mkDefault pkgs.zfs_2_3; zfs.package = lib.mkDefault pkgs.zfs_2_3;
}; };

129
esphome/batteries.yml Normal file
View File

@@ -0,0 +1,129 @@
esphome:
name: batteries
friendly_name: batteries
esp32:
board: esp32dev
framework:
type: arduino
logger:
api:
encryption:
key: !secret api_key
external_components:
- source: github://syssi/esphome-jk-bms@main
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
esp32_ble_tracker:
scan_parameters:
interval: 1100ms
window: 1100ms
active: true
ble_client:
- mac_address: "C8:47:80:29:0F:DB"
id: jk_ble0
- mac_address: "C8:47:80:37:9D:DD"
id: jk_ble1
jk_bms_ble:
- ble_client_id: jk_ble0
protocol_version: JK02_32S
throttle: 1s
id: jk_bms0
- ble_client_id: jk_ble1
protocol_version: JK02_32S
throttle: 1s
id: jk_bms1
sensor:
# BMS1 sensors
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms0
total_voltage:
name: "JK0 Total Voltage"
current:
name: "JK0 Current"
state_of_charge:
name: "JK0 SoC"
power:
name: "JK0 Power"
temperature_sensor_1:
name: "JK0 Temp 1"
temperature_sensor_2:
name: "JK0 Temp 2"
balancing:
name: "JK0 balancing"
charging_cycles:
name: "JK0 charging cycles"
total_runtime:
name: "JK0 total runtime"
balancing_current:
name: "JK0 balancing current"
# BMS2 sensors
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms1
total_voltage:
name: "JK1 Total Voltage"
current:
name: "JK1 Current"
state_of_charge:
name: "JK1 SoC"
power:
name: "Jk1 Power"
temperature_sensor_1:
name: "JK1 Temp 1"
temperature_sensor_2:
name: "Jk1 Temp 2"
balancing:
name: "JK1 balancing"
charging_cycles:
name: "JK1 charging cycles"
total_runtime:
name: "JK1 total runtime"
balancing_current:
name: "JK1 balancing current"
text_sensor:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms0
errors:
name: "JK0 Errors"
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms1
errors:
name: "JK1 Errors"
switch:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms0
charging:
name: "JK0 Charging"
discharging:
name: "JK0 Discharging"
balancer:
name: "JK0 Balancing"
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms1
charging:
name: "JK1 Charging"
discharging:
name: "JK1 Discharging"
balancer:
name: "JK1 Balancing"

View File

@@ -1,132 +0,0 @@
esphome:
name: batteries
friendly_name: batteries
esp32:
board: esp32dev
framework:
type: arduino
logger:
api:
encryption:
key: !secret api_key
external_components:
- source: github://syssi/esphome-jk-bms@main
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: on
captive_portal:
esp32_ble_tracker:
scan_parameters:
interval: 1100ms
window: 1100ms
active: true
ble_client:
- mac_address: "C8:47:80:29:0F:DB"
id: jk_ble0
jk_bms_ble:
- ble_client_id: jk_ble0
protocol_version: JK02_32S
throttle: 1s
id: jk_bms0
button:
- platform: jk_bms_ble
retrieve_settings:
name: "JK0 retrieve settings"
retrieve_device_info:
name: "JK0 retrieve device info"
sensor:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms0
total_voltage:
name: "JK0 Total Voltage"
state_of_charge:
name: "JK0 SoC"
charging_power:
name: "JK0 charging power"
discharging_power:
name: "JK0 discharging power"
temperature_sensor_1:
name: "JK0 Temp 1"
temperature_sensor_2:
name: "JK0 Temp 2"
balancing:
name: "JK0 balancing"
total_runtime:
name: "JK0 total runtime"
balancing_current:
name: "JK0 balancing current"
delta_cell_voltage:
name: "JK0 cell delta voltage"
average_cell_voltage:
name: "JK0 cell average voltage"
cell_voltage_1:
name: "JK0 cell voltage 1"
cell_voltage_2:
name: "JK0 cell voltage 2"
cell_voltage_3:
name: "JK0 cell voltage 3"
cell_voltage_4:
name: "JK0 cell voltage 4"
cell_voltage_5:
name: "JK0 cell voltage 5"
cell_voltage_6:
name: "JK0 cell voltage 6"
cell_voltage_7:
name: "JK0 cell voltage 7"
cell_voltage_8:
name: "JK0 cell voltage 8"
cell_resistance_1:
name: "JK0 cell resistance 1"
cell_resistance_2:
name: "JK0 cell resistance 2"
cell_resistance_3:
name: "JK0 cell resistance 3"
cell_resistance_4:
name: "JK0 cell resistance 4"
cell_resistance_5:
name: "JK0 cell resistance 5"
cell_resistance_6:
name: "JK0 cell resistance 6"
cell_resistance_7:
name: "JK0 cell resistance 7"
cell_resistance_8:
name: "JK0 cell resistance 8"
total_charging_cycle_capacity:
name: "JK0 total charging cycle capacity"
text_sensor:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms0
errors:
name: "JK0 Errors"
switch:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms0
charging:
name: "JK0 Charging"
discharging:
name: "JK0 Discharging"
balancer:
name: "JK0 Balancing"
- platform: ble_client
ble_client_id: jk_ble0
name: "JK0 enable bluetooth connection"
id: ble_client_switch0

View File

@@ -1,132 +0,0 @@
esphome:
name: battery1
friendly_name: battery1
esp32:
board: esp32dev
framework:
type: arduino
logger:
api:
encryption:
key: !secret api_key
external_components:
- source: github://syssi/esphome-jk-bms@main
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: on
captive_portal:
esp32_ble_tracker:
scan_parameters:
interval: 1100ms
window: 1100ms
active: true
ble_client:
- mac_address: "C8:47:80:37:9D:DD"
id: jk_ble1
jk_bms_ble:
- ble_client_id: jk_ble1
protocol_version: JK02_32S
throttle: 1s
id: jk_bms1
button:
- platform: jk_bms_ble
retrieve_settings:
name: "JK1 retrieve settings"
retrieve_device_info:
name: "JK1 retrieve device info"
sensor:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms1
total_voltage:
name: "JK1 Total Voltage"
state_of_charge:
name: "JK1 SoC"
charging_power:
name: "JK1 charging power"
discharging_power:
name: "JK1 discharging power"
temperature_sensor_1:
name: "JK1 Temp 1"
temperature_sensor_2:
name: "JK1 Temp 2"
balancing:
name: "JK1 balancing"
total_runtime:
name: "JK1 total runtime"
balancing_current:
name: "JK1 balancing current"
delta_cell_voltage:
name: "JK1 cell delta voltage"
average_cell_voltage:
name: "JK1 cell average voltage"
cell_voltage_1:
name: "JK1 cell voltage 1"
cell_voltage_2:
name: "JK1 cell voltage 2"
cell_voltage_3:
name: "JK1 cell voltage 3"
cell_voltage_4:
name: "JK1 cell voltage 4"
cell_voltage_5:
name: "JK1 cell voltage 5"
cell_voltage_6:
name: "JK1 cell voltage 6"
cell_voltage_7:
name: "JK1 cell voltage 7"
cell_voltage_8:
name: "JK1 cell voltage 8"
cell_resistance_1:
name: "JK1 cell resistance 1"
cell_resistance_2:
name: "JK1 cell resistance 2"
cell_resistance_3:
name: "JK1 cell resistance 3"
cell_resistance_4:
name: "JK1 cell resistance 4"
cell_resistance_5:
name: "JK1 cell resistance 5"
cell_resistance_6:
name: "JK1 cell resistance 6"
cell_resistance_7:
name: "JK1 cell resistance 7"
cell_resistance_8:
name: "JK1 cell resistance 8"
total_charging_cycle_capacity:
name: "JK1 total charging cycle capacity"
text_sensor:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms1
errors:
name: "JK1 Errors"
switch:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms1
charging:
name: "JK1 Charging"
discharging:
name: "JK1 Discharging"
balancer:
name: "JK1 Balancing"
- platform: ble_client
ble_client_id: jk_ble1
name: "JK1 enable bluetooth connection"
id: ble_client_switch0

View File

@@ -1,48 +0,0 @@
esphome:
name: "environment"
friendly_name: "environment"
esp32:
board: esp32dev
framework:
type: arduino
i2c:
sda: GPIO21
scl: GPIO22
scan: True
id: bus_a
sensor:
- platform: aht10
i2c_id: bus_a
address: 0x38
variant: AHT20
temperature:
name: "environment Temperature"
id: aht10_temperature
humidity:
name: "environment Humidity"
id: aht10_humidity
update_interval: 5s
web_server:
port: 80
logger:
level: DEBUG
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: on
captive_portal:

17
flake.lock generated
View File

@@ -74,6 +74,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-linux-firmware-20251011": {
"locked": {
"lastModified": 1760099975,
"narHash": "sha256-/fXH2TIVxVgmBbPouQNMsEPfUFB8Z9n6T9t40HMeC/k=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f9430900368d5a7346e30e6ecc7b26c9f7cc35cf",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f9430900368d5a7346e30e6ecc7b26c9f7cc35cf",
"type": "github"
}
},
"nixpkgs-master": { "nixpkgs-master": {
"locked": { "locked": {
"lastModified": 1763774007, "lastModified": 1763774007,
@@ -112,6 +128,7 @@
"home-manager": "home-manager", "home-manager": "home-manager",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-linux-firmware-20251011": "nixpkgs-linux-firmware-20251011",
"nixpkgs-master": "nixpkgs-master", "nixpkgs-master": "nixpkgs-master",
"nixpkgs-stable": "nixpkgs-stable", "nixpkgs-stable": "nixpkgs-stable",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",

View File

@@ -19,6 +19,8 @@
nixpkgs-master.url = "github:nixos/nixpkgs/master"; nixpkgs-master.url = "github:nixos/nixpkgs/master";
systems.url = "github:nix-systems/default-linux"; systems.url = "github:nix-systems/default-linux";
nixpkgs-linux-firmware-20251011.url = "github:NixOS/nixpkgs/f9430900368d5a7346e30e6ecc7b26c9f7cc35cf";
nixos-hardware.url = "github:nixos/nixos-hardware/master"; nixos-hardware.url = "github:nixos/nixos-hardware/master";
home-manager = { home-manager = {
@@ -82,6 +84,7 @@
jeeves = lib.nixosSystem { jeeves = lib.nixosSystem {
modules = [ modules = [
./systems/jeeves ./systems/jeeves
./systems/jeeves/linux-firmware-20251011.nix
]; ];
specialArgs = { inherit inputs outputs; }; specialArgs = { inherit inputs outputs; };
}; };

View File

@@ -3,14 +3,14 @@
# When applied, the stable nixpkgs set (declared in the flake inputs) will be accessible through 'pkgs.stable' # When applied, the stable nixpkgs set (declared in the flake inputs) will be accessible through 'pkgs.stable'
stable = final: _prev: { stable = final: _prev: {
stable = import inputs.nixpkgs-stable { stable = import inputs.nixpkgs-stable {
system = final.stdenv.hostPlatform.system; system = final.system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
}; };
# When applied, the master nixpkgs set (declared in the flake inputs) will be accessible through 'pkgs.master' # When applied, the master nixpkgs set (declared in the flake inputs) will be accessible through 'pkgs.master'
master = final: _prev: { master = final: _prev: {
master = import inputs.nixpkgs-master { master = import inputs.nixpkgs-master {
system = final.stdenv.hostPlatform.system; system = final.system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
}; };

View File

@@ -58,7 +58,7 @@ builtins-ignorelist = ["id"]
max-args = 9 max-args = 9
[tool.coverage.run] [tool.coverage.run]
source = ["python"] source = ["system_tools"]
[tool.coverage.report] [tool.coverage.report]
exclude_lines = [ exclude_lines = [

View File

@@ -1,161 +0,0 @@
#!/usr/bin/env python3
"""fix_eval_warnings."""
from __future__ import annotations
import logging
import os
from dataclasses import dataclass
from pathlib import Path
import requests
import typer
from python.common import configure_logger
logger = logging.getLogger(__name__)
@dataclass
class Config:
"""Configuration for the script.
Attributes:
github_token (str): GitHub token for API authentication.
model_name (str): The name of the LLM model to use. Defaults to "gpt-4o".
api_base (str): The base URL for the GitHub Models API.
Defaults to "https://models.inference.ai.azure.com".
"""
github_token: str
model_name: str = "gpt-4o"
api_base: str = "https://models.inference.ai.azure.com"
def get_log_content(run_id: str) -> None:
"""Fetch the logs for a specific workflow run.
Args:
run_id (str): The run ID.
"""
logger.info(f"Fetching logs for run ID: {run_id}")
# List artifacts to find logs (or use jobs API)
# For simplicity, we might need to use 'gh' cli in the workflow to download logs
# But let's try to read from a file if passed as argument, which is easier for the workflow
def parse_warnings(log_file_path: Path) -> list[str]:
"""Parse the log file for evaluation warnings.
Args:
log_file_path (Path): The path to the log file.
Returns:
list[str]: A list of warning messages.
"""
warnings = []
with log_file_path.open(encoding="utf-8", errors="ignore") as f:
warnings.extend(line.strip() for line in f if "evaluation warning:" in line)
return warnings
def generate_fix(warning_msg: str, config: Config) -> str | None:
"""Call GitHub Models to generate a fix for the warning.
Args:
warning_msg (str): The warning message.
config (Config): The configuration object.
Returns:
Optional[str]: The suggested fix or None.
"""
logger.info(f"Generating fix for: {warning_msg}")
prompt = f"""
I encountered the following Nix evaluation warning:
`{warning_msg}`
Please explain what this warning means and suggest how to fix it in the Nix code.
If possible, provide the exact code change in a diff format or a clear description of what to change.
"""
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {config.github_token}"}
payload = {
"messages": [
{"role": "system", "content": "You are an expert NixOS and Nix language developer."},
{"role": "user", "content": prompt},
],
"model": config.model_name,
"temperature": 0.1,
}
try:
response = requests.post(f"{config.api_base}/chat/completions", headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
return result["choices"][0]["message"]["content"] # type: ignore[no-any-return]
except Exception:
logger.exception("Error calling LLM")
return None
def main(
log_file: Path = typer.Argument(..., help="Path to the build log file"), # noqa: B008
model_name: str = typer.Option("gpt-4o", envvar="MODEL_NAME", help="LLM Model Name"),
) -> None:
"""Detect evaluation warnings in logs and suggest fixes using GitHub Models.
Args:
log_file (Path): Path to the build log file containing evaluation warnings.
model_name (str): The name of the LLM model to use for generating fixes.
Defaults to "gpt-4o", can be overridden by MODEL_NAME environment variable.
"""
configure_logger()
github_token = os.environ.get("GITHUB_TOKEN")
if not github_token:
logger.warning("GITHUB_TOKEN not set. LLM calls will fail.")
config = Config(github_token=github_token or "", model_name=model_name)
if not log_file.exists():
logger.error(f"Log file not found: {log_file}")
raise typer.Exit(code=1)
warnings = parse_warnings(log_file)
if not warnings:
logger.info("No evaluation warnings found.")
raise typer.Exit(code=0)
logger.info(f"Found {len(warnings)} warnings.")
# Process unique warnings to save tokens
unique_warnings = list(set(warnings))
fixes = []
for warning in unique_warnings:
if not config.github_token:
logger.warning("Skipping LLM call due to missing GITHUB_TOKEN")
continue
fix = generate_fix(warning, config)
if fix:
fixes.append(f"## Warning\n`{warning}`\n\n## Suggested Fix\n{fix}\n")
# Output fixes to a markdown file for the PR body
if fixes:
with Path("fix_suggestions.md").open("w") as f:
f.write("# Automated Fix Suggestions\n\n")
f.write("\n---\n".join(fixes))
logger.info("Fix suggestions written to fix_suggestions.md")
else:
logger.info("No fixes generated.")
app = typer.Typer()
app.command()(main)
if __name__ == "__main__":
app()

View File

@@ -1,7 +1,45 @@
template:
- sensor:
# Battery 0
- name: "JK0 charge power W"
unique_id: jk0_charge_power_w
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% set p = states('sensor.batteries_jk0_power')|float(0) %}
{{ max(0, p) }}
- name: "JK0 discharge power W"
unique_id: jk0_discharge_power_w
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% set p = states('sensor.batteries_jk0_power')|float(0) %}
{{ max(0, -p) }}
# Battery 1
- name: "JK1 charge power W"
unique_id: jk1_charge_power_w
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% set p = states('sensor.batteries_jk1_power')|float(0) %}
{{ max(0, p) }}
- name: "JK1 discharge power W"
unique_id: jk1_discharge_power_w
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% set p = states('sensor.batteries_jk1_power')|float(0) %}
{{ max(0, -p) }}
sensor: sensor:
# Battery 0 # Battery 0
- platform: integration - platform: integration
source: sensor.batteries_jk0_charging_power source: sensor.jk0_charge_power_w
name: "JK0 energy in" name: "JK0 energy in"
unique_id: jk0_energy_in_kwh unique_id: jk0_energy_in_kwh
unit_prefix: k unit_prefix: k
@@ -10,7 +48,7 @@ sensor:
max_sub_interval: max_sub_interval:
minutes: 5 minutes: 5
- platform: integration - platform: integration
source: sensor.batteries_jk0_charging_power source: sensor.jk0_discharge_power_w
name: "JK0 energy out" name: "JK0 energy out"
unique_id: jk0_energy_out_kwh unique_id: jk0_energy_out_kwh
unit_prefix: k unit_prefix: k
@@ -21,7 +59,7 @@ sensor:
# Battery 1 # Battery 1
- platform: integration - platform: integration
source: sensor.battery1_jk1_charging_power source: sensor.jk1_charge_power_w
name: "JK1 energy in" name: "JK1 energy in"
unique_id: jk1_energy_in_kwh unique_id: jk1_energy_in_kwh
unit_prefix: k unit_prefix: k
@@ -30,7 +68,7 @@ sensor:
max_sub_interval: max_sub_interval:
minutes: 5 minutes: 5
- platform: integration - platform: integration
source: sensor.battery1_jk1_discharge_power source: sensor.jk1_discharge_power_w
name: "JK1 energy out" name: "JK1 energy out"
unique_id: jk1_energy_out_kwh unique_id: jk1_energy_out_kwh
unit_prefix: k unit_prefix: k

View File

@@ -0,0 +1,11 @@
{ inputs, ... }:
let
linuxFirmwareOverlay = final: prev: {
linux-firmware =
inputs.nixpkgs-linux-firmware-20251011.legacyPackages.${final.system}.linux-firmware;
};
in
{
nixpkgs.overlays = [ linuxFirmwareOverlay ];
}

View File

@@ -1,6 +0,0 @@
"""Fixtures for tests."""
from __future__ import annotations
PASSWORD = "password" # noqa: S105
TOKEN = "token" # noqa: S105

View File

@@ -1,75 +0,0 @@
"""test_fix_eval_warnings."""
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
from typer.testing import CliRunner
from python.tools.fix_eval_warnings import Config, app, generate_fix, parse_warnings
from tests.conftest import TOKEN
if TYPE_CHECKING:
from pyfakefs.fake_filesystem import FakeFilesystem
from pytest_mock import MockerFixture
runner = CliRunner()
def test_parse_warnings(fs: FakeFilesystem) -> None:
"""test_parse_warnings."""
log_file = Path("/build.log")
fs.create_file(
log_file,
contents="Some output\nevaluation warning: 'system' is deprecated\nMore output",
encoding="utf-8",
)
warnings = parse_warnings(log_file)
assert len(warnings) == 1
assert warnings[0] == "evaluation warning: 'system' is deprecated"
def test_generate_fix(mocker: MockerFixture) -> None:
"""test_generate_fix."""
mock_post = mocker.patch("python.tools.fix_eval_warnings.requests.post")
mock_response = mocker.MagicMock()
mock_response.json.return_value = {
"choices": [{"message": {"content": "Use stdenv.hostPlatform.system"}}]
}
mock_post.return_value = mock_response
config = Config(github_token=TOKEN)
fix = generate_fix("evaluation warning: 'system' is deprecated", config)
assert fix == "Use stdenv.hostPlatform.system"
mock_post.assert_called_once()
def test_main(mocker: MockerFixture, fs: FakeFilesystem) -> None:
"""test_main."""
log_file = Path("/build.log")
fs.create_file(
log_file,
contents="Some output\nevaluation warning: 'system' is deprecated\nMore output",
encoding="utf-8",
)
mock_generate_fix = mocker.patch("python.tools.fix_eval_warnings.generate_fix")
mock_generate_fix.return_value = "Fixed it"
mock_logger = mocker.patch("python.tools.fix_eval_warnings.logger")
# We need to mock GITHUB_TOKEN env var or the script will warn/fail
mocker.patch.dict("os.environ", {"GITHUB_TOKEN": TOKEN})
result = runner.invoke(app, [str(log_file)])
assert result.exit_code == 0
# Verify logger calls instead of stdout, as CliRunner might not capture logging output correctly
# when logging is configured to write to sys.stdout directly.
assert any("Found 1 warnings" in str(call) for call in mock_logger.info.call_args_list)
assert any(
"Fix suggestions written to fix_suggestions.md" in str(call)
for call in mock_logger.info.call_args_list
)
assert Path("fix_suggestions.md").exists()

View File

@@ -1,11 +1,9 @@
{ {
programs.git = { programs.git = {
enable = true; enable = true;
userEmail = "dov.kruger@gmail.com";
userName = "Dov Kruger";
settings = { settings = {
user = {
email = "dov.kruger@gmail.com";
name = "Dov Kruger";
};
pull.rebase = true; pull.rebase = true;
color.ui = true; color.ui = true;
}; };

View File

@@ -1,11 +1,9 @@
{ {
programs.git = { programs.git = {
enable = true; enable = true;
userEmail = "DumbPuppy208@gmail.com";
userName = "Elise Corvidae";
settings = { settings = {
user = {
email = "DumbPuppy208@gmail.com";
name = "Elise Corvidae";
};
pull.rebase = true; pull.rebase = true;
color.ui = true; color.ui = true;
}; };

View File

@@ -1,11 +1,9 @@
{ {
programs.git = { programs.git = {
enable = true; enable = true;
userEmail = "matthew.michal11@gmail.com";
userName = "Matthew Michal";
settings = { settings = {
user = {
email = "matthew.michal11@gmail.com";
name = "Matthew Michal";
};
pull.rebase = true; pull.rebase = true;
color.ui = true; color.ui = true;
}; };

View File

@@ -1,11 +1,9 @@
{ {
programs.git = { programs.git = {
enable = true; enable = true;
userEmail = "mousikos112@gmail.com";
userName = "megan";
settings = { settings = {
user = {
email = "mousikos112@gmail.com";
name = "megan";
};
pull.rebase = true; pull.rebase = true;
color.ui = true; color.ui = true;
}; };

View File

@@ -1,11 +1,9 @@
{ {
programs.git = { programs.git = {
enable = true; enable = true;
userEmail = "Richie@tmmworkshop.com";
userName = "Richie Cahill";
settings = { settings = {
user = {
email = "Richie@tmmworkshop.com";
name = "Richie Cahill";
};
pull.rebase = true; pull.rebase = true;
color.ui = true; color.ui = true;
}; };

View File

@@ -9,24 +9,23 @@
home.packages = with pkgs; [ home.packages = with pkgs; [
candy-icons candy-icons
chromium chromium
discord-canary
gimp gimp
gparted
jetbrains.datagrip
mediainfo mediainfo
nemo
nemo-fileroller
obs-studio obs-studio
obsidian obsidian
prismlauncher prismlauncher
proxychains
prusa-slicer prusa-slicer
signal-desktop
sweet-nova sweet-nova
util-linux util-linux
vlc vlc
# comms
discord-canary
signal-desktop
zoom-us zoom-us
# dev tools
jetbrains.datagrip
proxychains
master.antigravity-fhs
gparted
# games # games
dwarf-fortress dwarf-fortress
tower-pixel-dungeon tower-pixel-dungeon