mirror of
https://github.com/RichieCahill/dotfiles.git
synced 2026-04-21 06:39:09 -04:00
Compare commits
6 Commits
feature/ad
...
feature/ad
| Author | SHA1 | Date | |
|---|---|---|---|
| 4538bb05da | |||
| 4530be4916 | |||
| 4b63b71a85 | |||
| 6029bcd6b9 | |||
| 261c7008f0 | |||
| 8cce072e76 |
2
.github/workflows/pytest.yml
vendored
2
.github/workflows/pytest.yml
vendored
@@ -16,4 +16,4 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run tests
|
||||
run: nix develop .#devShells.x86_64-linux.default -c pytest tests
|
||||
run: pytest tests
|
||||
|
||||
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@@ -252,7 +252,6 @@
|
||||
"schemeless",
|
||||
"scrollback",
|
||||
"SECUREFOX",
|
||||
"sessionmaker",
|
||||
"sessionstore",
|
||||
"shellcheck",
|
||||
"signon",
|
||||
@@ -264,7 +263,6 @@
|
||||
"socialtracking",
|
||||
"sonarr",
|
||||
"sponsorblock",
|
||||
"sqlalchemy",
|
||||
"sqltools",
|
||||
"ssdp",
|
||||
"SSHOPTS",
|
||||
@@ -327,10 +325,5 @@
|
||||
"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
|
||||
]
|
||||
}
|
||||
|
||||
@@ -44,10 +44,7 @@
|
||||
# firmware update
|
||||
fwupd.enable = true;
|
||||
|
||||
snapshot_manager = {
|
||||
enable = lib.mkDefault true;
|
||||
PYTHONPATH = "${inputs.self}/";
|
||||
};
|
||||
snapshot_manager.enable = lib.mkDefault true;
|
||||
|
||||
zfs = {
|
||||
trim.enable = lib.mkDefault true;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
@@ -16,12 +17,6 @@ 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;
|
||||
@@ -40,12 +35,11 @@ in
|
||||
requires = [ "zfs-import.target" ];
|
||||
after = [ "zfs-import.target" ];
|
||||
path = [ pkgs.zfs ];
|
||||
environment = {
|
||||
PYTHONPATH = cfg.PYTHONPATH;
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.my_python}/bin/python -m python.tools.snapshot_manager ${lib.escapeShellArg cfg.path}";
|
||||
ExecStart = "${
|
||||
inputs.system_tools.packages.${pkgs.system}.default
|
||||
}/bin/snapshot_manager ${lib.escapeShellArg cfg.path}";
|
||||
}
|
||||
// lib.optionalAttrs (cfg.EnvironmentFile != null) {
|
||||
EnvironmentFile = cfg.EnvironmentFile;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
boot = {
|
||||
kernelPackages = pkgs.linuxPackages_6_17;
|
||||
zfs.package = pkgs.zfs_unstable;
|
||||
kernelPackages = pkgs.linuxPackages_6_16;
|
||||
zfs.package = pkgs.zfs_2_3;
|
||||
};
|
||||
|
||||
hardware.bluetooth = {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# Cool tools
|
||||
|
||||
A collection of cool tools I've found.
|
||||
|
||||
- <https://github.com/9001/copyparty>
|
||||
- <https://github.com/google/magika>
|
||||
- <https://github.com/pytest-dev/pyfakefs>
|
||||
- <https://pyreadiness.org/>
|
||||
- <https://testcontainers.com/>
|
||||
@@ -15,11 +15,3 @@ You can read my latest posts below
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
## Other Resources
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ './cool_tools.md' | relative_url }}">Cool Tools</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -2,6 +2,16 @@ esphome:
|
||||
name: batteries
|
||||
friendly_name: batteries
|
||||
|
||||
platformio_options:
|
||||
build_unflags:
|
||||
- -fno-lto
|
||||
- -Og
|
||||
- -O0
|
||||
build_flags:
|
||||
- -flto
|
||||
- -Os
|
||||
- -Wl,--gc-sections
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
@@ -23,14 +33,7 @@ ota:
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
captive_portal:
|
||||
|
||||
esp32_ble_tracker:
|
||||
scan_parameters:
|
||||
interval: 1100ms
|
||||
window: 1100ms
|
||||
active: true
|
||||
fast_connect: true
|
||||
|
||||
ble_client:
|
||||
- mac_address: "C8:47:80:29:0F:DB"
|
||||
@@ -55,8 +58,6 @@ sensor:
|
||||
jk_bms_ble_id: jk_bms0
|
||||
total_voltage:
|
||||
name: "JK0 Total Voltage"
|
||||
current:
|
||||
name: "JK0 Current"
|
||||
state_of_charge:
|
||||
name: "JK0 SoC"
|
||||
power:
|
||||
@@ -65,12 +66,8 @@ sensor:
|
||||
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"
|
||||
|
||||
@@ -79,8 +76,6 @@ sensor:
|
||||
jk_bms_ble_id: jk_bms1
|
||||
total_voltage:
|
||||
name: "JK1 Total Voltage"
|
||||
current:
|
||||
name: "JK1 Current"
|
||||
state_of_charge:
|
||||
name: "JK1 SoC"
|
||||
power:
|
||||
@@ -89,12 +84,8 @@ sensor:
|
||||
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"
|
||||
|
||||
|
||||
135
flake.lock
generated
135
flake.lock
generated
@@ -8,11 +8,11 @@
|
||||
},
|
||||
"locked": {
|
||||
"dir": "pkgs/firefox-addons",
|
||||
"lastModified": 1763093017,
|
||||
"narHash": "sha256-FjnOyxTNNt85ZNjtLqRnG23LKQyvilGzyrO0bLffMm8=",
|
||||
"lastModified": 1760673822,
|
||||
"narHash": "sha256-h+liPhhMw1yYvkDGLHzQJQShQs+yLjNgjfAyZX+sRrM=",
|
||||
"owner": "rycee",
|
||||
"repo": "nur-expressions",
|
||||
"rev": "d84c9ea299c1e4629f0d0716799f5c57975021ce",
|
||||
"rev": "5cca27f1bb30a26140d0cf60ab34daa45b4fa11f",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
@@ -29,11 +29,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1762964643,
|
||||
"narHash": "sha256-RYHN8O/Aja59XDji6WSJZPkJpYVUfpSkyH+PEupBJqM=",
|
||||
"lastModified": 1760662441,
|
||||
"narHash": "sha256-mlDqR1Ntgs9uYYEAUR1IhamKBO0lxoNS4zGLzEZaY0A=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "827f2a23373a774a8805f84ca5344654c31f354b",
|
||||
"rev": "722792af097dff5790f1a66d271a47759f477755",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -44,11 +44,11 @@
|
||||
},
|
||||
"nixos-hardware": {
|
||||
"locked": {
|
||||
"lastModified": 1762847253,
|
||||
"narHash": "sha256-BWWnUUT01lPwCWUvS0p6Px5UOBFeXJ8jR+ZdLX8IbrU=",
|
||||
"lastModified": 1760106635,
|
||||
"narHash": "sha256-2GoxVaKWTHBxRoeUYSjv0AfSOx4qw5CWSFz2b+VolKU=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "899dc449bc6428b9ee6b3b8f771ca2b0ef945ab9",
|
||||
"rev": "9ed85f8afebf2b7478f25db0a98d0e782c0ed903",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -60,11 +60,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1762977756,
|
||||
"narHash": "sha256-4PqRErxfe+2toFJFgcRKZ0UI9NSIOJa+7RXVtBhy4KE=",
|
||||
"lastModified": 1760524057,
|
||||
"narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c5ae371f1a6a7fd27823bc500d9390b38c05fa55",
|
||||
"rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -76,11 +76,11 @@
|
||||
},
|
||||
"nixpkgs-master": {
|
||||
"locked": {
|
||||
"lastModified": 1763165634,
|
||||
"narHash": "sha256-jVuaLD1Yf2aHILt2EedLFhqJnQXAS8kIo3P4LbtYDyg=",
|
||||
"lastModified": 1760751316,
|
||||
"narHash": "sha256-1296zQfPiLZNrLKzX1t+kunadeI/mH82hKze3voduEI=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "20f91b6ba5eff456057e359946c3e832173b18df",
|
||||
"rev": "d85429339c0bcf0428084fe1306c970aed364417",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -106,6 +106,56 @@
|
||||
"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",
|
||||
@@ -115,6 +165,7 @@
|
||||
"nixpkgs-master": "nixpkgs-master",
|
||||
"nixpkgs-stable": "nixpkgs-stable",
|
||||
"sops-nix": "sops-nix",
|
||||
"system_tools": "system_tools",
|
||||
"systems": "systems"
|
||||
}
|
||||
},
|
||||
@@ -125,11 +176,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1763069729,
|
||||
"narHash": "sha256-A91a+K0Q9wfdPLwL06e/kbHeAWSzPYy2EGdTDsyfb+s=",
|
||||
"lastModified": 1760393368,
|
||||
"narHash": "sha256-8mN3kqyqa2PKY0wwZ2UmMEYMcxvNTwLaOrrDsw6Qi4E=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "a2bcd1c25c1d29e22756ccae094032ab4ada2268",
|
||||
"rev": "ab8d56e85b8be14cff9d93735951e30c3e86a437",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -138,6 +189,29 @@
|
||||
"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,
|
||||
@@ -152,6 +226,31 @@
|
||||
"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",
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
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";
|
||||
@@ -54,7 +59,6 @@
|
||||
system:
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = builtins.attrValues outputs.overlays;
|
||||
config.allowUnfree = true;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
apscheduler
|
||||
mypy
|
||||
polars
|
||||
psycopg
|
||||
pyfakefs
|
||||
pytest
|
||||
pytest-cov
|
||||
@@ -30,7 +29,6 @@
|
||||
pytest-xdist
|
||||
requests
|
||||
ruff
|
||||
sqlalchemy
|
||||
typer
|
||||
types-requests
|
||||
]
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
"""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
|
||||
@@ -85,7 +85,7 @@ def get_material_resistivity(
|
||||
) -> float:
|
||||
"""Get the resistivity of a material."""
|
||||
if not temperature:
|
||||
temperature = Temperature(20.0)
|
||||
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 = Temperature(100.0, unit=TemperatureUnit.FAHRENHEIT)
|
||||
Temperature(100.0, unit=TemperatureUnit.FAHRENHEIT)
|
||||
|
||||
resistivity = get_material_resistivity(material, temperature)
|
||||
resistance_per_meter = resistivity / calculate_wire_area_m2(gauge)
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
imports = [
|
||||
"${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"
|
||||
../../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
|
||||
./hardware.nix
|
||||
./syncthing.nix
|
||||
./llms.nix
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
imports = [
|
||||
"${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"
|
||||
../../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
|
||||
./docker
|
||||
./hardware.nix
|
||||
./programs.nix
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"192.168.95.35"
|
||||
"127.0.0.1"
|
||||
];
|
||||
use_x_forwarded_for = true;
|
||||
};
|
||||
homeassistant = {
|
||||
time_zone = "America/New_York";
|
||||
@@ -59,17 +60,16 @@
|
||||
};
|
||||
extraPackages =
|
||||
python3Packages: with python3Packages; [
|
||||
aioesphomeapi # for esphome
|
||||
bleak-esphome # for esphome
|
||||
esphome-dashboard-api # for esphome
|
||||
forecast-solar # for solar forecast
|
||||
pymodbus # for modbus
|
||||
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
|
||||
pymodbus # for modbus
|
||||
pyopenweathermap # for weather
|
||||
bleak-esphome # for esphome
|
||||
];
|
||||
extraComponents = [ "isal" ];
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ modbus:
|
||||
|
||||
# GPS
|
||||
- name: GPS Latitude
|
||||
slave: 1
|
||||
slave: 100
|
||||
address: 2800
|
||||
input_type: holding
|
||||
data_type: int32
|
||||
@@ -87,7 +87,7 @@ modbus:
|
||||
unique_id: gps_latitude
|
||||
|
||||
- name: GPS Longitude
|
||||
slave: 1
|
||||
slave: 100
|
||||
address: 2802
|
||||
input_type: holding
|
||||
data_type: int32
|
||||
@@ -97,7 +97,7 @@ modbus:
|
||||
unique_id: gps_longitude
|
||||
|
||||
- name: GPS Course
|
||||
slave: 1
|
||||
slave: 100
|
||||
address: 2804
|
||||
input_type: holding
|
||||
data_type: uint16
|
||||
@@ -108,7 +108,7 @@ modbus:
|
||||
unique_id: gps_course
|
||||
|
||||
- name: GPS Speed
|
||||
slave: 1
|
||||
slave: 100
|
||||
address: 2805
|
||||
input_type: holding
|
||||
data_type: uint16
|
||||
@@ -119,7 +119,7 @@ modbus:
|
||||
unique_id: gps_speed
|
||||
|
||||
- name: GPS Fix
|
||||
slave: 1
|
||||
slave: 100
|
||||
address: 2806
|
||||
input_type: holding
|
||||
data_type: uint16
|
||||
@@ -128,7 +128,7 @@ modbus:
|
||||
unique_id: gps_fix
|
||||
|
||||
- name: GPS Satellites
|
||||
slave: 1
|
||||
slave: 100
|
||||
address: 2807
|
||||
input_type: holding
|
||||
data_type: uint16
|
||||
@@ -137,7 +137,7 @@ modbus:
|
||||
unique_id: gps_satellites
|
||||
|
||||
- name: GPS Altitude
|
||||
slave: 1
|
||||
slave: 100
|
||||
address: 2808
|
||||
input_type: holding
|
||||
data_type: int32
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
{ inputs, ... }:
|
||||
let
|
||||
vars = import ./vars.nix;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
"${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"
|
||||
../../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
|
||||
./docker
|
||||
./services
|
||||
./hardware.nix
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ in
|
||||
jellyfin-apiclient-python
|
||||
psycopg2
|
||||
pymetno
|
||||
aio-ownet
|
||||
pyownet
|
||||
rokuecp
|
||||
uiprotect
|
||||
wakeonlan
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
pkgs,
|
||||
inputs,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
@@ -22,13 +22,10 @@ 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 = "${pkgs.my_python}/bin/python -m python.system_tests.validate_system '${./validate_system.toml}'";
|
||||
ExecStart = "${inputs.system_tools.packages.x86_64-linux.default}/bin/validate_system '${./validate_system.toml}'";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
imports = [
|
||||
"${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"
|
||||
../../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
|
||||
./hardware.nix
|
||||
inputs.nixos-hardware.nixosModules.framework-13-7040-amd
|
||||
];
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
imports = [
|
||||
"${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"
|
||||
../../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
|
||||
./hardware.nix
|
||||
./llms.nix
|
||||
./syncthing.nix
|
||||
|
||||
258
temp_flake.lock
Normal file
258
temp_flake.lock
Normal file
@@ -0,0 +1,258 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
"""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)
|
||||
@@ -1,4 +1,4 @@
|
||||
{ pkgs, ... }:
|
||||
{ pkgs, inputs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
# cli
|
||||
|
||||
@@ -88,6 +88,5 @@
|
||||
"redhat.telemetry.enabled": true,
|
||||
"gitlens.plusFeatures.enabled": false,
|
||||
// new
|
||||
"hediet.vscode-drawio.resizeImages": null,
|
||||
"hediet.vscode-drawio.appearance": "automatic"
|
||||
"hediet.vscode-drawio.resizeImages": null
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ pkgs, ... }:
|
||||
{ pkgs, inputs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
# cli
|
||||
@@ -58,5 +58,6 @@
|
||||
nix-tree
|
||||
nixfmt-rfc-style
|
||||
treefmt
|
||||
inputs.system_tools.packages.x86_64-linux.default
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user