Compare commits

..

40 Commits

Author SHA1 Message Date
59cfc0d02f improved unit tests 2025-12-06 21:29:51 -05:00
3914a1a7ab used TOKEN from conftest and updated coverage.run source 2025-12-06 21:17:44 -05:00
b5ac770003 reworked AGENTS.md 2025-12-06 20:58:29 -05:00
12e398514b added conftest.py 2025-12-06 20:43:54 -05:00
69f9ef8187 updated AGENTS.md 2025-12-06 20:41:33 -05:00
1b171fcd3e added format_code.md to .agent 2025-12-06 18:53:19 -05:00
16d938dc59 Merge branch 'main' into feature/adding-fix_eval_warnings.yml 2025-12-06 17:54:55 -05:00
7ffb7b4a37 adding AGENTS.md 2025-12-06 17:54:03 -05:00
c7fe44755f Merge branch 'main' into feature/adding-fix_eval_warnings.yml 2025-12-06 17:32:38 -05:00
bb9200860e adding fix_eval_warnings.yml 2025-12-06 17:31:08 -05:00
eb04f4a56d 'system' has been renamed to/replaced by 'stdenv.hostPlatform.system' 2025-12-06 12:45:55 -05:00
b91f7c34e1 'system' has been renamed to/replaced by 'stdenv.hostPlatform.system' 2025-12-06 12:37:22 -05:00
5b8e543226 added environment sensor 2025-12-06 12:33:10 -05:00
da48f62195 splint HA battery monitoring 2025-12-06 12:33:10 -05:00
60f2ab1039 testing google antigravity 2025-12-06 12:24:54 -05:00
c1de454005 ran treefmt 2025-11-28 09:16:46 -05:00
391e37b746 fixing git user settings 2025-11-28 09:16:46 -05:00
github-actions[bot]
27565173d4 flake.lock: Update
Flake lock file updates:

• Updated input 'firefox-addons':
    'gitlab:rycee/nur-expressions/0d05242?dir=pkgs/firefox-addons' (2025-11-20)
  → 'gitlab:rycee/nur-expressions/cefce78?dir=pkgs/firefox-addons' (2025-11-21)
• Updated input 'home-manager':
    'github:nix-community/home-manager/ea164b7' (2025-11-17)
  → 'github:nix-community/home-manager/d10a9b1' (2025-11-21)
• Updated input 'nixpkgs-master':
    'github:nixos/nixpkgs/973aa8b' (2025-11-21)
  → 'github:nixos/nixpkgs/8a7cf7e' (2025-11-22)
2025-11-22 09:49:19 -05:00
0c0ed92cb4 fixing user git settings 2025-11-20 21:36:54 -05:00
github-actions[bot]
cc9996d6fa flake.lock: Update
Flake lock file updates:

• Updated input 'firefox-addons':
    'gitlab:rycee/nur-expressions/d84c9ea?dir=pkgs/firefox-addons' (2025-11-14)
  → 'gitlab:rycee/nur-expressions/0d05242?dir=pkgs/firefox-addons' (2025-11-20)
• Updated input 'home-manager':
    'github:nix-community/home-manager/827f2a2' (2025-11-12)
  → 'github:nix-community/home-manager/ea164b7' (2025-11-17)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/c5ae371' (2025-11-12)
  → 'github:nixos/nixpkgs/89c2b23' (2025-11-17)
• Updated input 'nixpkgs-master':
    'github:nixos/nixpkgs/20f91b6' (2025-11-15)
  → 'github:nixos/nixpkgs/973aa8b' (2025-11-21)
• Updated input 'sops-nix':
    'github:Mic92/sops-nix/a2bcd1c' (2025-11-13)
  → 'github:Mic92/sops-nix/877bb49' (2025-11-20)
2025-11-20 21:30:32 -05:00
102f36eb1b adding post quantum ssh KexAlgorithms 2025-11-16 08:22:41 -05:00
9ec988729b testing zfs_unstable and linuxPackages_6_17 2025-11-15 13:47:13 -05:00
4e3c25afb4 added draw io setting 2025-11-15 13:47:13 -05:00
0d482aca4b HA update 2025-11-15 13:47:13 -05:00
github-actions[bot]
c624781d84 flake.lock: Update
Flake lock file updates:

• Updated input 'firefox-addons':
    'gitlab:rycee/nur-expressions/5cca27f1bb30a26140d0cf60ab34daa45b4fa11f?dir=pkgs/firefox-addons&narHash=sha256-h%2BliPhhMw1yYvkDGLHzQJQShQs%2ByLjNgjfAyZX%2BsRrM%3D' (2025-10-17)
  → 'gitlab:rycee/nur-expressions/d84c9ea299c1e4629f0d0716799f5c57975021ce?dir=pkgs/firefox-addons&narHash=sha256-FjnOyxTNNt85ZNjtLqRnG23LKQyvilGzyrO0bLffMm8%3D' (2025-11-14)
