Compare commits

4 Commits

Author SHA1 Message Date
33820abfc0 Merge branch 'main' into feature/hydra
All checks were successful
Check flake.lock / Check health of `flake.lock` (pull_request) Successful in 34s
Check Nix formatting / Perform Nix format checks (pull_request) Successful in 14m22s
Check Nix flake / Perform Nix flake checks (ubuntu-latest) (pull_request) Successful in 21m14s
2025-05-26 22:34:13 -04:00
e9837be2b1 fix flake show
Some checks failed
Check Nix flake / Perform Nix flake checks (ubuntu-latest) (pull_request) Has been cancelled
Check Nix formatting / Perform Nix format checks (pull_request) Has been cancelled
Check flake.lock / Check health of `flake.lock` (pull_request) Successful in 27s
2025-05-26 22:33:15 -04:00
2cc162404b Merge pull request 'update hydra for gitea' (#16) from feature/hydra into main
All checks were successful
Check flake.lock / Check health of `flake.lock` (push) Successful in 15s
Check Nix flake / Perform Nix flake checks (ubuntu-latest) (push) Successful in 7m14s
Check Nix formatting / Perform Nix format checks (push) Successful in 7m20s
Reviewed-on: #16
2025-05-26 22:16:20 -04:00
8d22f15781 update hydra for gitea
All checks were successful
Check flake.lock / Check health of `flake.lock` (pull_request) Successful in 10s
Check Nix formatting / Perform Nix format checks (pull_request) Successful in 3m32s
Check Nix flake / Perform Nix flake checks (ubuntu-latest) (pull_request) Successful in 8m41s
2025-05-26 22:06:30 -04:00
5 changed files with 31 additions and 21 deletions

View File

@@ -23,7 +23,9 @@ def build_output(path: str, output: str) -> str | None:
""" """
logger.info(f"build {output}") logger.info(f"build {output}")
logger.debug(f"outputting to {OUTPUT_DIR}/{output}.nixoutput") logger.debug(f"outputting to {OUTPUT_DIR}/{output}.nixoutput")
out = bash_wrapper(f"nix build {path}#{output} -o {OUTPUT_DIR}/{output}.nixoutput --accept-flake-config") out = bash_wrapper(
f"nix build {path}#{output} -o {OUTPUT_DIR}/{output}.nixoutput --accept-flake-config"
)
logger.debug("output") logger.debug("output")
logger.debug(out[0]) logger.debug(out[0])
logger.debug("error") logger.debug("error")

View File

@@ -53,7 +53,9 @@ def get_derivations_from_check(nix_path: str, path_to_flake: str) -> list[str]:
:param path_to_flake: path to flake to be checked :param path_to_flake: path to flake to be checked
:returns a list of all valid derivations in the flake :returns a list of all valid derivations in the flake
""" """
flake_check = bash_wrapper(f"{nix_path} flake check --verbose --keep-going --accept-flake-config", path=path_to_flake) flake_check = bash_wrapper(
f"{nix_path} flake check --verbose --keep-going --accept-flake-config", path=path_to_flake
)
if flake_check[2] != 0: if flake_check[2] != 0:
logger.warning( logger.warning(
"nix flake check returned non-zero exit code, collecting all available outputs" "nix flake check returned non-zero exit code, collecting all available outputs"
@@ -71,7 +73,9 @@ def get_derivations_from_check(nix_path: str, path_to_flake: str) -> list[str]:
return derivations return derivations
def get_derivations(path_to_flake: str, *, allow_import_from_derivation: False = False) -> list[str]: def get_derivations(
path_to_flake: str, *, allow_import_from_derivation: False = False
) -> list[str]:
"""Gets all derivations present in a flake. """Gets all derivations present in a flake.
:param path_to_flake: path to flake to be checked :param path_to_flake: path to flake to be checked
@@ -83,7 +87,7 @@ def get_derivations(path_to_flake: str, *, allow_import_from_derivation: False =
if nix_path is None: if nix_path is None:
status_msg = "nix is not available in the PATH, please verify that it is installed" status_msg = "nix is not available in the PATH, please verify that it is installed"
raise RuntimeError(status_msg) raise RuntimeError(status_msg)
cmd = f"{nix_path} flake show --json --accept-flake-path" cmd = f"{nix_path} flake show --json --accept-flake-config --all-systems"
cmd += " --allow-import-from-derivation" if allow_import_from_derivation else "" cmd += " --allow-import-from-derivation" if allow_import_from_derivation else ""
flake_show = bash_wrapper(cmd, path=path_to_flake) flake_show = bash_wrapper(cmd, path=path_to_flake)
if flake_show[2] != 0: if flake_show[2] != 0:

View File

@@ -99,7 +99,8 @@ def build_or_eval(args: Namespace) -> None:
""" """
flake_path = args.flake_path flake_path = args.flake_path
derivations, hydra_jobs = partition( derivations, hydra_jobs = partition(
lambda s: s.startswith("hydraJobs"), get_derivations(flake_path, args["allow-import-from-derivation"]) lambda s: s.startswith("hydraJobs"),
get_derivations(flake_path, allow_import_from_derivation=args.allow_import_from_derivation),
) )
derivations, hydra_jobs = list(derivations), list(hydra_jobs) derivations, hydra_jobs = list(derivations), list(hydra_jobs)
logger.info(f"derivations: {list(derivations)}") logger.info(f"derivations: {list(derivations)}")

View File

@@ -19,7 +19,6 @@ let
prs = readJSONFile pulls; prs = readJSONFile pulls;
refs = readJSONFile branches; refs = readJSONFile branches;
repo = "RAD-Development/flake-update-diff";
# template for creating a job # template for creating a job
makeJob = makeJob =
@@ -28,6 +27,7 @@ let
keepnr ? 3, keepnr ? 3,
description, description,
flake, flake,
enabled ? 1,
}: }:
{ {
inherit inherit
@@ -35,36 +35,39 @@ let
flake flake
schedulingshares schedulingshares
keepnr keepnr
enabled
; ;
enabled = 1;
type = 1; type = 1;
hidden = false; hidden = false;
checkinterval = 300; # every 6 months checkinterval = 300; # every 5 minutes
enableemail = false; enableemail = false;
emailoverride = ""; emailoverride = "";
}; };
# Create a hydra job for a branch giteaHost = "ssh://gitea@nayeonie.com:2222";
repo = "ahuston-0/flake-update-diff";
# # Create a hydra job for a branch
jobOfRef = jobOfRef =
name: name:
{ ref, ... }: { ref, ... }:
if (builtins.match "^refs/heads/(.*)$" ref) == null then if ((builtins.match "^refs/heads/(.*)$" ref) == null) then
null null
else else
{ {
name = builtins.replaceStrings [ "/" ] [ "-" ] "branch-${name}"; name = builtins.replaceStrings [ "/" ] [ "-" ] "branch-${name}";
value = makeJob { value = makeJob {
description = "Branch ${name}"; description = "Branch ${name}";
flake = "git+ssh://git@github.com/${repo}?ref=${ref}"; flake = "git+${giteaHost}/${repo}?ref=${ref}";
}; };
}; };
# Create a hydra job for a PR # Create a hydra job for a PR
jobOfPR = id: info: { jobOfPR = id: info: {
name = "pr-${id}"; name = if info.draft then "draft-${id}" else "pr-${id}";
value = makeJob { value = makeJob {
description = "PR ${id}: ${info.title}"; description = "PR ${id}: ${info.title}";
flake = "git+ssh://git@github.com/${info.head.repo.full_name}?ref=${info.head.ref}"; flake = "git+${giteaHost}/${repo}?ref=${info.head.ref}";
enabled = info.state == "open";
}; };
}; };
@@ -74,7 +77,7 @@ let
# wrapper function for reading json from file # wrapper function for reading json from file
readJSONFile = f: builtins.fromJSON (builtins.readFile f); readJSONFile = f: builtins.fromJSON (builtins.readFile f);
# remove null values from a set, in-case of branches that don't exist # remove null values from a set, in-case of branches that don't exist
mapFilter = f: l: builtins.filter (x: x != null) (map f l); mapFilter = f: l: builtins.filter (x: (x != null)) (map f l);
# Create job set from PRs and branches # Create job set from PRs and branches
jobs = makeSpec ( jobs = makeSpec (

View File

@@ -1,7 +1,7 @@
{ {
"enabled": 1, "enabled": 1,
"hidden": false, "hidden": false,
"description": "Flake update diff tool", "description": "Flake Update Diff Tool (flupdt)",
"nixexprinput": "nixexpr", "nixexprinput": "nixexpr",
"nixexprpath": "hydra/jobsets.nix", "nixexprpath": "hydra/jobsets.nix",
"checkinterval": 60, "checkinterval": 60,
@@ -12,23 +12,23 @@
"type": 0, "type": 0,
"inputs": { "inputs": {
"nixexpr": { "nixexpr": {
"value": "https://github.com/RAD-Development/flake-update-diff main", "value": "ssh://gitea@nayeonie.com:2222/ahuston-0/flake-update-diff.git main",
"type": "git", "type": "git",
"emailresponsible": false "emailresponsible": false
}, },
"nixpkgs": { "nixpkgs": {
"value": "https://github.com/NixOS/nixpkgs nixos-unstable-small", "value": "https://github.com/NixOS/nixpkgs nixos-unstable",
"type": "git", "type": "git",
"emailresponsible": false "emailresponsible": false
}, },
"pulls": { "pulls": {
"type": "githubpulls", "type": "giteapulls",
"value": "RAD-Development flake-update-diff", "value": "nayeonie.com ahuston-0 flake-update-diff https",
"emailresponsible": false "emailresponsible": false
}, },
"branches": { "branches": {
"type": "github_refs", "type": "gitea_refs",
"value": "RAD-Development flake-update-diff heads -", "value": "nayeonie.com ahuston-0 flake-update-diff heads https -",
"emailresponsible": false "emailresponsible": false
} }
} }