Skip to content

Commit

Permalink
also handle flake urls without deeper attr paths
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Oct 12, 2023
1 parent 51d05be commit b197e22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
outputs = inputs: let
inherit (builtins) fromJSON readFile fetchClosure attrValues;
inherit (import ./lib.nix) filterAttrs symlinkPath sane mapAndMergeAttrs aggregate optionalAttr;
inherit (import ./lib.nix) filterAttrs symlinkPath sane mapAndMergeAttrs aggregate optionalAttr last;

# This is a really verbose name, but it ensures we don't get collisions
nameOf = flakeUrl: pkg: let
parts = builtins.split "\\." flakeUrl;
name = builtins.elemAt parts ((builtins.length parts) - 1);
fragment = builtins.split "#" flakeUrl;
parts = builtins.split "\\." (last fragment);
name = last parts;
in
sane "${name}-${pkg.org_name}-${pkg.repo_name}-${pkg.version}";

Expand Down
4 changes: 3 additions & 1 deletion lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ let
if hasAttr name attrs
then {${name} = attrs.${name};}
else {};

last = list: elemAt list ((length list) - 1);
in {
inherit filterAttrs mapAndMergeAttrs sane symlinkPath aggregate optionalAttr;
inherit filterAttrs mapAndMergeAttrs sane symlinkPath aggregate optionalAttr last;
}

0 comments on commit b197e22

Please sign in to comment.