• Updated input 'home-manager':
    'github:nix-community/home-manager/722792af097dff5790f1a66d271a47759f477755?narHash=sha256-mlDqR1Ntgs9uYYEAUR1IhamKBO0lxoNS4zGLzEZaY0A%3D' (2025-10-17)
  → 'github:nix-community/home-manager/827f2a23373a774a8805f84ca5344654c31f354b?narHash=sha256-RYHN8O/Aja59XDji6WSJZPkJpYVUfpSkyH%2BPEupBJqM%3D' (2025-11-12)
• Updated input 'nixos-hardware':
    'github:nixos/nixos-hardware/9ed85f8afebf2b7478f25db0a98d0e782c0ed903?narHash=sha256-2GoxVaKWTHBxRoeUYSjv0AfSOx4qw5CWSFz2b%2BVolKU%3D' (2025-10-10)
  → 'github:nixos/nixos-hardware/899dc449bc6428b9ee6b3b8f771ca2b0ef945ab9?narHash=sha256-BWWnUUT01lPwCWUvS0p6Px5UOBFeXJ8jR%2BZdLX8IbrU%3D' (2025-11-11)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/544961dfcce86422ba200ed9a0b00dd4b1486ec5?narHash=sha256-EVAqOteLBFmd7pKkb0%2BFIUyzTF61VKi7YmvP1tw4nEw%3D' (2025-10-15)
  → 'github:nixos/nixpkgs/c5ae371f1a6a7fd27823bc500d9390b38c05fa55?narHash=sha256-4PqRErxfe%2B2toFJFgcRKZ0UI9NSIOJa%2B7RXVtBhy4KE%3D' (2025-11-12)
• Updated input 'nixpkgs-master':
    'github:nixos/nixpkgs/d85429339c0bcf0428084fe1306c970aed364417?narHash=sha256-1296zQfPiLZNrLKzX1t%2BkunadeI/mH82hKze3voduEI%3D' (2025-10-18)
  → 'github:nixos/nixpkgs/20f91b6ba5eff456057e359946c3e832173b18df?narHash=sha256-jVuaLD1Yf2aHILt2EedLFhqJnQXAS8kIo3P4LbtYDyg%3D' (2025-11-15)
• Updated input 'sops-nix':
    'github:Mic92/sops-nix/ab8d56e85b8be14cff9d93735951e30c3e86a437?narHash=sha256-8mN3kqyqa2PKY0wwZ2UmMEYMcxvNTwLaOrrDsw6Qi4E%3D' (2025-10-13)
  → 'github:Mic92/sops-nix/a2bcd1c25c1d29e22756ccae094032ab4ada2268?narHash=sha256-A91a%2BK0Q9wfdPLwL06e/kbHeAWSzPYy2EGdTDsyfb%2Bs%3D' (2025-11-13)
2025-11-15 13:47:13 -05:00
f4996b71e4 updating to inputs.self 2025-11-11 00:11:30 -05:00
58a29214d3 testing "${self}/ in imports 2025-11-11 00:11:30 -05:00
c4171b56b5 fixed systemd.nix 2025-11-10 23:21:54 -05:00
d6d48516ea updated PYTHONPATH to "${self}/" 2025-11-10 23:21:54 -05:00
ae882ba578 flake lock update 2025-11-10 23:21:54 -05:00
100b8145e8 fixed PYTHONPATH 2025-11-10 23:21:54 -05:00
e99cd8e54a removed system_tools 2025-11-10 23:21:54 -05:00
de9348432c deleted temp_flake.lock 2025-11-10 23:21:54 -05:00
b1fa596f37 fix victron_modbuss gps setting 2025-11-10 12:02:14 -05:00
908bccb8dc fixed typo 2025-11-08 08:21:27 -05:00
b8cc9c5772 testing dev shell for python pytest 2025-11-08 08:21:27 -05:00
d62076a900 added psycopg to my_python 2025-11-08 08:21:27 -05:00
0c9bd40659 fixed mypy and ruff errors 2025-11-08 08:21:27 -05:00
f713b8d4fa added safe_insert 2025-11-08 08:21:27 -05:00
ddba7d1068 disabling use_x_forwarded_for for brain HA 2025-11-08 07:11:30 -05:00
48 changed files with 913 additions and 662 deletions

View File

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

48
.github/workflows/fix_eval_warnings.yml vendored Normal file
View File

@@ -0,0 +1,48 @@
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"

View File

@@ -16,4 +16,4 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Run tests
run: pytest tests
run: nix develop .#devShells.x86_64-linux.default -c pytest tests

1
.gitignore vendored
View File

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

View File

@@ -252,6 +252,7 @@
"schemeless",
"scrollback",
"SECUREFOX",
"sessionmaker",
"sessionstore",
"shellcheck",
"signon",
@@ -263,6 +264,7 @@
"socialtracking",
"sonarr",
"sponsorblock",
"sqlalchemy",
"sqltools",
"ssdp",
"SSHOPTS",
@@ -325,5 +327,10 @@
"zoxide",
"zram",
"zstd"
]
],
"python-envs.defaultEnvManager": "ms-python.python:system",
"python-envs.pythonProjects": [],
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}

12
AGENTS.md Normal file
View File

