aboutsummaryrefslogtreecommitdiffstats
path: root/npins/default.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 22:13:02 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 22:13:02 +0200
commit8345d17df4a353c62acb999805f1b7b1cc02d9ab (patch)
tree74ff60b3784b7e08aaa9eaa053a82c1c9f14dd69 /npins/default.nix
parentscripts/unflake.sh: Work around unflake not supporting npins v8 (diff)
downloadnixos-config-8345d17df4a353c62acb999805f1b7b1cc02d9ab.zip
treewide: Update
Diffstat (limited to 'npins/default.nix')
-rw-r--r--npins/default.nix45
1 files changed, 28 insertions, 17 deletions
diff --git a/npins/default.nix b/npins/default.nix
index 884fc8cc..8ec5eca6 100644
--- a/npins/default.nix
+++ b/npins/default.nix
@@ -65,7 +65,9 @@ let
if pkgs == null then
{
inherit (builtins) fetchTarball fetchurl;
- # For some fucking reason, fetchGit has a different signature than the other builtin fetchers …
+ # Frustratingly, due to flakes and `fetchTree`, `fetchGit`
+ # has a different signature than the other builtin
+ # fetchers
fetchGit = args: (builtins.fetchGit args).outPath;
}
else
@@ -95,7 +97,6 @@ let
};
};
- # Dispatch to the correct code path based on the type
path =
if spec.type == "Git" then
mkGitSource fetchers spec
@@ -105,8 +106,8 @@ let
mkPyPiSource fetchers spec
else if spec.type == "Channel" then
mkChannelSource fetchers spec
- else if spec.type == "Tarball" then
- mkTarballSource fetchers spec
+ else if spec.type == "Url" || spec.type == "MutableUrl" then
+ mkUrlSource fetchers spec
else if spec.type == "Container" then
mkContainerSource pkgs spec
else
@@ -192,16 +193,20 @@ let
sha256 = hash;
};
- mkTarballSource =
- { fetchTarball, ... }:
+ mkUrlSource =
+ {
+ fetchTarball,
+ fetchurl,
+ ...
+ }:
{
url,
- locked_url ? url,
hash,
+ unpack,
...
}:
- fetchTarball {
- url = locked_url;
+ (if unpack then fetchTarball else fetchurl) {
+ inherit url;
sha256 = hash;
};
@@ -211,16 +216,22 @@ let
image_name,
image_tag,
image_digest,
+ hash,
...
- }:
+ }@args:
if pkgs == null then
builtins.throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers"
else
- pkgs.dockerTools.pullImage {
- imageName = image_name;
- imageDigest = image_digest;
- finalImageTag = image_tag;
- };
+ pkgs.dockerTools.pullImage (
+ {
+ imageName = image_name;
+ imageDigest = image_digest;
+ finalImageTag = image_tag;
+ hash = hash;
+ }
+ // (if args.arch or null != null then { arch = args.arch; } else { })
+ );
+
in
mkFunctor (
{
@@ -231,7 +242,7 @@ mkFunctor (
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
- # *piegames sighs*
+ # See: <https://git.lix.systems/lix-project/lix/issues/1098>
if builtins.pathExists input then
builtins.fromJSON (builtins.readFile input)
else
@@ -242,7 +253,7 @@ mkFunctor (
throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset";
version = data.version;
in
- if version == 7 then
+ 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`"