From 033901dfd733162464cfd98b2cbd61ad47a077d5 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Wed, 27 Nov 2024 16:52:07 +0300 Subject: [PATCH] Nix: Fix name characters in prefetch. --- home/program/bash/module/Nix.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/home/program/bash/module/Nix.nix b/home/program/bash/module/Nix.nix index 0718297a..9f546589 100644 --- a/home/program/bash/module/Nix.nix +++ b/home/program/bash/module/Nix.nix @@ -51,13 +51,15 @@ # Usage: prefetch function prefetch() { local url="''${1}" + local name="''${1##*/}" + name=$(parse_alnum "''${name%%\?*}") if [[ "''${url}" = "" ]]; then help prefetch return 2 fi - local result=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url "''${url}")) + local result=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url --name "''${name}" "''${url}")) printf "%s" ''${result} | copy printf "%s\n" ''${result} }