@@ -0,0 +1,12 @@
## 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

@@ -44,7 +44,10 @@
# firmware update
fwupd.enable = true;
snapshot_manager.enable = lib.mkDefault true;
snapshot_manager = {
enable = lib.mkDefault true;
PYTHONPATH = "${inputs.self}/";
};
zfs = {
trim.enable = lib.mkDefault true;

View File

@@ -1,5 +1,4 @@
{
inputs,
pkgs,
lib,
config,
@@ -17,6 +16,12 @@ in
default = ./snapshot_config.toml;
description = "Path to the snapshot_manager TOML config.";
};
PYTHONPATH = lib.mkOption {
type = lib.types.str;
description = ''
the PYTHONPATH to use for the snapshot_manager service.
'';
};
EnvironmentFile = lib.mkOption {
type = lib.types.nullOr (lib.types.coercedTo lib.types.path toString lib.types.str);
default = null;
@@ -35,11 +40,12 @@ in
requires = [ "zfs-import.target" ];
after = [ "zfs-import.target" ];
path = [ pkgs.zfs ];
environment = {
PYTHONPATH = cfg.PYTHONPATH;
};
serviceConfig = {
Type = "oneshot";
ExecStart = "${
inputs.system_tools.packages.${pkgs.system}.default
}/bin/snapshot_manager ${lib.escapeShellArg cfg.path}";
ExecStart = "${pkgs.my_python}/bin/python -m python.tools.snapshot_manager ${lib.escapeShellArg cfg.path}";
}
// lib.optionalAttrs (cfg.EnvironmentFile != null) {
EnvironmentFile = cfg.EnvironmentFile;

View File

@@ -37,6 +37,8 @@
TcpKeepAlive = "no";
X11Forwarding = lib.mkDefault false;
KexAlgorithms = [
"sntrup761x25519-sha512@openssh.com"
"mlkem768x25519-sha256"
"curve25519-sha256@libssh.org"
"diffie-hellman-group-exchange-sha256"
];

View File

@@ -1,8 +1,8 @@
{ pkgs, ... }:
{
boot = {
kernelPackages = pkgs.linuxPackages_6_16;
zfs.package = pkgs.zfs_2_3;
kernelPackages = pkgs.linuxPackages_6_17;
zfs.package = pkgs.zfs_unstable;
};
hardware.bluetooth = {

View File

@@ -1,129 +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
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"

132
esphome/battery0.yml Normal file
View File

@@ -0,0 +1,132 @@
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

132
esphome/battery1.yml Normal file
View File

@@ -0,0 +1,132 @@
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

48
esphome/environment.yml Normal file
View File

@@ -0,0 +1,48 @@
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:

135
flake.lock generated
View File

@@ -8,11 +8,11 @@
},
"locked": {
"dir": "pkgs/firefox-addons",
"lastModified": 1760673822,
"narHash": "sha256-h+liPhhMw1yYvkDGLHzQJQShQs+yLjNgjfAyZX+sRrM=",
"lastModified": 1763697825,
"narHash": "sha256-AgCCcVPOi1tuzuW5/StlwqBjRWSX62oL97qWuxrq5UA=",
"owner": "rycee",
"repo": "nur-expressions",
"rev": "5cca27f1bb30a26140d0cf60ab34daa45b4fa11f",
"rev": "cefce78793603231be226fa77e7ad58e0e4899b8",
"type": "gitlab"
},
"original": {
@@ -29,11 +29,11 @@
]
},
"locked": {
"lastModified": 1760662441,
"narHash": "sha256-mlDqR1Ntgs9uYYEAUR1IhamKBO0lxoNS4zGLzEZaY0A=",
"lastModified": 1763748372,
"narHash": "sha256-AUc78Qv3sWir0hvbmfXoZ7Jzq9VVL97l+sP9Jgms+JU=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "722792af097dff5790f1a66d271a47759f477755",
"rev": "d10a9b16b2a3ee28433f3d1c603f4e9f1fecb8e1",
"type": "github"
},
"original": {
@@ -44,11 +44,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1760106635,
"narHash": "sha256-2GoxVaKWTHBxRoeUYSjv0AfSOx4qw5CWSFz2b+VolKU=",
"lastModified": 1762847253,
"narHash": "sha256-BWWnUUT01lPwCWUvS0p6Px5UOBFeXJ8jR+ZdLX8IbrU=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "9ed85f8afebf2b7478f25db0a98d0e782c0ed903",
"rev": "899dc449bc6428b9ee6b3b8f771ca2b0ef945ab9",
"type": "github"
},
"original": {
@@ -60,11 +60,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1760524057,
"narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
"lastModified": 1763421233,
"narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
"rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648",
"type": "github"
},
"original": {
@@ -76,11 +76,11 @@
},
"nixpkgs-master": {
"locked": {
"lastModified": 1760751316,
"narHash": "sha256-1296zQfPiLZNrLKzX1t+kunadeI/mH82hKze3voduEI=",
"lastModified": 1763774007,
"narHash": "sha256-PPeHfKA11P09kBkBD5pS3tIAFjnG5muHQnODQGTY87g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d85429339c0bcf0428084fe1306c970aed364417",
"rev": "8a7cf7e9e18384533d9ecd0bfbcf475ac1dc497e",
"type": "github"
},
"original": {
@@ -106,56 +106,6 @@
"type": "github"
}
},
"pyproject-build-systems": {
"inputs": {
"nixpkgs": [
"system_tools",
"nixpkgs"
],
"pyproject-nix": [
"system_tools",
"pyproject-nix"
],
"uv2nix": [
"system_tools",
"uv2nix"
]
},
"locked": {
"lastModified": 1744599653,
"narHash": "sha256-nysSwVVjG4hKoOjhjvE6U5lIKA8sEr1d1QzEfZsannU=",
"owner": "pyproject-nix",
"repo": "build-system-pkgs",
"rev": "7dba6dbc73120e15b558754c26024f6c93015dd7",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "build-system-pkgs",
"type": "github"
}
},
"pyproject-nix": {
"inputs": {
"nixpkgs": [
"system_tools",
"nixpkgs"
]
},
"locked": {
"lastModified": 1746540146,
"narHash": "sha256-QxdHGNpbicIrw5t6U3x+ZxeY/7IEJ6lYbvsjXmcxFIM=",
"owner": "pyproject-nix",
"repo": "pyproject.nix",
"rev": "e09c10c24ebb955125fda449939bfba664c467fd",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "pyproject.nix",
"type": "github"
}
},
"root": {
"inputs": {
"firefox-addons": "firefox-addons",
@@ -165,7 +115,6 @@
"nixpkgs-master": "nixpkgs-master",
"nixpkgs-stable": "nixpkgs-stable",
"sops-nix": "sops-nix",
"system_tools": "system_tools",
"systems": "systems"
}
},
@@ -176,11 +125,11 @@
]
},
"locked": {
"lastModified": 1760393368,
"narHash": "sha256-8mN3kqyqa2PKY0wwZ2UmMEYMcxvNTwLaOrrDsw6Qi4E=",
"lastModified": 1763607916,
"narHash": "sha256-VefBA1JWRXM929mBAFohFUtQJLUnEwZ2vmYUNkFnSjE=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "ab8d56e85b8be14cff9d93735951e30c3e86a437",
"rev": "877bb495a6f8faf0d89fc10bd142c4b7ed2bcc0b",
"type": "github"
},
"original": {
@@ -189,29 +138,6 @@
"type": "github"
}
},
"system_tools": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"pyproject-build-systems": "pyproject-build-systems",
"pyproject-nix": "pyproject-nix",
"uv2nix": "uv2nix"
},
"locked": {
"lastModified": 1760751967,
"narHash": "sha256-u/uciy9kpM/CBZKl05iAZRaOTwUHiuI0L/qbkk2mLUg=",
"owner": "RichieCahill",
"repo": "system_tools",
"rev": "a125c3e5c01cecbc3f2a842ffb1abb1210c35706",
"type": "github"
},
"original": {
"owner": "RichieCahill",
"repo": "system_tools",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1689347949,
@@ -226,31 +152,6 @@
"repo": "default-linux",
"type": "github"
}
},
"uv2nix": {
"inputs": {
"nixpkgs": [
"system_tools",
"nixpkgs"
],
"pyproject-nix": [
"system_tools",
"pyproject-nix"
]
},
"locked": {
"lastModified": 1747441483,
"narHash": "sha256-W8BFXk5R0TuJcjIhcGoMpSOaIufGXpizK0pm+uTqynA=",
"owner": "pyproject-nix",
"repo": "uv2nix",
"rev": "582024dc64663e9f88d467c2f7f7b20d278349de",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "uv2nix",
"type": "github"
}
}
},
"root": "root",

