Revert "Support install git dependencies"

This reverts commit ecffc169c3.
This commit is contained in:
DavHau 2023-09-03 01:49:48 +02:00
parent 46f45ab34d
commit 5d561bbf35
5 changed files with 17 additions and 37 deletions

View File

@ -51,11 +51,6 @@
};
};
fetchers = {
url = info: l.fetchurl {inherit (info) url sha256;};
git = info: config.deps.fetchgit {inherit (info) url sha256 rev;};
};
commonModule = {config, ...}: {
imports = [
dream2nix.modules.dream2nix.mkDerivation
@ -86,7 +81,7 @@
);
};
mkDerivation = {
src = l.mkDefault (fetchers.${metadata.sources.${config.name}.type} metadata.sources.${config.name});
src = l.mkDefault (l.fetchurl {inherit (metadata.sources.${config.name}) url sha256;});
doCheck = l.mkDefault false;
nativeBuildInputs =
@ -118,7 +113,7 @@ in {
inherit (config.deps) writePureShellScript python nix git;
};
setuptools = config.deps.python.pkgs.setuptools;
inherit (nixpkgs) git fetchgit;
inherit (nixpkgs) git;
inherit (writers) writePureShellScript;
};

View File

@ -48,7 +48,7 @@ def lock_info_from_fod(store_path, drv_json):
f"fatal: requirement '{store_path}' does not seem to be a FOD.\n"
f"No URL ({url}) or hash ({sha256}) found."
)
return {"type": "url", "url": url, "sha256": sha256}
return url, sha256
def lock_info_from_file_url(download_info):
@ -69,7 +69,7 @@ def lock_info_from_path(full_path):
# See whether the path is relative to our local repo
repo = Path(repo_root("."))
if repo in full_path.parents or repo == full_path:
return {"type": "url", "url": str(full_path.relative_to(repo)), "sha256": None}
return str(full_path.relative_to(repo)), None
# Otherwise, we assume its in /nix/store and just the "top-level"
# store path /nix/store/$hash-name/
@ -94,11 +94,7 @@ def lock_info_from_path(full_path):
)
if proc.returncode == 0:
sha256 = proc.stdout
return {
"type": "url",
"url": "",
"sha256": sha256,
} # need to find a way to get the URL
return "", sha256 # need to find a way to get the URL
else:
raise Exception(
f"fatal: requirement '{full_path}' refers to something we "
@ -115,7 +111,7 @@ def lock_info_from_archive(download_info) -> Optional[Tuple[str, Optional[str]]]
hash = archive_info.get("hash", "").split("=", 1)
sha256 = hash[1] if hash[0] == "sha256" else None
return {"type": "url", "url": download_info["url"], "sha256": sha256}
return (download_info["url"], sha256)
def lock_info_from_vcs(download_info) -> Optional[Tuple[str, Optional[str]]]:
@ -136,12 +132,11 @@ def lock_info_from_vcs(download_info) -> Optional[Tuple[str, Optional[str]]]:
check=True,
).stdout
)["sha256"]
return {"type": "git", "url": url, "rev": rev, "sha256": sha256}
return (f"git+{url}@{rev}", sha256)
def lock_info_fallback(download_info):
return {"type": "url", "url": download_info["url"], "sha256": None}
return download_info["url"], None
def lock_entry_from_report_entry(install):
@ -163,9 +158,12 @@ def lock_entry_from_report_entry(install):
else:
info = lock_info_fallback(download_info)
url, sha256 = info
return name, dict(
url=url,
version=install["metadata"]["version"],
**info,
sha256=sha256,
)

View File

@ -13,7 +13,6 @@ def test_url_no_hash():
download_info=dict(url="https://example.com"),
)
expected = "test", dict(
type="url",
url=install["download_info"]["url"],
version=install["metadata"]["version"],
sha256=None,
@ -33,7 +32,6 @@ def test_url_with_hash():
),
)
expected = "test", dict(
type="url",
url=install["download_info"]["url"],
version=install["metadata"]["version"],
sha256="example_hash",
@ -52,7 +50,6 @@ def test_path_external():
),
)
expected = "test", dict(
type="url",
url=install["download_info"]["url"],
version=install["metadata"]["version"],
sha256=None,
@ -71,7 +68,6 @@ def test_path_in_repo(git_repo_path):
),
)
expected = "test", dict(
type="url",
url=install["download_info"]["url"],
version=install["metadata"]["version"],
sha256=None,
@ -90,7 +86,6 @@ def test_path_in_nix_store():
),
)
expected = "test", dict(
type="url",
url=install["download_info"]["url"],
version=install["metadata"]["version"],
sha256=None,

View File

@ -37,7 +37,6 @@ def test_simple():
expected = dict(
sources=dict(
test=dict(
type="url",
sha256=None,
url="https://example.com",
version="0.0.0",
@ -77,13 +76,11 @@ def test_multiple_requested():
expected = dict(
sources=dict(
foo=dict(
type="url",
sha256=None,
url="https://example.com",
version="0.0.0",
),
bar=dict(
type="url",
sha256=None,
url="https://example.com",
version="0.0.0",

View File

@ -9,11 +9,7 @@ def test_path_in_repo_root(monkeypatch, git_repo_path):
return git_repo_path
monkeypatch.setattr(l, "repo_root", repo_root)
assert l.lock_info_from_path(git_repo_path / "foo") == {
"type": "url",
"url": "foo",
"sha256": None,
}
assert l.lock_info_from_path(git_repo_path / "foo") == ("foo", None)
def test_path_not_in_store_or_repo():
@ -40,8 +36,7 @@ def test_path_is_fod_output(monkeypatch):
)
monkeypatch.setattr(l, "nix_show_derivation", nix_show_derivation)
assert l.lock_info_from_path(Path(fod_store_path)) == {
"type": "url",
"url": "https://example.com",
"sha256": "3a3f9b030dcb0974ef85969c37f570349df9d74fb8abf34ed86fc5aae0bef42b",
}
assert l.lock_info_from_path(Path(fod_store_path)) == (
"https://example.com",
"3a3f9b030dcb0974ef85969c37f570349df9d74fb8abf34ed86fc5aae0bef42b",
)