From a0de0646f68f44d9f0d812092af02173fbfdefa9 Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Sun, 1 Feb 2026 16:38:45 -0500 Subject: [PATCH] npins: use mnw function --- flake.lock | 6 +- modules/wrapper/build/config.nix | 2 +- npins/sources.nix | 115 ------------------------------- 3 files changed, 4 insertions(+), 119 deletions(-) delete mode 100644 npins/sources.nix diff --git a/flake.lock b/flake.lock index 0a98f689..a7cdc255 100644 --- a/flake.lock +++ b/flake.lock @@ -38,11 +38,11 @@ }, "mnw": { "locked": { - "lastModified": 1768701608, - "narHash": "sha256-kSvWF3Xt2HW9hmV5V7i8PqeWJIBUKmuKoHhOgj3Znzs=", + "lastModified": 1769981889, + "narHash": "sha256-ndI7AxL/6auelkLHngdUGVImBiHkG8w2N2fOTKZKn4k=", "owner": "Gerg-L", "repo": "mnw", - "rev": "20d63a8a1ae400557c770052a46a9840e768926b", + "rev": "332fed8f43b77149c582f1782683d6aeee1f07cf", "type": "github" }, "original": { diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index 907983ed..72af1071 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -9,7 +9,7 @@ inherit (lib.trivial) flip; inherit (builtins) filter isString hasAttr getAttr; - getPin = flip getAttr (pkgs.callPackages ../../../npins/sources.nix {}); + getPin = flip getAttr (inputs.mnw.lib.npinsToPluginsAttrs pkgs ../../../npins/sources.json); # Build a Vim plugin with the given name and arguments. buildPlug = attrs: let diff --git a/npins/sources.nix b/npins/sources.nix deleted file mode 100644 index 0b09e232..00000000 --- a/npins/sources.nix +++ /dev/null @@ -1,115 +0,0 @@ -{ - lib, - fetchurl, - fetchgit, - fetchzip, -}: -builtins.mapAttrs -( - name: spec: let - mayOverride = name: path: let - envVarName = "NPINS_OVERRIDE_${saneName}"; - saneName = builtins.concatStringsSep "_" ( - builtins.concatLists ( - builtins.filter (x: builtins.isList x && x != [""]) (builtins.split "([a-zA-Z0-9]*)" 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}" - ); - - path = - rec { - GitRelease = Git; - Channel = Tarball; - - Git = - if spec.url != null && !spec.submodules - then Tarball - else - fetchgit ( - let - repo = spec.repository; - url = - { - Git = repo.url; - GitHub = "https://github.com/${repo.owner}/${repo.repo}.git"; - GitLab = "${repo.server}/${repo.repo_path}.git"; - Forgejo = "${repo.server}/${repo.owner}/${repo.repo}.git"; - } - .${ - repo.type - } or (throw "Unrecognized repository type ${repo.type}"); - in { - name = let - matched = builtins.match "^.*/([^/]*)(\\.git)?$" url; - appendShort = - if (builtins.match "[a-f0-9]*" spec.revision) != null - then "-${builtins.substring 0 7 spec.revision}" - else ""; - in "${ - if matched == null - then "source" - else builtins.head matched - }${appendShort}"; - inherit url; - - rev = spec.revision; - inherit (spec) hash; - fetchSubmodules = spec.submodules; - } - ); - - PyPi = fetchurl { - inherit (spec) url hash; - }; - - Tarball = fetchzip { - inherit (spec) url hash; - extension = "tar"; - }; - } - .${ - spec.type - } or (builtins.throw "Unknown source type ${spec.type}"); - - version = - if spec ? revision - then builtins.substring 0 8 spec.revision - else "0"; - in - spec - // { - name = "${name}-${version}"; - pname = name; - inherit version; - outPath = - ( - # Override logic won't do anything if we're in pure eval - if builtins ? currentSystem - then mayOverride name path - else path - ).overrideAttrs - { - pname = name; - name = "${name}-${version}"; - inherit version; - }; - } -) -( - let - json = lib.importJSON ./sources.json; - in - assert lib.assertMsg (json.version == 7) "Unsupported format version ${toString json.version} in sources.json. Try running `npins upgrade`"; - json.pins -)