mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-04-02 19:11:53 +00:00
Merge pull request #743 from Gerg-L/main
Some checks failed
Validate flake & check formatting / Validate Flake (push) Waiting to run
Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Check for typos in the source tree / check-typos (push) Has been cancelled
Some checks failed
Validate flake & check formatting / Validate Flake (push) Waiting to run
Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Check for typos in the source tree / check-typos (push) Has been cancelled
fix: Update npins version
This commit is contained in:
commit
4f92525672
2 changed files with 237 additions and 26 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,3 @@
|
||||||
# Based off of:
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/776c3bee4769c616479393aeefceefeda16b6fcb/pkgs/tools/nix/npins/source.nix
|
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
fetchurl,
|
fetchurl,
|
||||||
|
@ -8,7 +6,16 @@
|
||||||
}:
|
}:
|
||||||
builtins.mapAttrs
|
builtins.mapAttrs
|
||||||
(
|
(
|
||||||
_: let
|
name: let
|
||||||
|
getUrl = {
|
||||||
|
url,
|
||||||
|
hash,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
fetchurl {
|
||||||
|
inherit url;
|
||||||
|
sha256 = hash;
|
||||||
|
};
|
||||||
getZip = {
|
getZip = {
|
||||||
url,
|
url,
|
||||||
hash,
|
hash,
|
||||||
|
@ -23,19 +30,29 @@ builtins.mapAttrs
|
||||||
repository,
|
repository,
|
||||||
revision,
|
revision,
|
||||||
url ? null,
|
url ? null,
|
||||||
|
submodules,
|
||||||
hash,
|
hash,
|
||||||
...
|
...
|
||||||
} @ attrs:
|
} @ attrs:
|
||||||
assert repository ? type;
|
assert repository ? type;
|
||||||
if url != null
|
if url != null && !submodules
|
||||||
then getZip attrs
|
then getZip attrs
|
||||||
else
|
else
|
||||||
assert repository.type == "Git"; let
|
assert repository.type == "Git"; let
|
||||||
urlToName = url: rev: let
|
url' =
|
||||||
matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url;
|
if repository.type == "Git"
|
||||||
short = builtins.substring 0 7 rev;
|
then repository.url
|
||||||
|
else if repository.type == "GitHub"
|
||||||
|
then "https://github.com/${repository.owner}/${repository.repo}.git"
|
||||||
|
else if repository.type == "GitLab"
|
||||||
|
then "${repository.server}/${repository.repo_path}.git"
|
||||||
|
else throw "Unrecognized repository type ${repository.type}";
|
||||||
|
|
||||||
|
name = let
|
||||||
|
matched = builtins.match "^.*/([^/]*)(\\.git)?$" url';
|
||||||
|
short = builtins.substring 0 7 revision;
|
||||||
appendShort =
|
appendShort =
|
||||||
if (builtins.match "[a-f0-9]*" rev) != null
|
if (builtins.match "[a-f0-9]*" revision) != null
|
||||||
then "-${short}"
|
then "-${short}"
|
||||||
else "";
|
else "";
|
||||||
in "${
|
in "${
|
||||||
|
@ -43,43 +60,53 @@ builtins.mapAttrs
|
||||||
then "source"
|
then "source"
|
||||||
else builtins.head matched
|
else builtins.head matched
|
||||||
}${appendShort}";
|
}${appendShort}";
|
||||||
name = urlToName repository.url revision;
|
|
||||||
in
|
in
|
||||||
fetchgit {
|
fetchgit {
|
||||||
inherit name;
|
inherit name;
|
||||||
inherit (repository) url;
|
url = url';
|
||||||
rev = revision;
|
rev = revision;
|
||||||
sha256 = hash;
|
sha256 = hash;
|
||||||
|
fetchSubmodules = submodules;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkPyPiSource = {
|
|
||||||
url,
|
|
||||||
hash,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
fetchurl {
|
|
||||||
inherit url;
|
|
||||||
sha256 = hash;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
spec:
|
spec:
|
||||||
assert spec ? type; let
|
assert spec ? type; let
|
||||||
|
mayOverride = path: let
|
||||||
|
envVarName = "NPINS_OVERRIDE_${saneName}";
|
||||||
|
saneName = lib.stringAsChars (c:
|
||||||
|
if (builtins.match "[a-zA-Z0-9]" c) == null
|
||||||
|
then "_"
|
||||||
|
else c)
|
||||||
|
name;
|
||||||
|
ersatz = builtins.getEnv envVarName;
|
||||||
|
in
|
||||||
|
if ersatz == ""
|
||||||
|
then path
|
||||||
|
else
|
||||||
|
# this turns the string into an actual Nix path (for both absolute and
|
||||||
|
# relative paths)
|
||||||
|
builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" (
|
||||||
|
if builtins.substring 0 1 ersatz == "/"
|
||||||
|
then /. + ersatz
|
||||||
|
else /. + builtins.getEnv "PWD" + "/${ersatz}"
|
||||||
|
);
|
||||||
func =
|
func =
|
||||||
{
|
{
|
||||||
Git = mkGitSource;
|
Git = mkGitSource;
|
||||||
GitRelease = mkGitSource;
|
GitRelease = mkGitSource;
|
||||||
PyPi = mkPyPiSource;
|
PyPi = getUrl;
|
||||||
Channel = getZip;
|
Channel = getZip;
|
||||||
|
Tarball = getUrl;
|
||||||
}
|
}
|
||||||
.${spec.type}
|
.${spec.type}
|
||||||
or (builtins.throw "Unknown source type ${spec.type}");
|
or (builtins.throw "Unknown source type ${spec.type}");
|
||||||
in
|
in
|
||||||
spec // {outPath = func spec;}
|
spec // {outPath = mayOverride (func spec);}
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
let
|
let
|
||||||
json = lib.importJSON ./sources.json;
|
json = lib.importJSON ./sources.json;
|
||||||
in
|
in
|
||||||
assert lib.assertMsg (json.version == 3) "Npins version mismatch!";
|
assert lib.assertMsg (json.version == 5) "Npins version mismatch!";
|
||||||
json.pins
|
json.pins
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue