omnisharp-dotnet: use buildDotnetModule
This commit is contained in:
parent
c277bd86a5
commit
465d355e5b
|
@ -1,74 +0,0 @@
|
||||||
#!/usr/bin/env nix-shell
|
|
||||||
#!nix-shell -I nixpkgs=../../../.. -i bash -p dotnet-sdk_6 jq xmlstarlet curl
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
cat << EOL
|
|
||||||
{ fetchurl }: [
|
|
||||||
EOL
|
|
||||||
|
|
||||||
# enter a temporary directory containing the source code, copied from the derivation
|
|
||||||
srcdir="$(mktemp -d)"
|
|
||||||
cp -r "$(nix-build -A omnisharp-roslyn.src ../../../..)"/. "$srcdir"
|
|
||||||
rm -f "$srcdir"/global.json
|
|
||||||
|
|
||||||
pushd $srcdir >&2
|
|
||||||
|
|
||||||
tmpdir="$(mktemp -d -p "$(pwd)")" # must be under source root
|
|
||||||
|
|
||||||
mapfile -t repos < <(
|
|
||||||
xmlstarlet sel -t -v 'configuration/packageSources/add/@value' -n NuGet.Config |
|
|
||||||
while IFS= read index
|
|
||||||
do
|
|
||||||
curl --compressed -fsL "$index" | \
|
|
||||||
jq -r '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"'
|
|
||||||
done
|
|
||||||
)
|
|
||||||
|
|
||||||
dotnet msbuild -t:restore -p:Configuration=Release -p:RestorePackagesPath="$tmpdir" \
|
|
||||||
-p:RestoreNoCache=true -p:RestoreForce=true \
|
|
||||||
"$srcdir/src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj" >&2
|
|
||||||
|
|
||||||
cd "$tmpdir"
|
|
||||||
for package in *
|
|
||||||
do
|
|
||||||
cd "$package"
|
|
||||||
for version in *
|
|
||||||
do
|
|
||||||
found=false
|
|
||||||
for repo in "${repos[@]}"
|
|
||||||
do
|
|
||||||
url="$repo$package/$version/$package.$version.nupkg"
|
|
||||||
if curl -fsL "$url" -o /dev/null
|
|
||||||
then
|
|
||||||
found=true
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if ! $found
|
|
||||||
then
|
|
||||||
echo "couldn't find $package $version" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sha256=$(nix-prefetch-url "$url" 2>/dev/null)
|
|
||||||
cat << EOL
|
|
||||||
{
|
|
||||||
pname = "$package";
|
|
||||||
version = "$version";
|
|
||||||
src = fetchurl {
|
|
||||||
url = "$url";
|
|
||||||
sha256 = "$sha256";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
EOL
|
|
||||||
done
|
|
||||||
cd ..
|
|
||||||
done
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
cat << EOL
|
|
||||||
]
|
|
||||||
EOL
|
|
||||||
|
|
||||||
popd >&2
|
|
|
@ -1,68 +1,9 @@
|
||||||
{ lib, stdenv
|
{ lib, fetchFromGitHub, buildDotnetModule, dotnetCorePackages }:
|
||||||
, fetchFromGitHub
|
|
||||||
, fetchurl
|
|
||||||
, dotnetCorePackages
|
|
||||||
, makeWrapper
|
|
||||||
, unzip
|
|
||||||
, writeText
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
sdkVersion = dotnetCorePackages.sdk_6_0.version;
|
||||||
dotnet-sdk = dotnetCorePackages.sdk_6_0;
|
in
|
||||||
|
buildDotnetModule rec {
|
||||||
deps = map (package: stdenv.mkDerivation (with package; {
|
|
||||||
inherit pname version src;
|
|
||||||
|
|
||||||
buildInputs = [ unzip ];
|
|
||||||
unpackPhase = ''
|
|
||||||
unzip $src
|
|
||||||
chmod -R u+r .
|
|
||||||
function traverseRename () {
|
|
||||||
for e in *
|
|
||||||
do
|
|
||||||
t="$(echo "$e" | sed -e "s/%20/\ /g" -e "s/%2B/+/g")"
|
|
||||||
[ "$t" != "$e" ] && mv -vn "$e" "$t"
|
|
||||||
if [ -d "$t" ]
|
|
||||||
then
|
|
||||||
cd "$t"
|
|
||||||
traverseRename
|
|
||||||
cd ..
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
traverseRename
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
package=$out/lib/dotnet/${pname}/${version}
|
|
||||||
mkdir -p $package
|
|
||||||
cp -r . $package
|
|
||||||
echo "{}" > $package/.nupkg.metadata
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
dontFixup = true;
|
|
||||||
}))
|
|
||||||
(import ./deps.nix { inherit fetchurl; });
|
|
||||||
|
|
||||||
nuget-config = writeText "NuGet.Config" ''
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<packageSources>
|
|
||||||
<clear />
|
|
||||||
</packageSources>
|
|
||||||
<fallbackPackageFolders>
|
|
||||||
${lib.concatStringsSep "\n" (map (package: "<add key=\"${package}\" value=\"${package}/lib/dotnet\"/>") deps)}
|
|
||||||
</fallbackPackageFolders>
|
|
||||||
</configuration>
|
|
||||||
'';
|
|
||||||
|
|
||||||
in stdenv.mkDerivation rec {
|
|
||||||
pname = "omnisharp-roslyn";
|
pname = "omnisharp-roslyn";
|
||||||
version = "1.38.2";
|
version = "1.38.2";
|
||||||
|
|
||||||
|
@ -73,36 +14,21 @@ in stdenv.mkDerivation rec {
|
||||||
sha256 = "7XJIdotfffu8xo+S6xlc1zcK3oY9QIg1CJhCNJh5co0=";
|
sha256 = "7XJIdotfffu8xo+S6xlc1zcK3oY9QIg1CJhCNJh5co0=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper dotnet-sdk ];
|
projectFile = "src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj";
|
||||||
|
nugetDeps = ./deps.nix;
|
||||||
|
|
||||||
|
dotnetInstallFlags = [ "--framework net6.0" ];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
# Relax the version requirement
|
# Relax the version requirement
|
||||||
substituteInPlace global.json \
|
substituteInPlace global.json \
|
||||||
--replace '6.0.100' '${dotnet-sdk.version}'
|
--replace '6.0.100' '${sdkVersion}'
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildPhase = ''
|
postFixup = ''
|
||||||
runHook preBuild
|
|
||||||
|
|
||||||
HOME=$(pwd)/fake-home dotnet msbuild -r \
|
|
||||||
-p:Configuration=Release \
|
|
||||||
-p:RestoreConfigFile=${nuget-config} \
|
|
||||||
src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj
|
|
||||||
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
cp -r bin/Release/OmniSharp.Stdio.Driver/net6.0 $out/src
|
|
||||||
|
|
||||||
# Delete files to mimick hacks in https://github.com/OmniSharp/omnisharp-roslyn/blob/bdc14ca/build.cake#L594
|
# Delete files to mimick hacks in https://github.com/OmniSharp/omnisharp-roslyn/blob/bdc14ca/build.cake#L594
|
||||||
rm $out/src/NuGet.*.dll
|
rm $out/lib/omnisharp-roslyn/NuGet.*.dll
|
||||||
rm $out/src/System.Configuration.ConfigurationManager.dll
|
rm $out/lib/omnisharp-roslyn/System.Configuration.ConfigurationManager.dll
|
||||||
|
|
||||||
makeWrapper $out/src/OmniSharp $out/bin/omnisharp \
|
|
||||||
--prefix DOTNET_ROOT : ${dotnet-sdk} \
|
|
||||||
--suffix PATH : ${dotnet-sdk}/bin
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
|
@ -114,8 +40,7 @@ in stdenv.mkDerivation rec {
|
||||||
binaryNativeCode # dependencies
|
binaryNativeCode # dependencies
|
||||||
];
|
];
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = with maintainers; [ tesq0 ericdallo corngood ];
|
maintainers = with maintainers; [ tesq0 ericdallo corngood mdarocha ];
|
||||||
mainProgram = "omnisharp";
|
mainProgram = "OmniSharp";
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
3215
pkgs/development/tools/omnisharp-roslyn/deps.nix
generated
3215
pkgs/development/tools/omnisharp-roslyn/deps.nix
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue