From a4e4fc5d3565488b8720878dad19784d724a329f Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 12 Sep 2024 20:18:12 +0300 Subject: [PATCH] dotnetenv.{buildSolution,buildWrapper}: follow `editorconfig` & follow common bash style There seems to be duplication and also improvements to one between these, so someone should rework these. Add missing `pre` and `post` hook runs. --- .../dotnet/dotnetenv/build-solution.nix | 55 +++++++++---------- .../dotnet/dotnetenv/wrapper.nix | 30 +++++----- 2 files changed, 39 insertions(+), 46 deletions(-) diff --git a/pkgs/build-support/dotnet/dotnetenv/build-solution.nix b/pkgs/build-support/dotnet/dotnetenv/build-solution.nix index b3372b942177..9984db1cb2d3 100644 --- a/pkgs/build-support/dotnet/dotnetenv/build-solution.nix +++ b/pkgs/build-support/dotnet/dotnetenv/build-solution.nix @@ -31,41 +31,37 @@ stdenv.mkDerivation { ''; installPhase = '' - addDeps() - { - if [ -f $1/nix-support/dotnet-assemblies ] - then - for i in $(cat $1/nix-support/dotnet-assemblies) - do - windowsPath=$(cygpath --windows $i) - assemblySearchPaths="$assemblySearchPaths;$windowsPath" + runHook preInstall - addDeps $i - done - fi + addDeps() { + if [ -f $1/nix-support/dotnet-assemblies ]; then + for i in $(cat $1/nix-support/dotnet-assemblies); do + windowsPath=$(cygpath --windows $i) + assemblySearchPaths="$assemblySearchPaths;$windowsPath" + + addDeps $i + done + fi } - for i in ${toString assemblyInputs} - do - windowsPath=$(cygpath --windows $i) - echo "Using assembly path: $windowsPath" + for i in ${toString assemblyInputs}; do + windowsPath=$(cygpath --windows $i) + echo "Using assembly path: $windowsPath" - if [ "$assemblySearchPaths" = "" ] - then - assemblySearchPaths="$windowsPath" - else - assemblySearchPaths="$assemblySearchPaths;$windowsPath" - fi + if [ "$assemblySearchPaths" = "" ]; then + assemblySearchPaths="$windowsPath" + else + assemblySearchPaths="$assemblySearchPaths;$windowsPath" + fi - addDeps $i + addDeps $i done echo "Assembly search paths are: $assemblySearchPaths" - if [ "$assemblySearchPaths" != "" ] - then - echo "Using assembly search paths args: $assemblySearchPathsArg" - export AssemblySearchPaths=$assemblySearchPaths + if [ "$assemblySearchPaths" != "" ]; then + echo "Using assembly search paths args: $assemblySearchPathsArg" + export AssemblySearchPaths=$assemblySearchPaths fi mkdir -p $out @@ -77,9 +73,10 @@ stdenv.mkDerivation { mkdir -p $out/nix-support - for i in ${toString assemblyInputs} - do - echo $i >> $out/nix-support/dotnet-assemblies + for i in ${toString assemblyInputs}; do + echo $i >> $out/nix-support/dotnet-assemblies done + + runHook postInstall ''; } diff --git a/pkgs/build-support/dotnet/dotnetenv/wrapper.nix b/pkgs/build-support/dotnet/dotnetenv/wrapper.nix index 423303c3084a..549abd07e2b9 100644 --- a/pkgs/build-support/dotnet/dotnetenv/wrapper.nix +++ b/pkgs/build-support/dotnet/dotnetenv/wrapper.nix @@ -28,27 +28,23 @@ dotnetenv.buildSolution { slnFile = "Wrapper.sln"; assemblyInputs = [ application ]; preBuild = '' - addRuntimeDeps() - { - if [ -f $1/nix-support/dotnet-assemblies ] - then - for i in $(cat $1/nix-support/dotnet-assemblies) - do - windowsPath=$(cygpath --windows $i | sed 's|\\|\\\\|g') - assemblySearchArray="$assemblySearchArray @\"$windowsPath\"" + addRuntimeDeps() { + if [ -f $1/nix-support/dotnet-assemblies ]; then + for i in $(cat $1/nix-support/dotnet-assemblies); do + windowsPath=$(cygpath --windows $i | sed 's|\\|\\\\|g') + assemblySearchArray="$assemblySearchArray @\"$windowsPath\"" - addRuntimeDeps $i - done - fi + addRuntimeDeps $i + done + fi } export exePath=$(cygpath --windows $(find ${application} -name \*.exe) | sed 's|\\|\\\\|g') # Generate assemblySearchPaths string array contents - for path in ${toString assemblyInputs} - do - assemblySearchArray="$assemblySearchArray @\"$(cygpath --windows $path | sed 's|\\|\\\\|g')\", " - addRuntimeDeps $path + for path in ${toString assemblyInputs}; do + assemblySearchArray="$assemblySearchArray @\"$(cygpath --windows $path | sed 's|\\|\\\\|g')\", " + addRuntimeDeps $path done sed -e "s|@ROOTNAMESPACE@|${namespace}Wrapper|" \ @@ -57,8 +53,8 @@ dotnetenv.buildSolution { sed -e "s|@NAMESPACE@|${namespace}|g" \ -e "s|@MAINCLASSNAME@|${mainClassName}|g" \ - -e "s|@EXEPATH@|$exePath|g" \ - -e "s|@ASSEMBLYSEARCHPATH@|$assemblySearchArray|" \ + -e "s|@EXEPATH@|$exePath|g" \ + -e "s|@ASSEMBLYSEARCHPATH@|$assemblySearchArray|" \ Wrapper/Wrapper.cs.in > Wrapper/Wrapper.cs ''; }