View File

@@ -31,11 +31,6 @@
inputs.nixpkgs.follows = "nixpkgs";
};
system_tools = {
url = "github:RichieCahill/system_tools";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
@@ -59,6 +54,7 @@
system:
import nixpkgs {
inherit system;
overlays = builtins.attrValues outputs.overlays;
config.allowUnfree = true;
}
);

View File

@@ -3,14 +3,14 @@
# When applied, the stable nixpkgs set (declared in the flake inputs) will be accessible through 'pkgs.stable'
stable = final: _prev: {
stable = import inputs.nixpkgs-stable {
system = final.system;
system = final.stdenv.hostPlatform.system;
config.allowUnfree = true;
};
};
# When applied, the master nixpkgs set (declared in the flake inputs) will be accessible through 'pkgs.master'
master = final: _prev: {
master = import inputs.nixpkgs-master {
system = final.system;
system = final.stdenv.hostPlatform.system;
config.allowUnfree = true;
};
};
@@ -22,6 +22,7 @@
apscheduler
mypy
polars
psycopg
pyfakefs
pytest
pytest-cov
@@ -29,6 +30,7 @@
pytest-xdist
requests
ruff
sqlalchemy
typer
types-requests
]

View File

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

59
python/database.py Normal file
View File

@@ -0,0 +1,59 @@
"""database."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from sqlalchemy import inspect
from sqlalchemy.exc import NoInspectionAvailable
if TYPE_CHECKING:
from collections.abc import Sequence
from sqlalchemy.orm import Session
logger = logging.getLogger(__name__)
def safe_insert(orm_objects: Sequence[object], session: Session) -> list[tuple[Exception, object]]:
"""Safer insert at allows for partial rollbacks.
Args:
orm_objects (Sequence[object]): Tables to insert.
session (Session): Database session.
"""
if unmapped := [orm_object for orm_object in orm_objects if not _is_mapped_instance(orm_object)]:
error = f"safe_insert expects ORM-mapped instances {unmapped}"
raise TypeError(error)
return _safe_insert(orm_objects, session)
def _safe_insert(objects: Sequence[object], session: Session) -> list[tuple[Exception, object]]:
exceptions: list[tuple[Exception, object]] = []
try:
session.add_all(objects)
session.commit()
except Exception as error:
session.rollback()
objects_len = len(objects)
if objects_len == 1:
logger.exception(objects)
return [(error, objects[0])]
middle = objects_len // 2
exceptions.extend(_safe_insert(objects=objects[:middle], session=session))
exceptions.extend(_safe_insert(objects=objects[middle:], session=session))
return exceptions
def _is_mapped_instance(obj: object) -> bool:
"""Return True if `obj` is a SQLAlchemy ORM-mapped instance."""
try:
inspect(obj) # raises NoInspectionAvailable if not mapped
except NoInspectionAvailable:
return False
else:
return True

View File

@@ -85,7 +85,7 @@ def get_material_resistivity(
) -> float:
"""Get the resistivity of a material."""
if not temperature:
Temperature(20.0)
temperature = Temperature(20.0)
material_info = {
MaterialType.COPPER: (1.724e-8, 0.00393),
MaterialType.ALUMINUM: (2.908e-8, 0.00403),
@@ -180,7 +180,7 @@ def max_wire_length(
float: Maximum wire length in meters that maintains the specified voltage drop
"""
if not temperature:
Temperature(100.0, unit=TemperatureUnit.FAHRENHEIT)
temperature = Temperature(100.0, unit=TemperatureUnit.FAHRENHEIT)
resistivity = get_material_resistivity(material, temperature)
resistance_per_meter = resistivity / calculate_wire_area_m2(gauge)

