From 8d75b351672302c7c98ef2fcc142f6db6e70701c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 2 Apr 2020 10:23:08 +0100 Subject: [PATCH 1/3] lib/repoSource: don't copy local repositories to the nix store --- lib/repoSource.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/repoSource.nix b/lib/repoSource.nix index b8d1692d2..75f7080f5 100644 --- a/lib/repoSource.nix +++ b/lib/repoSource.nix @@ -21,7 +21,7 @@ let localPath = ../repos + "/${name}"; in if lib.pathExists localPath then - "${localPath}" + localPath else if lib.hasPrefix "https://github.com" attr.url && !submodules then fetchzip { url = "${attr.url}/archive/${revision.rev}.zip"; From 08f476af09132e12cf83f35185124300905c182a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 2 Apr 2020 10:25:03 +0100 Subject: [PATCH 2/3] nur-index: fix indexing nur-combined we want to switch to nur-combined in case repositories are not reachable --- nur/index.py | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/nur/index.py b/nur/index.py index e1acdb054..92bc97a6b 100644 --- a/nur/index.py +++ b/nur/index.py @@ -8,23 +8,20 @@ from typing import Any, Dict def index_repo(directory: Path, repo: str, expression_file: str) -> Dict[str, Any]: - default_nix = directory.joinpath("default.nix") - fetch_source_cmd = [ - "nix-build", - "--builders", - "", - "--no-out-link", - str(default_nix), - "-A", - f'repo-sources."{repo}"', - ] - - repo_path = subprocess.check_output(fetch_source_cmd).strip().decode("utf-8") - - expression_path = Path(repo_path).joinpath(expression_file) + default_nix = directory.joinpath("default.nix").resolve() + expr = """ +with import {}; +let + nur = import %s { nurpkgs = pkgs; inherit pkgs; }; +in +callPackage (nur.repo-sources."%s" + "/%s") {} +""" % ( + default_nix, + repo, + expression_file, + ) with NamedTemporaryFile(mode="w") as f: - expr = f"with import {{}}; callPackage {expression_path} {{}}" f.write(expr) f.flush() query_cmd = ["nix-env", "-qa", "*", "--json", "-f", str(f.name)] @@ -42,11 +39,11 @@ def index_repo(directory: Path, repo: str, expression_file: str) -> Dict[str, An position = pkg["meta"].get("position", None) # TODO commit hash prefix = f"https://github.com/nix-community/nur-combined/tree/master/repos/{repo}" - if position is not None and position.startswith(repo_path): - prefix_len = len(repo_path) - stripped = position[prefix_len:] - path, line = stripped.rsplit(":", 1) - pkg["meta"]["position"] = f"{prefix}{path}#L{line}" + if position is not None and position.startswith("/nix/store"): + path_str, line = position.rsplit(":", 1) + path = Path(path_str) + stripped = path.parts[4:] + pkg["meta"]["position"] = f"{prefix}{stripped}#L{line}" else: pkg["meta"]["position"] = prefix pkgs[f"nur.repos.{repo}.{name}"] = pkg @@ -62,6 +59,7 @@ def index_command(args: Namespace) -> None: pkgs: Dict[str, Any] = {} for (repo, data) in repos.items(): - pkgs.update(index_repo(directory, repo, data.get("file", "default.nix"))) + repo_pkgs = index_repo(directory, repo, data.get("file", "default.nix")) + pkgs.update(repo_pkgs) json.dump(pkgs, sys.stdout, indent=4) From 8a8948c86d6b1e3ac7c3047410441d04731c28eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 2 Apr 2020 12:55:40 +0100 Subject: [PATCH 3/3] ci: use nur-combined for faster indexing This avoids downloading repositories --- ci/update-nur-search.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/update-nur-search.sh b/ci/update-nur-search.sh index b4a536d37..3f9cdbf6e 100755 --- a/ci/update-nur-search.sh +++ b/ci/update-nur-search.sh @@ -15,7 +15,9 @@ nix-build --quiet release.nix git clone git@github.com:nix-community/nur-search -nix run '(import ./release.nix {})' -c nur index . > nur-search/data/packages.json +git clone git@github.com:nix-community/nur-combined + +nix run '(import ./release.nix {})' -c nur index nur-combined > nur-search/data/packages.json # rebuild and publish nur-search repository # -----------------------------------------