fork/nix-minecraft
git clone https://git.julia.blue/fork/nix-minecraft
ba3ae2b
develop
1{ lib } : 2lib . makeExtensible ( self : 3with lib ; 4with builtins ; 5rec { 6latestVersion = versions : 7last 8( sort versionOlder 9( filter 10( v :isList ( match "([[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?)" v )) 11( attrNames versions ))); 12 13escapeVersion = builtins . replaceStrings [ "." " " ] [ "_" "_" ]; 14 15removeVanilla = n :escapeVersion ( lib . removePrefix "vanilla-" n ); 16 17# Stolen from digga: https://github.com/divnix/digga/blob/587013b2500031b71959496764b6fdd1b2096f9a/src/importers.nix#L61-L114 18rakeLeaves = 19dirPath : 20let 21seive = file :type : 22# Only rake `.nix` files or directories 23( type == "regular" && lib . hasSuffix ".nix" file ) || ( type == "directory" ) 24; 25 26collect = file :type :{ 27name = lib . removeSuffix ".nix" file ; 28value = 29let 30path = dirPath + "/ ${ file } " ; 31in 32if ( type == "regular" ) 33|| ( type == "directory" && builtins . pathExists ( path + "/default.nix" )) 34then path 35# recurse on directories that don't contain a `default.nix` 36else rakeLeaves path ; 37}; 38 39files = lib . filterAttrs seive ( builtins . readDir dirPath ); 40in 41lib . filterAttrs ( n :v :v != { }) ( lib . mapAttrs' collect files ); 42})