From 275f78e40212aa97a2bb5d1126bca38c251c5e27 Mon Sep 17 00:00:00 2001 From: Samuel Shuert Date: Wed, 19 Nov 2025 20:48:10 +0000 Subject: [PATCH] fix: deadnix Change-Id: xksnzzzvllkyvrnlqkqmoopvxkmrntts --- .tangled/workflows/deadnix.yml | 2 +- packetmix/ci.nix | 41 +++++++++++----------- packetmix/homes/default.nix | 1 - packetmix/nilla.nix | 1 - packetmix/packages/OpenLinkHub/default.nix | 1 - packetmix/packages/kavita/default.nix | 1 - packetmix/systems/teal/vaultwarden.nix | 4 --- 7 files changed, 21 insertions(+), 30 deletions(-) diff --git a/.tangled/workflows/deadnix.yml b/.tangled/workflows/deadnix.yml index d4f557b5..9081d805 100644 --- a/.tangled/workflows/deadnix.yml +++ b/.tangled/workflows/deadnix.yml @@ -18,4 +18,4 @@ steps: command: | set -eo pipefail - deadnix --exclude **/npins --no-underscore --fail | ansifilter + deadnix --exclude **/npins --no-underscore --no-lambda-pattern-names --fail | ansifilter diff --git a/packetmix/ci.nix b/packetmix/ci.nix index cd297171..e95646bb 100644 --- a/packetmix/ci.nix +++ b/packetmix/ci.nix @@ -6,27 +6,26 @@ let base = import ./nilla.nix; project = base.extend { modules = [ - ( - { config, ... }: - { - config.inputs = ( - builtins.mapAttrs ( - _name: value: - if value ? settings.configuration.allowUnfree then - { - settings.configuration = { - allowUnfree = false; - allowUnfreePredicate = ( - x: (x ? meta.license) && (x.meta.license.shortName == "unfreeRedistributable") - ); # As we push to a public cachix, we can't use non-redistributable unfree software in CI - }; - } - else - { } - ) base.inputs - ); - } - ) + + { + config.inputs = ( + builtins.mapAttrs ( + _name: value: + if value ? settings.configuration.allowUnfree then + { + settings.configuration = { + allowUnfree = false; + allowUnfreePredicate = ( + x: (x ? meta.license) && (x.meta.license.shortName == "unfreeRedistributable") + ); # As we push to a public cachix, we can't use non-redistributable unfree software in CI + }; + } + else + { } + ) base.inputs + ); + } + { config.lib.ci = true; } diff --git a/packetmix/homes/default.nix b/packetmix/homes/default.nix index 7ef74466..81b8dc78 100644 --- a/packetmix/homes/default.nix +++ b/packetmix/homes/default.nix @@ -3,7 +3,6 @@ # # SPDX-License-Identifier: MIT -{ config, ... }: { config.homes."maya:x86_64-linux" = { modules = [ diff --git a/packetmix/nilla.nix b/packetmix/nilla.nix index ca134f81..8fe1cfe2 100644 --- a/packetmix/nilla.nix +++ b/packetmix/nilla.nix @@ -106,7 +106,6 @@ nilla.create ( { pkgs, system, - npins, mkShell, kdePackages, ... diff --git a/packetmix/packages/OpenLinkHub/default.nix b/packetmix/packages/OpenLinkHub/default.nix index ee310198..9e0fa644 100644 --- a/packetmix/packages/OpenLinkHub/default.nix +++ b/packetmix/packages/OpenLinkHub/default.nix @@ -1,7 +1,6 @@ # SPDX-FileCopyrightText: 2025 FreshlyBakedCake # # SPDX-License-Identifier: MIT -{ config, ... }: { config.packages.openlinkhub = { systems = [ "x86_64-linux" ]; diff --git a/packetmix/packages/kavita/default.nix b/packetmix/packages/kavita/default.nix index 252f4f47..7779e512 100644 --- a/packetmix/packages/kavita/default.nix +++ b/packetmix/packages/kavita/default.nix @@ -2,7 +2,6 @@ # SPDX-FileCopyrightText: 2025 Nixpkgs Maintainers # # SPDX-License-Identifier: MIT -{ config, ... }: { config.packages.kavita = { systems = [ "x86_64-linux" ]; diff --git a/packetmix/systems/teal/vaultwarden.nix b/packetmix/systems/teal/vaultwarden.nix index 6c2ad23e..a60c2e62 100644 --- a/packetmix/systems/teal/vaultwarden.nix +++ b/packetmix/systems/teal/vaultwarden.nix @@ -2,10 +2,6 @@ # # SPDX-License-Identifier: MIT -{ - config, - ... -}: { services.vaultwarden = { enable = true; -- 2.43.0 From ad356df59ac39981b807d4c034b827b13ee31c56 Mon Sep 17 00:00:00 2001 From: Samuel Shuert Date: Wed, 5 Nov 2025 15:38:24 +0000 Subject: [PATCH] chore(npins): upgrade & update Change-Id: lsovxmttznrtuqlswrwvqwkuxmopluyp --- packetmix/npins/default.nix | 141 +++++++++++++++++++++---- packetmix/npins/sources.json | 111 ++++++++++--------- packetmix/systems/common/inputs.nix | 2 +- packetmix/systems/midnight/spindle.nix | 2 +- sprinkles/npins/default.nix | 141 +++++++++++++++++++++---- sprinkles/npins/sources.json | 26 ++--- 6 files changed, 311 insertions(+), 112 deletions(-) diff --git a/packetmix/npins/default.nix b/packetmix/npins/default.nix index fc9ebc56..b844b313 100644 --- a/packetmix/npins/default.nix +++ b/packetmix/npins/default.nix @@ -9,8 +9,15 @@ */ # Generated by npins. Do not modify; will be overwritten regularly let - data = builtins.fromJSON (builtins.readFile ./sources.json); - version = data.version; + # Backwards-compatibly make something that previously didn't take any arguments take some + # 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 range = @@ -21,7 +28,6 @@ let # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); concatStrings = builtins.concatStringsSep ""; # If the environment variable NPINS_OVERRIDE_${name} is set, then use @@ -48,39 +54,85 @@ let mkSource = name: spec: + { + pkgs ? null, + }: assert spec ? type; 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; + # For some fucking reason, 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, + narHash, + }: + pkgs.fetchgit { + inherit url rev name; + fetchSubmodules = submodules; + hash = narHash; + }; + }; + + # Dispatch to the correct code path based on the type path = if spec.type == "Git" then - mkGitSource spec + mkGitSource fetchers spec else if spec.type == "GitRelease" then - mkGitSource spec + mkGitSource fetchers spec else if spec.type == "PyPi" then - mkPyPiSource spec + mkPyPiSource fetchers spec else if spec.type == "Channel" then - mkChannelSource spec + mkChannelSource fetchers spec else if spec.type == "Tarball" then - mkTarballSource spec + mkTarballSource fetchers spec + else if spec.type == "Container" then + mkContainerSource pkgs spec else builtins.throw "Unknown source type ${spec.type}"; in spec // { outPath = mayOverride name path; }; mkGitSource = + { + fetchTarball, + fetchGit, + ... + }: { repository, revision, url ? null, submodules, hash, - branch ? null, ... }: assert repository ? type; # 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 if url != null && !submodules then - builtins.fetchTarball { + fetchTarball { inherit url; sha256 = hash; } @@ -107,7 +159,7 @@ let "${if matched == null then "source" else builtins.head matched}${appendShort}"; name = urlToName url revision; in - builtins.fetchGit { + fetchGit { rev = revision; narHash = hash; @@ -115,32 +167,81 @@ let }; mkPyPiSource = - { url, hash, ... }: - builtins.fetchurl { + { fetchurl, ... }: + { + url, + hash, + ... + }: + fetchurl { inherit url; sha256 = hash; }; mkChannelSource = - { url, hash, ... }: - builtins.fetchTarball { + { fetchTarball, ... }: + { + url, + hash, + ... + }: + fetchTarball { inherit url; sha256 = hash; }; mkTarballSource = + { fetchTarball, ... }: { url, locked_url ? url, hash, ... }: - builtins.fetchTarball { + fetchTarball { url = locked_url; sha256 = hash; }; + + mkContainerSource = + pkgs: + { + image_name, + image_tag, + image_digest, + ... + }: + 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; + }; in -if version == 6 then - builtins.mapAttrs mkSource data.pins -else - throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" +mkFunctor ( + { + 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 + # *piegames sighs* + 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 == 7 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`" +) diff --git a/packetmix/npins/sources.json b/packetmix/npins/sources.json index f6321cac..f8031134 100644 --- a/packetmix/npins/sources.json +++ b/packetmix/npins/sources.json @@ -61,9 +61,9 @@ }, "branch": "main", "submodules": false, - "revision": "c518cf4f62659d9cf585da6f29b67f8a77d0fbc0", - "url": "https://github.com/bluesky-social/atproto/archive/c518cf4f62659d9cf585da6f29b67f8a77d0fbc0.tar.gz", - "hash": "sha256-fW9BKtG9vptNYzCh/AWf8m9QoPEGX6najSFlAekElHA=" + "revision": "3628cebfbb04ba49f326bbf411a2d15de2900302", + "url": "https://github.com/bluesky-social/atproto/archive/3628cebfbb04ba49f326bbf411a2d15de2900302.tar.gz", + "hash": "sha256-5udskm8sOQ73VukP6bweE0rNxW8YG9so8Gk93x9Dzzs=" }, "catppuccin": { "type": "Git", @@ -88,9 +88,9 @@ }, "branch": "master", "submodules": false, - "revision": "8395ec4576cf54411d974675d26f64208acdcee0", - "url": "https://gitlab.collabora.com/api/v4/projects/collabora%2Fgtimelog/repository/archive.tar.gz?sha=8395ec4576cf54411d974675d26f64208acdcee0", - "hash": "sha256-M9pCF+XVf5ylxgq0BSUn5Vkg1HZ6i88LDiUDM4Y1Ghs=" + "revision": "1be9d9f7e844831f221b67a46a55fc47a164e416", + "url": "https://gitlab.collabora.com/api/v4/projects/collabora%2Fgtimelog/repository/archive.tar.gz?sha=1be9d9f7e844831f221b67a46a55fc47a164e416", + "hash": "sha256-v5WEa7M0mmrxdU1l7nIqyrMaVy2jiJNnXHLiHnw2xIc=" }, "copyparty": { "type": "GitRelease", @@ -103,10 +103,10 @@ "version_upper_bound": null, "release_prefix": null, "submodules": false, - "version": "v1.19.17", - "revision": "e2a15a3a922514efe97afc4afa043cd7c4619ad1", - "url": "https://api.github.com/repos/9001/copyparty/tarball/refs/tags/v1.19.17", - "hash": "sha256-Rb6Lq2CW+LrIH8M4sCPA8k12GX7xNUWK4I+xeByLl+M=" + "version": "v1.19.20", + "revision": "450cd86dc1e98b98ab131fc9417c83289165a507", + "url": "https://api.github.com/repos/9001/copyparty/tarball/refs/tags/v1.19.20", + "hash": "sha256-/Wm8hZvdGfYWdTOF+dgTPX8DGuSKLhGw4qC4crf1dAo=" }, "headscale": { "type": "Git", @@ -117,9 +117,9 @@ }, "branch": "main", "submodules": false, - "revision": "8010cc574ea309728f5c7d3fd1cb08252f0111f5", - "url": "https://github.com/juanfont/headscale/archive/8010cc574ea309728f5c7d3fd1cb08252f0111f5.tar.gz", - "hash": "sha256-lQhaw7SVV+qBEZnH8u+gsEwqIByFlZQyjDJ3RbW7uzM=" + "revision": "21af106f68fa38f37d80c9ac91a336a4f53bc074", + "url": "https://github.com/juanfont/headscale/archive/21af106f68fa38f37d80c9ac91a336a4f53bc074.tar.gz", + "hash": "sha256-EGLIiL/80bf6e5P5oDcG7zw7fMpOK5jIALd8rmu6Jv8=" }, "home-manager": { "type": "Git", @@ -143,9 +143,9 @@ }, "branch": "master", "submodules": false, - "revision": "189c21cf879669008ccf06e78a553f17e88d8ef0", - "url": "https://github.com/nix-community/home-manager/archive/189c21cf879669008ccf06e78a553f17e88d8ef0.tar.gz", - "hash": "sha256-nZh6uvc71nVNaf/y+wesnjwsmJ6IZZUnP2EzpZe48To=" + "revision": "827f2a23373a774a8805f84ca5344654c31f354b", + "url": "https://github.com/nix-community/home-manager/archive/827f2a23373a774a8805f84ca5344654c31f354b.tar.gz", + "hash": "sha256-RYHN8O/Aja59XDji6WSJZPkJpYVUfpSkyH+PEupBJqM=" }, "impermanence": { "type": "Git", @@ -171,10 +171,10 @@ "version_upper_bound": null, "release_prefix": null, "submodules": false, - "version": "v0.4.2", - "revision": "f0212638a2ec787a7841882f4477d40ae24f0a5d", - "url": "https://api.github.com/repos/nix-community/lanzaboote/tarball/refs/tags/v0.4.2", - "hash": "sha256-AEEDktApTEZ5PZXNDkry2YV2k6t0dTgLPEmAZbnigXU=" + "version": "v0.4.3", + "revision": "65a4aa3d4dccf50f22c0190c7ee660de51c586f2", + "url": "https://api.github.com/repos/nix-community/lanzaboote/tarball/refs/tags/v0.4.3", + "hash": "sha256-If6vQ+KvtKs3ARBO9G3l+4wFSCYtRBrwX1z+I+B61wQ=" }, "lix": { "type": "Git", @@ -186,9 +186,9 @@ }, "branch": "main", "submodules": false, - "revision": "2d2cd7ac03311bddb9645a7ab82c7e78edccbaa0", - "url": "https://git.lix.systems/lix-project/lix/archive/2d2cd7ac03311bddb9645a7ab82c7e78edccbaa0.tar.gz", - "hash": "sha256-jUn34QOaXqguaH+WwB2xWRHlmelvzJfFuEcQrC1cwK0=" + "revision": "2fa40c9de49e47c1f59dd32bf99227884bad3a2d", + "url": "https://git.lix.systems/lix-project/lix/archive/2fa40c9de49e47c1f59dd32bf99227884bad3a2d.tar.gz", + "hash": "sha256-2SAAMUhS1rH2J0elOJZLAbU6KjQ1r6vEWrRFeIaVDzM=" }, "lix-module": { "type": "Git", @@ -200,9 +200,9 @@ }, "branch": "main", "submodules": false, - "revision": "7c31a18259b8358ac196cf803a26967c0fa1d3e4", - "url": "https://git.lix.systems/lix-project/nixos-module/archive/7c31a18259b8358ac196cf803a26967c0fa1d3e4.tar.gz", - "hash": "sha256-n5dRAIC3/78drQtFxmQRrBLd6TKfotUnX7GWu0mAcSg=" + "revision": "c47f62187601ea2991b79a9bacdbfdf76cd29fbe", + "url": "https://git.lix.systems/lix-project/nixos-module/archive/c47f62187601ea2991b79a9bacdbfdf76cd29fbe.tar.gz", + "hash": "sha256-FvuAw56NIVJpS3Kr8Wv9PpU4eehZMcdIVkxjStuYmqc=" }, "lua-multipart": { "type": "GitRelease", @@ -221,20 +221,17 @@ "hash": "sha256-CWQf76/SQEHYX0Xv1UudA4RJtZsMpLY+IU8vjlqnsQY=" }, "nilla": { - "type": "GitRelease", + "type": "Git", "repository": { "type": "GitHub", "owner": "nilla-nix", "repo": "nilla" }, - "pre_releases": true, - "version_upper_bound": null, - "release_prefix": null, + "branch": "private/coded/push-nzprlvpltxyl", "submodules": false, - "version": "v0.0.0-alpha.14", - "revision": "2e98ae315a592ad6b6de44670514c048dcc88dc7", - "url": "https://api.github.com/repos/nilla-nix/nilla/tarball/refs/tags/v0.0.0-alpha.14", - "hash": "sha256-15lwhWcMonJH6UholMMHDc+p2BoSpGA4AYGrsXQA9Do=" + "revision": "2f8b8c68efc4d81637be344d1b01462291a45e05", + "url": "https://github.com/nilla-nix/nilla/archive/2f8b8c68efc4d81637be344d1b01462291a45e05.tar.gz", + "hash": "sha256-VLlP6L8uvgEjb1ZZXdc4P3NAs5PcgIjpGm8LvaObrLY=" }, "nilla-cli": { "type": "Git", @@ -245,9 +242,9 @@ }, "branch": "main", "submodules": false, - "revision": "6c6c42eaae3d095de6d1b47396c8b74ea57cb442", - "url": "https://github.com/nilla-nix/cli/archive/6c6c42eaae3d095de6d1b47396c8b74ea57cb442.tar.gz", - "hash": "sha256-0+d6LZfofBG+4OxnZcFaNg2ycgj1zcOJQUcPL1TEaSc=" + "revision": "aa042dbd9152c99e5a8db51bcf87306737423b9e", + "url": "https://github.com/nilla-nix/cli/archive/aa042dbd9152c99e5a8db51bcf87306737423b9e.tar.gz", + "hash": "sha256-cPdYYXhCsDllVgq+gs5Wqhb41bFtKWHlkTvjOJv7its=" }, "nilla-home": { "type": "GitRelease", @@ -287,9 +284,9 @@ }, "branch": "main", "submodules": false, - "revision": "f851a923137c0a54719412146fd63d24b3214e60", - "url": "https://github.com/sodiboo/niri-flake/archive/f851a923137c0a54719412146fd63d24b3214e60.tar.gz", - "hash": "sha256-E2ySTu/oK7cYBdAI3tlGP9zVjF4mZgWJ1OZInBCMb00=" + "revision": "add7bcf2925547e180cc2fe6d5f4b5e7c579d086", + "url": "https://github.com/sodiboo/niri-flake/archive/add7bcf2925547e180cc2fe6d5f4b5e7c579d086.tar.gz", + "hash": "sha256-LVYJJObvkWwR8QB/Srr6Rks+Fw2lYvnRNOH0etV9DM8=" }, "nix-index-database": { "type": "Git", @@ -300,9 +297,9 @@ }, "branch": "main", "submodules": false, - "revision": "5024e1901239a76b7bf94a4cd27f3507e639d49e", - "url": "https://github.com/nix-community/nix-index-database/archive/5024e1901239a76b7bf94a4cd27f3507e639d49e.tar.gz", - "hash": "sha256-xmU8kAsRprJiTGBTaGrwmjBP3AMA9ltlrxHKFuy5JWc=" + "revision": "15c5451c63f4c612874a43846bfe3fa828b03eee", + "url": "https://github.com/nix-community/nix-index-database/archive/15c5451c63f4c612874a43846bfe3fa828b03eee.tar.gz", + "hash": "sha256-C9F1C31ys0V7mnp4EcDy7L1cLZw/sCTEXqqTtGnvu08=" }, "nix-monitored": { "type": "Git", @@ -320,14 +317,14 @@ "nixos-unstable": { "type": "Channel", "name": "nixos-unstable", - "url": "https://releases.nixos.org/nixos/unstable/nixos-25.11pre880095.5e2a59a5b1a8/nixexprs.tar.xz", - "hash": "sha256-u0JUo46QSoXnjLaezAM75wRNuxVMVbm5OxHH122TeTY=" + "url": "https://releases.nixos.org/nixos/unstable/nixos-25.11pre895122.c5ae371f1a6a/nixexprs.tar.xz", + "hash": "sha256-ofLW/pWU9HuZO43hK0ze2uTITgG5NWUws6ePJrazSlM=" }, "nixpkgs": { "type": "Channel", "name": "nixos-25.05", - "url": "https://releases.nixos.org/nixos/25.05/nixos-25.05.811497.33c6dca0c0cb/nixexprs.tar.xz", - "hash": "sha256-Z7kbKnORypPkJ74r6sHA2RQH1XATHLWiGgZVrli0scY=" + "url": "https://releases.nixos.org/nixos/25.05/nixos-25.05.812778.3acb677ea67d/nixexprs.tar.xz", + "hash": "sha256-79T1mnDzWNjktwvynnm0ptFJW5qVfuzavIRDCzKFiZ8=" }, "npins": { "type": "Git", @@ -363,9 +360,9 @@ }, "branch": "master", "submodules": false, - "revision": "7d1888abf8c5b82692476a9de2137a024d484771", + "revision": "3eb9cefd98d13ab9864abb2e394fc41f89ffd923", "url": null, - "hash": "sha256-WD/UFUMcXMV/3tqD4h2tPaQH1KDlsJ00M+T4N/xkAGs=" + "hash": "sha256-lRTZLRcqWpVf6CzJmvg+ggp/YWWasT4u2lFKIiIopoM=" }, "treefmt-nix": { "type": "Git", @@ -376,9 +373,9 @@ }, "branch": "main", "submodules": false, - "revision": "f56b1934f5f8fcab8deb5d38d42fd692632b47c2", - "url": "https://github.com/numtide/treefmt-nix/archive/f56b1934f5f8fcab8deb5d38d42fd692632b47c2.tar.gz", - "hash": "sha256-ZRVs8UqikBa4Ki3X4KCnMBtBW0ux1DaT35tgsnB1jM4=" + "revision": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4", + "url": "https://github.com/numtide/treefmt-nix/archive/5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4.tar.gz", + "hash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=" }, "walker": { "type": "GitRelease", @@ -391,11 +388,11 @@ "version_upper_bound": null, "release_prefix": null, "submodules": false, - "version": "v2.5.5", - "revision": "ff292cb12c4816ce21dab47cd9894b8046b16a93", - "url": "https://api.github.com/repos/abenz1267/walker/tarball/refs/tags/v2.5.5", - "hash": "sha256-xc0yW9OhLTppjkaWWCWG9q4BVJZbhnLqLniLeMkcTvM=" + "version": "v2.10.0", + "revision": "ce131301bbbdecde37bf76bf8478e8af06ff3792", + "url": "https://api.github.com/repos/abenz1267/walker/tarball/refs/tags/v2.10.0", + "hash": "sha256-72+WE0RGSW8TgzPijHU6TtLWfMb0G7ojraM5UifTLVg=" } }, - "version": 6 + "version": 7 } diff --git a/packetmix/systems/common/inputs.nix b/packetmix/systems/common/inputs.nix index 96f5efbc..609b6cec 100644 --- a/packetmix/systems/common/inputs.nix +++ b/packetmix/systems/common/inputs.nix @@ -26,5 +26,5 @@ builtins.storePath value.result else builtins.storePath value.src; - }) project.inputs; + }) (lib.attrsets.filterAttrs (n: _: n != "__functor") project.inputs); } diff --git a/packetmix/systems/midnight/spindle.nix b/packetmix/systems/midnight/spindle.nix index c1ce39ee..ddbe77a4 100644 --- a/packetmix/systems/midnight/spindle.nix +++ b/packetmix/systems/midnight/spindle.nix @@ -13,7 +13,7 @@ networking.firewall.allowedTCPPorts = [ 1024 ]; - services.tangled-spindle = { + services.tangled.spindle = { enable = true; server = { listenAddr = "0.0.0.0:1024"; diff --git a/sprinkles/npins/default.nix b/sprinkles/npins/default.nix index fc9ebc56..b844b313 100644 --- a/sprinkles/npins/default.nix +++ b/sprinkles/npins/default.nix @@ -9,8 +9,15 @@ */ # Generated by npins. Do not modify; will be overwritten regularly let - data = builtins.fromJSON (builtins.readFile ./sources.json); - version = data.version; + # Backwards-compatibly make something that previously didn't take any arguments take some + # 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 range = @@ -21,7 +28,6 @@ let # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); concatStrings = builtins.concatStringsSep ""; # If the environment variable NPINS_OVERRIDE_${name} is set, then use @@ -48,39 +54,85 @@ let mkSource = name: spec: + { + pkgs ? null, + }: assert spec ? type; 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; + # For some fucking reason, 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, + narHash, + }: + pkgs.fetchgit { + inherit url rev name; + fetchSubmodules = submodules; + hash = narHash; + }; + }; + + # Dispatch to the correct code path based on the type path = if spec.type == "Git" then - mkGitSource spec + mkGitSource fetchers spec else if spec.type == "GitRelease" then - mkGitSource spec + mkGitSource fetchers spec else if spec.type == "PyPi" then - mkPyPiSource spec + mkPyPiSource fetchers spec else if spec.type == "Channel" then - mkChannelSource spec + mkChannelSource fetchers spec else if spec.type == "Tarball" then - mkTarballSource spec + mkTarballSource fetchers spec + else if spec.type == "Container" then + mkContainerSource pkgs spec else builtins.throw "Unknown source type ${spec.type}"; in spec // { outPath = mayOverride name path; }; mkGitSource = + { + fetchTarball, + fetchGit, + ... + }: { repository, revision, url ? null, submodules, hash, - branch ? null, ... }: assert repository ? type; # 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 if url != null && !submodules then - builtins.fetchTarball { + fetchTarball { inherit url; sha256 = hash; } @@ -107,7 +159,7 @@ let "${if matched == null then "source" else builtins.head matched}${appendShort}"; name = urlToName url revision; in - builtins.fetchGit { + fetchGit { rev = revision; narHash = hash; @@ -115,32 +167,81 @@ let }; mkPyPiSource = - { url, hash, ... }: - builtins.fetchurl { + { fetchurl, ... }: + { + url, + hash, + ... + }: + fetchurl { inherit url; sha256 = hash; }; mkChannelSource = - { url, hash, ... }: - builtins.fetchTarball { + { fetchTarball, ... }: + { + url, + hash, + ... + }: + fetchTarball { inherit url; sha256 = hash; }; mkTarballSource = + { fetchTarball, ... }: { url, locked_url ? url, hash, ... }: - builtins.fetchTarball { + fetchTarball { url = locked_url; sha256 = hash; }; + + mkContainerSource = + pkgs: + { + image_name, + image_tag, + image_digest, + ... + }: + 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; + }; in -if version == 6 then - builtins.mapAttrs mkSource data.pins -else - throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" +mkFunctor ( + { + 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 + # *piegames sighs* + 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 == 7 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`" +) diff --git a/sprinkles/npins/sources.json b/sprinkles/npins/sources.json index 498de1be..921a98bf 100644 --- a/sprinkles/npins/sources.json +++ b/sprinkles/npins/sources.json @@ -9,9 +9,9 @@ }, "branch": "monthly", "submodules": false, - "revision": "f44d7c3596ff028ad9f7fcc31d1941ed585f11b3", - "url": "https://github.com/nix-community/fenix/archive/f44d7c3596ff028ad9f7fcc31d1941ed585f11b3.tar.gz", - "hash": "sha256-6RzWfxENGlO73jQb3uQNgOvubUFwvveeIg+PZxhAu6s=" + "revision": "3107255abfe4f2d1c3eee7a3e2f5a5eb6f2200fe", + "url": "https://github.com/nix-community/fenix/archive/3107255abfe4f2d1c3eee7a3e2f5a5eb6f2200fe.tar.gz", + "hash": "sha256-isqMvjTk3jdTHN6KA/BWQvOSVe7O35OQKAZNtLK76OY=" }, "nilla": { "type": "Git", @@ -22,9 +22,9 @@ }, "branch": "main", "submodules": false, - "revision": "4e6038f4ebc89487194013af6a1e077dfeb00359", - "url": "https://github.com/nilla-nix/nilla/archive/4e6038f4ebc89487194013af6a1e077dfeb00359.tar.gz", - "hash": "sha256-7iLzbTLtgdFtm9em3xxHO9BunN2YpgYquMLKXh5hEpQ=" + "revision": "b617bdbaa5faa9345ca077cd497372ece77bf119", + "url": "https://github.com/nilla-nix/nilla/archive/b617bdbaa5faa9345ca077cd497372ece77bf119.tar.gz", + "hash": "sha256-eCKqHY7uUiNqmP0XqWlXxpBLABuk65MRPLH2INFEE5U=" }, "nixpkgs": { "type": "Git", @@ -35,9 +35,9 @@ }, "branch": "nixos-unstable", "submodules": false, - "revision": "a84ebe20c6bc2ecbcfb000a50776219f48d134cc", - "url": "https://github.com/nixos/nixpkgs/archive/a84ebe20c6bc2ecbcfb000a50776219f48d134cc.tar.gz", - "hash": "sha256-mNqIplmEohk5jRkqYqG19GA8MbQ/D4gQSK0Mu4LvfRQ=" + "revision": "ae814fd3904b621d8ab97418f1d0f2eb0d3716f4", + "url": "https://github.com/nixos/nixpkgs/archive/ae814fd3904b621d8ab97418f1d0f2eb0d3716f4.tar.gz", + "hash": "sha256-YRqMDEtSMbitIMj+JLpheSz0pwEr0Rmy5mC7myl17xs=" }, "quickshell": { "type": "GitRelease", @@ -49,11 +49,11 @@ "version_upper_bound": null, "release_prefix": null, "submodules": false, - "version": "v0.2.0", - "revision": "a5431dd02dc23d9ef1680e67777fed00fe5f7cda", + "version": "v0.2.1", + "revision": "a1a150fab00a93ea983aaca5df55304bc837f51b", "url": null, - "hash": "sha256-vqkSDvh7hWhPvNjMjEDV4KbSCv2jyl2Arh73ZXe274k=" + "hash": "sha256-e++Ogy91Sv7gGLMdAqZaBzbH/UmPWZ4GAt7VDCA66aU=" } }, - "version": 6 + "version": 7 } -- 2.43.0