161
python/tools/fix_eval_warnings.py Executable file
View File

@@ -0,0 +1,161 @@
#!/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

@@ -9,6 +9,7 @@
nix
home-manager
git
my_python
ssh-to-age
gnupg

View File

@@ -1,18 +1,19 @@
{ inputs, ... }:
{
imports = [
../../users/richie
../../users/gaming
../../common/global
../../common/optional/desktop.nix
../../common/optional/docker.nix
../../common/optional/scanner.nix
../../common/optional/steam.nix
../../common/optional/syncthing_base.nix
../../common/optional/systemd-boot.nix
../../common/optional/update.nix
../../common/optional/yubikey.nix
../../common/optional/zerotier.nix
../../common/optional/nvidia.nix
"${inputs.self}/users/richie"
"${inputs.self}/users/gaming"
"${inputs.self}/common/global"
"${inputs.self}/common/optional/desktop.nix"
"${inputs.self}/common/optional/docker.nix"
"${inputs.self}/common/optional/scanner.nix"
"${inputs.self}/common/optional/steam.nix"
"${inputs.self}/common/optional/syncthing_base.nix"
"${inputs.self}/common/optional/systemd-boot.nix"
"${inputs.self}/common/optional/update.nix"
"${inputs.self}/common/optional/yubikey.nix"
"${inputs.self}/common/optional/zerotier.nix"
"${inputs.self}/common/optional/nvidia.nix"
./hardware.nix
./syncthing.nix
./llms.nix

View File

@@ -1,14 +1,14 @@
{ inputs, ... }:
{
imports = [
../../users/richie
../../common/global
../../common/optional/docker.nix
../../common/optional/ssh_decrypt.nix
../../common/optional/syncthing_base.nix
../../common/optional/systemd-boot.nix
../../common/optional/update.nix
../../common/optional/zerotier.nix
"${inputs.self}/users/richie"
"${inputs.self}/common/global"
"${inputs.self}/common/optional/docker.nix"
"${inputs.self}/common/optional/ssh_decrypt.nix"
"${inputs.self}/common/optional/syncthing_base.nix"
"${inputs.self}/common/optional/systemd-boot.nix"
"${inputs.self}/common/optional/update.nix"
"${inputs.self}/common/optional/zerotier.nix"
./docker
./hardware.nix
./programs.nix

View File

@@ -19,7 +19,6 @@
"192.168.95.35"
"127.0.0.1"
];
use_x_forwarded_for = true;
};
homeassistant = {
time_zone = "America/New_York";
@@ -60,16 +59,17 @@
};
extraPackages =
python3Packages: with python3Packages; [
pymodbus # for modbus
aioesphomeapi # for esphome
bleak-esphome # for esphome
esphome-dashboard-api # for esphome
forecast-solar # for solar forecast
gtts # not sure what wants this
jellyfin-apiclient-python # for jellyfin
paho-mqtt # for mqtt
psycopg2 # for postgresql
forecast-solar # for solar forecast
aioesphomeapi # for esphome
esphome-dashboard-api # for esphome
py-improv-ble-client # for esphome
bleak-esphome # for esphome
pymodbus # for modbus
pyopenweathermap # for weather
];
extraComponents = [ "isal" ];
};

View File

@@ -1,45 +1,7 @@
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:
# Battery 0
- platform: integration
source: sensor.jk0_charge_power_w
source: sensor.batteries_jk0_charging_power
name: "JK0 energy in"
unique_id: jk0_energy_in_kwh
unit_prefix: k
@@ -48,7 +10,7 @@ sensor:
max_sub_interval:
minutes: 5
- platform: integration
source: sensor.jk0_discharge_power_w
source: sensor.batteries_jk0_charging_power
name: "JK0 energy out"
unique_id: jk0_energy_out_kwh
unit_prefix: k
@@ -59,7 +21,7 @@ sensor:
# Battery 1
- platform: integration
source: sensor.jk1_charge_power_w
source: sensor.battery1_jk1_charging_power
name: "JK1 energy in"
unique_id: jk1_energy_in_kwh
unit_prefix: k
@@ -68,7 +30,7 @@ sensor:
max_sub_interval:
minutes: 5
- platform: integration
source: sensor.jk1_discharge_power_w
source: sensor.battery1_jk1_discharge_power
name: "JK1 energy out"
unique_id: jk1_energy_out_kwh
unit_prefix: k

View File

@@ -77,7 +77,7 @@ modbus:
# GPS
- name: GPS Latitude
slave: 100
slave: 1
address: 2800
input_type: holding
data_type: int32
@@ -87,7 +87,7 @@ modbus:
unique_id: gps_latitude
- name: GPS Longitude
slave: 100
slave: 1
address: 2802
input_type: holding
data_type: int32
@@ -97,7 +97,7 @@ modbus:
unique_id: gps_longitude
- name: GPS Course
slave: 100
slave: 1
address: 2804
input_type: holding
data_type: uint16
@@ -108,7 +108,7 @@ modbus:
unique_id: gps_course
- name: GPS Speed
slave: 100
slave: 1
address: 2805
input_type: holding
data_type: uint16
@@ -119,7 +119,7 @@ modbus:
unique_id: gps_speed
- name: GPS Fix
slave: 100
slave: 1
address: 2806
input_type: holding
data_type: uint16
@@ -128,7 +128,7 @@ modbus:
unique_id: gps_fix
- name: GPS Satellites
slave: 100
slave: 1
address: 2807
input_type: holding
data_type: uint16
@@ -137,7 +137,7 @@ modbus:
unique_id: gps_satellites
- name: GPS Altitude
slave: 100
slave: 1
address: 2808
input_type: holding
data_type: int32

View File

@@ -1,17 +1,18 @@
{ inputs, ... }:
let
vars = import ./vars.nix;
in
{
imports = [
../../users/richie
../../users/math
../../users/dov
../../common/global
../../common/optional/docker.nix
../../common/optional/ssh_decrypt.nix
../../common/optional/syncthing_base.nix
../../common/optional/update.nix
../../common/optional/zerotier.nix
"${inputs.self}/users/richie"
"${inputs.self}/users/math"
"${inputs.self}/users/dov"
"${inputs.self}/common/global"
"${inputs.self}/common/optional/docker.nix"
"${inputs.self}/common/optional/ssh_decrypt.nix"
"${inputs.self}/common/optional/syncthing_base.nix"
"${inputs.self}/common/optional/update.nix"
"${inputs.self}/common/optional/zerotier.nix"
./docker
./services
./hardware.nix

View File

@@ -1,7 +1,6 @@
{
config,
pkgs,
lib,
...
}:

View File

@@ -68,7 +68,7 @@ in
jellyfin-apiclient-python
psycopg2
pymetno
pyownet
aio-ownet
rokuecp
uiprotect
wakeonlan

View File

@@ -1,6 +1,6 @@
{
inputs,
pkgs,
inputs,
...
}:
let
@@ -22,10 +22,13 @@ in
wantedBy = [ "multi-user.target" ];
description = "validates startup";
path = [ pkgs.zfs ];
environment = {
PYTHONPATH = "${inputs.self}/";
};
serviceConfig = {
EnvironmentFile = "${vars.secrets}/services/server-validation";
Type = "oneshot";
ExecStart = "${inputs.system_tools.packages.x86_64-linux.default}/bin/validate_system '${./validate_system.toml}'";
ExecStart = "${pkgs.my_python}/bin/python -m python.system_tests.validate_system '${./validate_system.toml}'";
};
};
};

View File

@@ -1,14 +1,14 @@
{ inputs, ... }:
{
imports = [
../../users/elise
../../users/richie
../../common/global
../../common/optional/desktop.nix
../../common/optional/steam.nix
../../common/optional/systemd-boot.nix
../../common/optional/update.nix
../../common/optional/zerotier.nix
"${inputs.self}/users/elise"
"${inputs.self}/users/richie"
"${inputs.self}/common/global"
"${inputs.self}/common/optional/desktop.nix"
"${inputs.self}/common/optional/steam.nix"
"${inputs.self}/common/optional/systemd-boot.nix"
"${inputs.self}/common/optional/update.nix"
"${inputs.self}/common/optional/zerotier.nix"
./hardware.nix
inputs.nixos-hardware.nixosModules.framework-13-7040-amd
];

View File

@@ -1,15 +1,15 @@
{ inputs, ... }:
{
imports = [
../../users/richie
../../common/global
../../common/optional/desktop.nix
../../common/optional/docker.nix
../../common/optional/steam.nix
../../common/optional/syncthing_base.nix
../../common/optional/systemd-boot.nix
../../common/optional/yubikey.nix
../../common/optional/zerotier.nix
"${inputs.self}/users/richie"
"${inputs.self}/common/global"
"${inputs.self}/common/optional/desktop.nix"
"${inputs.self}/common/optional/docker.nix"
"${inputs.self}/common/optional/steam.nix"
"${inputs.self}/common/optional/syncthing_base.nix"
"${inputs.self}/common/optional/systemd-boot.nix"
"${inputs.self}/common/optional/yubikey.nix"
"${inputs.self}/common/optional/zerotier.nix"
./hardware.nix
./llms.nix
./syncthing.nix

View File

@@ -1,258 +0,0 @@
{
"nodes": {
"firefox-addons": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"dir": "pkgs/firefox-addons",
"lastModified": 1757649814,
"narHash": "sha256-VjtA+fqkraKHbGzjKJBPfDj+SXysXiR4SrghTr10HoY=",
"owner": "rycee",
"repo": "nur-expressions",
"rev": "789920825fc982a93a2bf91a714367fa8f7ea0a6",
"type": "gitlab"
},
"original": {
"dir": "pkgs/firefox-addons",
"owner": "rycee",
"repo": "nur-expressions",
"type": "gitlab"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1757698511,
"narHash": "sha256-UqHHGydF/q3jfYXCpvYLA0TWtvByOp1NwOKCUjhYmPs=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "a3fcc92180c7462082cd849498369591dfb20855",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixos-hardware": {
"locked": {
"lastModified": 1757103352,
"narHash": "sha256-PtT7ix43ss8PONJ1VJw3f6t2yAoGH+q462Sn8lrmWmk=",
"owner": "nixos",
"repo": "nixos-hardware",
"rev": "11b2a10c7be726321bb854403fdeec391e798bf0",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "master",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1757487488,
"narHash": "sha256-zwE/e7CuPJUWKdvvTCB7iunV4E/+G0lKfv4kk/5Izdg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "ab0f3607a6c7486ea22229b92ed2d355f1482ee0",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-master": {
"locked": {
"lastModified": 1757720853,
"narHash": "sha256-VBS5+YKIT8Aj81ZW+8Bg9MuYoI6OqO6HSrwG4dpHpW4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2ca437b4796d049192eb30576a50fef139038c09",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "master",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1735563628,
"narHash": "sha256-OnSAY7XDSx7CtDoqNh8jwVwh4xNL/2HaJxGjryLWzX8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b134951a4c9f3c995fd7be05f3243f8ecd65d798",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pyproject-build-systems": {
"inputs": {
"nixpkgs": [
"system_tools",
"nixpkgs"
],
"pyproject-nix": [
"system_tools",
"pyproject-nix"
],
"uv2nix": [
"system_tools",
"uv2nix"
]
},
"locked": {
"lastModified": 1744599653,
"narHash": "sha256-nysSwVVjG4hKoOjhjvE6U5lIKA8sEr1d1QzEfZsannU=",
"owner": "pyproject-nix",
"repo": "build-system-pkgs",
"rev": "7dba6dbc73120e15b558754c26024f6c93015dd7",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "build-system-pkgs",
"type": "github"
}
},
"pyproject-nix": {
"inputs": {
"nixpkgs": [
"system_tools",
"nixpkgs"
]
},
"locked": {
"lastModified": 1746540146,
"narHash": "sha256-QxdHGNpbicIrw5t6U3x+ZxeY/7IEJ6lYbvsjXmcxFIM=",
"owner": "pyproject-nix",
"repo": "pyproject.nix",
"rev": "e09c10c24ebb955125fda449939bfba664c467fd",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "pyproject.nix",
"type": "github"
}
},
"root": {
"inputs": {
"firefox-addons": "firefox-addons",
"home-manager": "home-manager",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs",
"nixpkgs-master": "nixpkgs-master",
"nixpkgs-stable": "nixpkgs-stable",
"sops-nix": "sops-nix",
"system_tools": "system_tools",
"systems": "systems"
}
},
"sops-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1757503115,
"narHash": "sha256-S9F6bHUBh+CFEUalv/qxNImRapCxvSnOzWBUZgK1zDU=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "0bf793823386187dff101ee2a9d4ed26de8bbf8c",
"type": "github"
},
"original": {
"owner": "Mic92",
"repo": "sops-nix",
"type": "github"
}
},
"system_tools": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"pyproject-build-systems": "pyproject-build-systems",
"pyproject-nix": "pyproject-nix",
"uv2nix": "uv2nix"
},
"locked": {
"lastModified": 1757910132,
"narHash": "sha256-6r45DD/tMN+hYgnMc2/c82Z0bb1A7FnI/nvU8kZf/Us=",
"owner": "RichieCahill",
"repo": "system_tools",
"rev": "d63c486fe3b76c24b2ed2fff33d6f54c847b50e8",
"type": "github"
},
"original": {
"owner": "RichieCahill",
"repo": "system_tools",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"uv2nix": {
"inputs": {
"nixpkgs": [
"system_tools",
"nixpkgs"
],
"pyproject-nix": [
"system_tools",
"pyproject-nix"
]
},
"locked": {
"lastModified": 1747441483,
"narHash": "sha256-W8BFXk5R0TuJcjIhcGoMpSOaIufGXpizK0pm+uTqynA=",
"owner": "pyproject-nix",
"repo": "uv2nix",
"rev": "582024dc64663e9f88d467c2f7f7b20d278349de",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "uv2nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

6
tests/conftest.py Normal file
View File

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

67
tests/test_databasse.py Normal file
View File

@@ -0,0 +1,67 @@
"""test_database."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from sqlalchemy import Integer, String, create_engine, select
from sqlalchemy.orm import DeclarativeBase, Mapped, Session, mapped_column, sessionmaker
from python.database import safe_insert
if TYPE_CHECKING:
from collections.abc import Generator
class TestingBase(DeclarativeBase):
"""TestingBase."""
class Item(TestingBase):
"""Item."""
__tablename__ = "items"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(50), nullable=False, unique=True)
@pytest.fixture
def session() -> Generator[Session]:
"""Fresh in-memory DB + tables for each test."""
engine = create_engine("sqlite+pysqlite:///:memory:", echo=False, future=True)
TestingBase.metadata.create_all(engine)
with sessionmaker(bind=engine, expire_on_commit=False, future=True)() as s:
yield s
def test_partial_failure_unique_constraint(session: Session) -> None:
"""Duplicate name should fail only for the conflicting row; others commit."""
objs = [Item(name="a"), Item(name="b"), Item(name="a"), Item(name="c")]
failures = safe_insert(objs, session)
assert len(failures) == 1
exc, failed_obj = failures[0]
assert isinstance(exc, Exception)
assert isinstance(failed_obj, Item)
assert failed_obj.name == "a"
rows = session.scalars(select(Item.name)).all()
assert sorted(rows) == ["a", "b", "c"]
assert rows.count("a") == 1
def test_all_good_inserts(session: Session) -> None:
"""No failures when all rows are valid."""
objs = [Item(name="x"), Item(name="y")]
failures = safe_insert(objs, session)
assert failures == []
rows = session.scalars(select(Item.name).where(Item.name.in_(("x", "y")))).all()
assert sorted(rows) == ["x", "y"]
def test_unmapped_object_raises(session: Session) -> None:
"""Non-ORM instances should raise TypeError immediately."""
with pytest.raises(TypeError):
safe_insert([object()], session)

View File

@@ -0,0 +1,75 @@
"""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,9 +1,11 @@
{
programs.git = {
enable = true;
userEmail = "dov.kruger@gmail.com";
userName = "Dov Kruger";
extraConfig = {
settings = {
user = {
email = "dov.kruger@gmail.com";
name = "Dov Kruger";
};
pull.rebase = true;
color.ui = true;
};

View File

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

View File

@@ -15,7 +15,6 @@
# graphics tools
gimp3
xcursorgen
xf86_input_wacom
# browser
chromium
firefox

View File

@@ -1,4 +1,4 @@
{ pkgs, inputs, ... }:
{ pkgs, ... }:
{
home.packages = with pkgs; [
# cli

View File

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

View File

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

View File

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

View File

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

View File

@@ -88,5 +88,6 @@
"redhat.telemetry.enabled": true,
"gitlens.plusFeatures.enabled": false,
// new
"hediet.vscode-drawio.resizeImages": null
"hediet.vscode-drawio.resizeImages": null,
"hediet.vscode-drawio.appearance": "automatic"
}

View File

@@ -1,4 +1,4 @@
{ pkgs, inputs, ... }:
{ pkgs, ... }:
{
home.packages = with pkgs; [
# cli
@@ -58,6 +58,5 @@
nix-tree
nixfmt-rfc-style
treefmt
inputs.system_tools.packages.x86_64-linux.default
];
}

View File

@@ -43,12 +43,6 @@
identityFile = "~/.ssh/id_ed25519";
port = 922;
};
leviathan = {
hostname = "192.168.90.127";
user = "richie";
identityFile = "~/.ssh/id_ed25519";
port = 332;
};
};
};
}