fix(nix-autodeploy): pass the repo map as a file
systemd's Environment= strips the quotes out of inline JSON, so the listener died on startup parsing it. A store file has no such problem. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -98,10 +98,9 @@ let
|
||||
flakeIgnore = [ "E501" ];
|
||||
} (builtins.readFile ./listener.py);
|
||||
|
||||
repoMap = lib.mapAttrs (_: r: {
|
||||
inherit (r) input;
|
||||
inherit (r) apply;
|
||||
}) cfg.repos;
|
||||
repoFile = (pkgs.formats.json { }).generate "nix-autodeploy-repos.json" (
|
||||
lib.mapAttrs (_: r: { inherit (r) input apply; }) cfg.repos
|
||||
);
|
||||
in
|
||||
{
|
||||
options.services.nixAutodeploy = {
|
||||
@@ -188,7 +187,7 @@ in
|
||||
"NIX_AUTODEPLOY_PORT=${toString cfg.port}"
|
||||
"NIX_AUTODEPLOY_DEPLOY_BIN=${lib.getExe deploy}"
|
||||
"NIX_AUTODEPLOY_ENV_FILE=${cfg.environmentFile}"
|
||||
"NIX_AUTODEPLOY_REPOS=${builtins.toJSON repoMap}"
|
||||
"NIX_AUTODEPLOY_REPOS_FILE=${repoFile}"
|
||||
];
|
||||
Restart = "always";
|
||||
RestartSec = 2;
|
||||
|
||||
@@ -17,8 +17,10 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
SECRET = os.environ.get("NIX_AUTODEPLOY_SECRET", "").encode()
|
||||
PORT = int(os.environ.get("NIX_AUTODEPLOY_PORT", "7375"))
|
||||
DEPLOY = os.environ["NIX_AUTODEPLOY_DEPLOY_BIN"]
|
||||
# {"<owner>/<repo>": {"input": "rev", "apply": true}, ...}
|
||||
REPOS = json.loads(os.environ["NIX_AUTODEPLOY_REPOS"])
|
||||
# {"<owner>/<repo>": {"input": "rev", "apply": true}, ...}. Passed as a file,
|
||||
# not a variable: systemd's Environment= strips the quotes out of inline JSON.
|
||||
with open(os.environ["NIX_AUTODEPLOY_REPOS_FILE"]) as fh:
|
||||
REPOS = json.load(fh)
|
||||
ENV_FILE = os.environ.get("NIX_AUTODEPLOY_ENV_FILE", "")
|
||||
MAX_BODY = 1 << 20
|
||||
|
||||
|
||||
Reference in New Issue
Block a user