treewide: upgrade npins to support lfs
this has the side effect of making the root site's favicon work
This commit is contained in:
+141
-28
@@ -9,8 +9,15 @@
|
|||||||
*/
|
*/
|
||||||
# Generated by npins. Do not modify; will be overwritten regularly
|
# Generated by npins. Do not modify; will be overwritten regularly
|
||||||
let
|
let
|
||||||
data = builtins.fromJSON (builtins.readFile ./sources.json);
|
# Backwards-compatibly make something that previously didn't take any arguments take some
|
||||||
version = data.version;
|
# The function must return an attrset, and will unfortunately be eagerly evaluated
|
||||||
|
# Same thing, but it catches eval errors on the default argument so that one may still call it with other arguments
|
||||||
|
mkFunctor =
|
||||||
|
fn:
|
||||||
|
let
|
||||||
|
e = builtins.tryEval (fn { });
|
||||||
|
in
|
||||||
|
(if e.success then e.value else { error = fn { }; }) // { __functor = _self: fn; };
|
||||||
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
||||||
range =
|
range =
|
||||||
@@ -21,7 +28,6 @@ let
|
|||||||
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||||
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||||
concatMapStrings = f: list: concatStrings (map f list);
|
|
||||||
concatStrings = builtins.concatStringsSep "";
|
concatStrings = builtins.concatStringsSep "";
|
||||||
|
|
||||||
# If the environment variable NPINS_OVERRIDE_${name} is set, then use
|
# If the environment variable NPINS_OVERRIDE_${name} is set, then use
|
||||||
@@ -48,41 +54,90 @@ let
|
|||||||
|
|
||||||
mkSource =
|
mkSource =
|
||||||
name: spec:
|
name: spec:
|
||||||
|
{
|
||||||
|
pkgs ? null,
|
||||||
|
}:
|
||||||
assert spec ? type;
|
assert spec ? type;
|
||||||
let
|
let
|
||||||
|
# Unify across builtin and pkgs fetchers.
|
||||||
|
# `fetchGit` requires a wrapper because of slight API differences.
|
||||||
|
fetchers =
|
||||||
|
if pkgs == null then
|
||||||
|
{
|
||||||
|
inherit (builtins) fetchTarball fetchurl;
|
||||||
|
# Frustratingly, due to flakes and `fetchTree`, `fetchGit`
|
||||||
|
# has a different signature than the other builtin
|
||||||
|
# fetchers
|
||||||
|
fetchGit = args: (builtins.fetchGit args).outPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fetchTarball =
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
sha256,
|
||||||
|
}:
|
||||||
|
pkgs.fetchzip {
|
||||||
|
inherit url sha256;
|
||||||
|
extension = "tar";
|
||||||
|
};
|
||||||
|
inherit (pkgs) fetchurl;
|
||||||
|
fetchGit =
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
submodules,
|
||||||
|
rev,
|
||||||
|
name,
|
||||||
|
lfs,
|
||||||
|
narHash,
|
||||||
|
}:
|
||||||
|
pkgs.fetchgit {
|
||||||
|
inherit url rev name lfs;
|
||||||
|
fetchSubmodules = submodules;
|
||||||
|
hash = narHash;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
path =
|
path =
|
||||||
if spec.type == "Git" then
|
if spec.type == "Git" then
|
||||||
mkGitSource spec
|
mkGitSource fetchers spec
|
||||||
else if spec.type == "GitRelease" then
|
else if spec.type == "GitRelease" then
|
||||||
mkGitSource spec
|
mkGitSource fetchers spec
|
||||||
else if spec.type == "PyPi" then
|
else if spec.type == "PyPi" then
|
||||||
mkPyPiSource spec
|
mkPyPiSource fetchers spec
|
||||||
else if spec.type == "Channel" then
|
else if spec.type == "Channel" then
|
||||||
mkChannelSource spec
|
mkChannelSource fetchers spec
|
||||||
else if spec.type == "Tarball" then
|
else if spec.type == "Url" || spec.type == "MutableUrl" then
|
||||||
mkTarballSource spec
|
mkUrlSource fetchers spec
|
||||||
|
else if spec.type == "Container" then
|
||||||
|
mkContainerSource pkgs spec
|
||||||
else
|
else
|
||||||
builtins.throw "Unknown source type ${spec.type}";
|
builtins.throw "Unknown source type ${spec.type}";
|
||||||
in
|
in
|
||||||
spec // { outPath = mayOverride name path; };
|
spec // { outPath = mayOverride name path; };
|
||||||
|
|
||||||
mkGitSource =
|
mkGitSource =
|
||||||
|
{
|
||||||
|
fetchTarball,
|
||||||
|
fetchGit,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
repository,
|
repository,
|
||||||
revision,
|
revision,
|
||||||
url ? null,
|
url ? null,
|
||||||
submodules,
|
submodules,
|
||||||
hash,
|
hash,
|
||||||
branch ? null,
|
lfs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
assert repository ? type;
|
assert repository ? type;
|
||||||
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
|
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
|
||||||
# In the latter case, there we will always be an url to the tarball
|
# In the latter case, there we will always be an url to the tarball
|
||||||
if url != null && !submodules then
|
if url != null && !submodules then
|
||||||
builtins.fetchTarball {
|
fetchTarball {
|
||||||
inherit url;
|
inherit url;
|
||||||
sha256 = hash; # FIXME: check nix version & use SRI hashes
|
sha256 = hash;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@@ -93,6 +148,8 @@ let
|
|||||||
"https://github.com/${repository.owner}/${repository.repo}.git"
|
"https://github.com/${repository.owner}/${repository.repo}.git"
|
||||||
else if repository.type == "GitLab" then
|
else if repository.type == "GitLab" then
|
||||||
"${repository.server}/${repository.repo_path}.git"
|
"${repository.server}/${repository.repo_path}.git"
|
||||||
|
else if repository.type == "Forgejo" then
|
||||||
|
"${repository.server}/${repository.owner}/${repository.repo}.git"
|
||||||
else
|
else
|
||||||
throw "Unrecognized repository type ${repository.type}";
|
throw "Unrecognized repository type ${repository.type}";
|
||||||
urlToName =
|
urlToName =
|
||||||
@@ -107,40 +164,96 @@ let
|
|||||||
"${if matched == null then "source" else builtins.head matched}${appendShort}";
|
"${if matched == null then "source" else builtins.head matched}${appendShort}";
|
||||||
name = urlToName url revision;
|
name = urlToName url revision;
|
||||||
in
|
in
|
||||||
builtins.fetchGit {
|
fetchGit {
|
||||||
rev = revision;
|
rev = revision;
|
||||||
inherit name;
|
narHash = hash;
|
||||||
# hash = hash;
|
|
||||||
inherit url submodules;
|
inherit name submodules url lfs;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkPyPiSource =
|
mkPyPiSource =
|
||||||
{ url, hash, ... }:
|
{ fetchurl, ... }:
|
||||||
builtins.fetchurl {
|
{
|
||||||
|
url,
|
||||||
|
hash,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
fetchurl {
|
||||||
inherit url;
|
inherit url;
|
||||||
sha256 = hash;
|
sha256 = hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkChannelSource =
|
mkChannelSource =
|
||||||
{ url, hash, ... }:
|
{ fetchTarball, ... }:
|
||||||
builtins.fetchTarball {
|
{
|
||||||
|
url,
|
||||||
|
hash,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
fetchTarball {
|
||||||
inherit url;
|
inherit url;
|
||||||
sha256 = hash;
|
sha256 = hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkTarballSource =
|
mkUrlSource =
|
||||||
|
{
|
||||||
|
fetchTarball,
|
||||||
|
fetchurl,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
url,
|
url,
|
||||||
locked_url ? url,
|
hash,
|
||||||
|
unpack,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
(if unpack then fetchTarball else fetchurl) {
|
||||||
|
inherit url;
|
||||||
|
sha256 = hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkContainerSource =
|
||||||
|
pkgs:
|
||||||
|
{
|
||||||
|
image_name,
|
||||||
|
image_tag,
|
||||||
|
image_digest,
|
||||||
hash,
|
hash,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
builtins.fetchTarball {
|
if pkgs == null then
|
||||||
url = locked_url;
|
builtins.throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers"
|
||||||
sha256 = hash;
|
else
|
||||||
|
pkgs.dockerTools.pullImage {
|
||||||
|
imageName = image_name;
|
||||||
|
imageDigest = image_digest;
|
||||||
|
finalImageTag = image_tag;
|
||||||
|
hash = hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
if version == 5 then
|
mkFunctor (
|
||||||
builtins.mapAttrs mkSource data.pins
|
{
|
||||||
else
|
input ? ./sources.json,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
data =
|
||||||
|
if builtins.isPath input then
|
||||||
|
# while `readFile` will throw an error anyways if the path doesn't exist,
|
||||||
|
# we still need to check beforehand because *our* error can be caught but not the one from the builtin
|
||||||
|
# See: <https://git.lix.systems/lix-project/lix/issues/1098>
|
||||||
|
if builtins.pathExists input then
|
||||||
|
builtins.fromJSON (builtins.readFile input)
|
||||||
|
else
|
||||||
|
throw "Input path ${toString input} does not exist"
|
||||||
|
else if builtins.isAttrs input then
|
||||||
|
input
|
||||||
|
else
|
||||||
|
throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset";
|
||||||
|
version = data.version;
|
||||||
|
in
|
||||||
|
if version == 8 then
|
||||||
|
builtins.mapAttrs (name: spec: mkFunctor (mkSource name spec)) data.pins
|
||||||
|
else
|
||||||
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
|
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
|
||||||
|
)
|
||||||
|
|||||||
+3
-2
@@ -8,10 +8,11 @@
|
|||||||
},
|
},
|
||||||
"branch": "main",
|
"branch": "main",
|
||||||
"submodules": false,
|
"submodules": false,
|
||||||
|
"lfs": true,
|
||||||
"revision": "b18dd7b863644debb0a843a5b21bb490bfe7d048",
|
"revision": "b18dd7b863644debb0a843a5b21bb490bfe7d048",
|
||||||
"url": null,
|
"url": null,
|
||||||
"hash": "18czfxaldy0zhjprdsqzxnzj3p9qlc4canwigr13iw2wisi4ww5y"
|
"hash": "sha256-xYH9RXYZDVotUW8fKIEC9u0GJeEg2nV/23aQlEyeQso="
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": 5
|
"version": 8
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-1
@@ -2,6 +2,26 @@
|
|||||||
{
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
npins' = pkgs.npins.overrideAttrs (
|
||||||
|
final: old: {
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "javalsai";
|
||||||
|
repo = "npins";
|
||||||
|
rev = "f3def7dfeecc16884cb0601f6c904d5142f47383";
|
||||||
|
hash = "sha256-ejeOGmDw+D4KddFJ5OAPradqoS+p2eAhhS4fOLQOWOk=";
|
||||||
|
};
|
||||||
|
|
||||||
|
cargoHash = null;
|
||||||
|
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
|
||||||
|
src = final.src;
|
||||||
|
hash = "sha256-mG4UClFBgiWBraWQ12N3CSyapaIpuXI9F8wQGwh/ooQ=";
|
||||||
|
};
|
||||||
|
|
||||||
|
cargoBuildFeatures = [ ];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
in
|
||||||
{
|
{
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
name = "configuration.nix";
|
name = "configuration.nix";
|
||||||
@@ -33,7 +53,7 @@
|
|||||||
jujutsu
|
jujutsu
|
||||||
nix-output-monitor
|
nix-output-monitor
|
||||||
nixfmt
|
nixfmt
|
||||||
npins
|
npins'
|
||||||
parted
|
parted
|
||||||
smartmontools
|
smartmontools
|
||||||
statix
|
statix
|
||||||
|
|||||||
Reference in New Issue
Block a user