From 1a7d76af304c664cb9070b3da3836d99889ee1a3 Mon Sep 17 00:00:00 2001 From: Mifom Date: Thu, 31 Mar 2022 12:47:41 +0300 Subject: [PATCH] Improve git deps parsing --- flake.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 202c9e8..d3a2d66 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,16 @@ (pkg: let - isGit = builtins.match ''git\+(.*)\?rev=([0-9a-f]+)(#.*)?'' pkg.source; + gitRegexp = x: builtins.match "git\+(.*)\?((branch=(.+)#([0-9a-f]+)(#.*)?)|(rev=([0-9a-f]+)(#.*)?))" x; + isGit = x: let gitArr = gitRegexp x; in + if isNull gitArr then + null + else + let url_ = builtins.elemAt gitArr 0; + url = builtins.substring 1 (builtins.stringLength url_ - 2) url_; + rev5 = builtins.elemAt gitArr 4; + rev8 = builtins.elemAt gitArr 7; + in if isNull rev5 then [url rev8] else [url rev5]; isRegistry = builtins.match ''registry\+(.*)'' pkg.source; in