diff --git a/nix/default.nix b/nix/default.nix index 399883b60..148ae442e 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -73,6 +73,8 @@ in stdenv.mkDerivation rec { configurePhase = '' patchShebangs . vendor/nimbus-build-system > /dev/null make nimbus-build-system-paths + # Generate ./vendor/.nimble dir structure + ./nix/generate-nimble-paths.sh ''; preBuild = '' diff --git a/nix/generate-nimble-paths.sh b/nix/generate-nimble-paths.sh new file mode 100755 index 000000000..24b2fa8b2 --- /dev/null +++ b/nix/generate-nimble-paths.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Output file to store the submodule paths +output_file="submodule_paths.txt" + +# Ensure the output file is empty before we start +> "$output_file" + +# Find all .gitmodules files and process them +find . -name .gitmodules | while read -r gitmodules_file; do + # Get the absolute directory path containing the .gitmodules file + module_dir=$(dirname "$(realpath "$gitmodules_file")") + + # Extract paths from the .gitmodules file + while IFS= read -r line; do + if [[ $line =~ path[[:space:]]*=[[:space:]]*(.*) ]]; then + submodule_path="${BASH_REMATCH[1]}" + # Write the absolute path of the submodule to the output file + echo "$module_dir/$submodule_path" >> "$output_file" + fi + done < "$gitmodules_file" +done + +echo "Submodule paths collected in $output_file" + +# Base directory for nimble packages +nimble_pkgs_dir="./vendor/.nimble/pkgs" + +# Ensure the base directory exists +mkdir -p "$nimble_pkgs_dir" + +# Read each submodule path and process it +while IFS= read -r submodule_path; do + # Extract the submodule name (last part of the path) + submodule_name=$(basename "$submodule_path") + + # Create the directory for the submodule + submodule_dir="$nimble_pkgs_dir/${submodule_name}-#head" + mkdir -p "$submodule_dir" + + # Create the .nimble-link file with the absolute path + nimble_link_file="$submodule_dir/${submodule_name}.nimble-link" + echo "$submodule_path" > "$nimble_link_file" + echo "$submodule_path" >> "$nimble_link_file" +done < "$output_file" + +echo "Nimble packages prepared in $nimble_pkgs_dir" \ No newline at end of file