refactor(python): use dedicated runtime environments
This commit is contained in:
@@ -15,7 +15,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: merge_flake_lock_update
|
- name: merge_flake_lock_update
|
||||||
run: >-
|
run: >-
|
||||||
nix develop .#devShells.x86_64-linux.default -c
|
|
||||||
python -m python.gitea_flake_lock merge
|
python -m python.gitea_flake_lock merge
|
||||||
--repo "${{ github.repository }}"
|
--repo "${{ github.repository }}"
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -21,6 +21,5 @@ jobs:
|
|||||||
JEEVES_BOT_TOKEN: ${{ secrets.JEEVES_BOT_TOKEN }}
|
JEEVES_BOT_TOKEN: ${{ secrets.JEEVES_BOT_TOKEN }}
|
||||||
GITEA_URL: https://gitea.tmmworkshop.com
|
GITEA_URL: https://gitea.tmmworkshop.com
|
||||||
run: >-
|
run: >-
|
||||||
nix develop .#devShells.x86_64-linux.default -c
|
|
||||||
python -m python.gitea_flake_lock update
|
python -m python.gitea_flake_lock update
|
||||||
--repo "${{ github.repository }}"
|
--repo "${{ github.repository }}"
|
||||||
|
|||||||
@@ -2,6 +2,5 @@
|
|||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
git
|
git
|
||||||
my_python
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,17 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: _prev: {
|
||||||
|
snapshot_manager_python = final.python314.withPackages (
|
||||||
|
ps: with ps; [
|
||||||
|
apprise
|
||||||
|
typer
|
||||||
|
]
|
||||||
|
);
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
systemd = {
|
systemd = {
|
||||||
services.snapshot_manager = {
|
services.snapshot_manager = {
|
||||||
description = "ZFS Snapshot Manager";
|
description = "ZFS Snapshot Manager";
|
||||||
@@ -45,7 +56,7 @@ in
|
|||||||
};
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "${pkgs.my_python}/bin/python -m python.tools.snapshot_manager ${lib.escapeShellArg cfg.path}";
|
ExecStart = "${pkgs.snapshot_manager_python}/bin/python -m python.tools.snapshot_manager ${lib.escapeShellArg cfg.path}";
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs (cfg.EnvironmentFile != null) {
|
// lib.optionalAttrs (cfg.EnvironmentFile != null) {
|
||||||
EnvironmentFile = cfg.EnvironmentFile;
|
EnvironmentFile = cfg.EnvironmentFile;
|
||||||
|
|||||||
@@ -17,35 +17,4 @@
|
|||||||
|
|
||||||
test-exclusions = import ./test-exclusions.nix;
|
test-exclusions = import ./test-exclusions.nix;
|
||||||
x86-64-v3-workarounds = import ./x86-64-v3-workarounds.nix;
|
x86-64-v3-workarounds = import ./x86-64-v3-workarounds.nix;
|
||||||
|
|
||||||
python-env = final: _prev: {
|
|
||||||
my_python = final.python314.withPackages (
|
|
||||||
ps: with ps; [
|
|
||||||
alembic
|
|
||||||
apprise
|
|
||||||
fastapi
|
|
||||||
fastapi-cli
|
|
||||||
httpx
|
|
||||||
jinja2
|
|
||||||
mypy
|
|
||||||
pgvector
|
|
||||||
psycopg
|
|
||||||
pydantic
|
|
||||||
pyfakefs
|
|
||||||
pytest
|
|
||||||
pytest-cov
|
|
||||||
pytest-mock
|
|
||||||
pytest-xdist
|
|
||||||
python-multipart
|
|
||||||
pydantic-settings
|
|
||||||
ruff
|
|
||||||
sqlalchemy
|
|
||||||
tenacity
|
|
||||||
tinytuya
|
|
||||||
typer
|
|
||||||
uvicorn
|
|
||||||
websockets
|
|
||||||
]
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
# loader path, which NixOS does not provide globally.
|
# loader path, which NixOS does not provide globally.
|
||||||
ebook-search = pkgs.mkShell {
|
ebook-search = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
my_python
|
python314
|
||||||
uv
|
uv
|
||||||
];
|
];
|
||||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
|
||||||
@@ -23,7 +23,6 @@
|
|||||||
nix
|
nix
|
||||||
home-manager
|
home-manager
|
||||||
git
|
git
|
||||||
my_python
|
|
||||||
|
|
||||||
ssh-to-age
|
ssh-to-age
|
||||||
gnupg
|
gnupg
|
||||||
|
|||||||
@@ -4,6 +4,20 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: _prev: {
|
||||||
|
heater_python = final.python314.withPackages (
|
||||||
|
ps: with ps; [
|
||||||
|
fastapi
|
||||||
|
pydantic
|
||||||
|
tinytuya
|
||||||
|
typer
|
||||||
|
uvicorn
|
||||||
|
]
|
||||||
|
);
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ 8124 ];
|
networking.firewall.allowedTCPPorts = [ 8124 ];
|
||||||
|
|
||||||
systemd.services.heater-api = {
|
systemd.services.heater-api = {
|
||||||
@@ -17,7 +31,7 @@
|
|||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
ExecStart = "${pkgs.my_python}/bin/python -m python.heater.main --host 0.0.0.0 --port 8124";
|
ExecStart = "${pkgs.heater_python}/bin/python -m python.heater.main --host 0.0.0.0 --port 8124";
|
||||||
EnvironmentFile = "/etc/heater.env";
|
EnvironmentFile = "/etc/heater.env";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = "5s";
|
RestartSec = "5s";
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ let
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
giteaAutomationPython = pkgs.python314.withPackages (
|
||||||
|
ps: with ps; [
|
||||||
|
httpx
|
||||||
|
pydantic
|
||||||
|
typer
|
||||||
|
]
|
||||||
|
);
|
||||||
runnerConfigFile = (pkgs.formats.yaml { }).generate "gitea-runner.yaml" { };
|
runnerConfigFile = (pkgs.formats.yaml { }).generate "gitea-runner.yaml" { };
|
||||||
registerRunner = pkgs.writeShellApplication {
|
registerRunner = pkgs.writeShellApplication {
|
||||||
name = "register-gitea-runner";
|
name = "register-gitea-runner";
|
||||||
@@ -96,8 +103,8 @@ let
|
|||||||
curl
|
curl
|
||||||
gawk
|
gawk
|
||||||
gitMinimal
|
gitMinimal
|
||||||
|
giteaAutomationPython
|
||||||
gnused
|
gnused
|
||||||
my_python
|
|
||||||
nix
|
nix
|
||||||
nixfmt
|
nixfmt
|
||||||
nixos-rebuild
|
nixos-rebuild
|
||||||
|
|||||||
@@ -8,6 +8,22 @@ let
|
|||||||
stateDir = "${vars.services}/gems";
|
stateDir = "${vars.services}/gems";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: _prev: {
|
||||||
|
gems_python = final.python314.withPackages (
|
||||||
|
ps: with ps; [
|
||||||
|
fastapi
|
||||||
|
jinja2
|
||||||
|
pydantic
|
||||||
|
pydantic-settings
|
||||||
|
python-multipart
|
||||||
|
typer
|
||||||
|
uvicorn
|
||||||
|
]
|
||||||
|
);
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
users.groups.gems = { };
|
users.groups.gems = { };
|
||||||
users.users.gems = {
|
users.users.gems = {
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
@@ -36,7 +52,7 @@ in
|
|||||||
Type = "simple";
|
Type = "simple";
|
||||||
User = "gems";
|
User = "gems";
|
||||||
Group = "gems";
|
Group = "gems";
|
||||||
ExecStart = "${pkgs.my_python}/bin/python -m python.gems.main --host 0.0.0.0 --port 8002";
|
ExecStart = "${pkgs.gems_python}/bin/python -m python.gems.main --host 0.0.0.0 --port 8002";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = "5s";
|
RestartSec = "5s";
|
||||||
StandardOutput = "journal";
|
StandardOutput = "journal";
|
||||||
|
|||||||
Reference in New Issue
Block a user