uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
146
pkgs/build-support/dotnet/build-dotnet-module/default.nix
Normal file
146
pkgs/build-support/dotnet/build-dotnet-module/default.nix
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
{ lib, stdenvNoCC, linkFarmFromDrvs, callPackage, nuget-to-nix, writeScript, makeWrapper, fetchurl, xml2, dotnetCorePackages, dotnetPackages, mkNugetSource, mkNugetDeps, cacert }:
|
||||
|
||||
{ name ? "${args.pname}-${args.version}"
|
||||
, pname ? name
|
||||
, enableParallelBuilding ? true
|
||||
, doCheck ? false
|
||||
# Flags to pass to `makeWrapper`. This is done to avoid double wrapping.
|
||||
, makeWrapperArgs ? []
|
||||
|
||||
# Flags to pass to `dotnet restore`.
|
||||
, dotnetRestoreFlags ? []
|
||||
# Flags to pass to `dotnet build`.
|
||||
, dotnetBuildFlags ? []
|
||||
# Flags to pass to `dotnet test`, if running tests is enabled.
|
||||
, dotnetTestFlags ? []
|
||||
# Flags to pass to `dotnet install`.
|
||||
, dotnetInstallFlags ? []
|
||||
# Flags to pass to `dotnet pack`.
|
||||
, dotnetPackFlags ? []
|
||||
# Flags to pass to dotnet in all phases.
|
||||
, dotnetFlags ? []
|
||||
|
||||
# The path to publish the project to. When unset, the directory "$out/lib/$pname" is used.
|
||||
, installPath ? null
|
||||
# The binaries that should get installed to `$out/bin`, relative to `$out/lib/$pname/`. These get wrapped accordingly.
|
||||
# Unfortunately, dotnet has no method for doing this automatically.
|
||||
# If unset, all executables in the projects root will get installed. This may cause bloat!
|
||||
, executables ? null
|
||||
# Packs a project as a `nupkg`, and installs it to `$out/share`. If set to `true`, the derivation can be used as a dependency for another dotnet project by adding it to `projectReferences`.
|
||||
, packNupkg ? false
|
||||
# The packages project file, which contains instructions on how to compile it. This can be an array of multiple project files as well.
|
||||
, projectFile ? null
|
||||
# The NuGet dependency file. This locks all NuGet dependency versions, as otherwise they cannot be deterministically fetched.
|
||||
# This can be generated by running the `passthru.fetch-deps` script.
|
||||
, nugetDeps ? null
|
||||
# A list of derivations containing nupkg packages for local project references.
|
||||
# Referenced derivations can be built with `buildDotnetModule` with `packNupkg=true` flag.
|
||||
# Since we are sharing them as nugets they must be added to csproj/fsproj files as `PackageReference` as well.
|
||||
# For example, your project has a local dependency:
|
||||
# <ProjectReference Include="../foo/bar.fsproj" />
|
||||
# To enable discovery through `projectReferences` you would need to add a line:
|
||||
# <ProjectReference Include="../foo/bar.fsproj" />
|
||||
# <PackageReference Include="bar" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' "/>
|
||||
, projectReferences ? []
|
||||
# Libraries that need to be available at runtime should be passed through this.
|
||||
# These get wrapped into `LD_LIBRARY_PATH`.
|
||||
, runtimeDeps ? []
|
||||
|
||||
# Tests to disable. This gets passed to `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all frameworks.
|
||||
# See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details for more details.
|
||||
, disabledTests ? []
|
||||
# The project file to run unit tests against. This is usually referenced in the regular project file, but sometimes it needs to be manually set.
|
||||
# It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this.
|
||||
, testProjectFile ? ""
|
||||
|
||||
# The type of build to perform. This is passed to `dotnet` with the `--configuration` flag. Possible values are `Release`, `Debug`, etc.
|
||||
, buildType ? "Release"
|
||||
# The dotnet SDK to use.
|
||||
, dotnet-sdk ? dotnetCorePackages.sdk_6_0
|
||||
# The dotnet runtime to use.
|
||||
, dotnet-runtime ? dotnetCorePackages.runtime_6_0
|
||||
# The dotnet SDK to run tests against. This can differentiate from the SDK compiled against.
|
||||
, dotnet-test-sdk ? dotnet-sdk
|
||||
, ... } @ args:
|
||||
|
||||
assert projectFile == null -> throw "Defining the `projectFile` attribute is required. This is usually an `.csproj`, or `.sln` file.";
|
||||
|
||||
# TODO: Automatically generate a dependency file when a lockfile is present.
|
||||
# This file is unfortunately almost never present, as Microsoft recommands not to push this in upstream repositories.
|
||||
assert nugetDeps == null -> throw "Defining the `nugetDeps` attribute is required, as to lock the NuGet dependencies. This file can be generated by running the `passthru.fetch-deps` script.";
|
||||
|
||||
let
|
||||
inherit (callPackage ./hooks {
|
||||
inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType;
|
||||
}) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
|
||||
|
||||
localDeps = if (projectReferences != [])
|
||||
then linkFarmFromDrvs "${name}-project-references" projectReferences
|
||||
else null;
|
||||
|
||||
_nugetDeps = mkNugetDeps { inherit name; nugetDeps = import nugetDeps; };
|
||||
|
||||
nuget-source = mkNugetSource {
|
||||
name = "${name}-nuget-source";
|
||||
description = "A Nuget source with the dependencies for ${name}";
|
||||
deps = [ _nugetDeps ] ++ lib.optional (localDeps != null) localDeps;
|
||||
};
|
||||
|
||||
in stdenvNoCC.mkDerivation (args // {
|
||||
nativeBuildInputs = args.nativeBuildInputs or [] ++ [
|
||||
dotnetConfigureHook
|
||||
dotnetBuildHook
|
||||
dotnetCheckHook
|
||||
dotnetInstallHook
|
||||
dotnetFixupHook
|
||||
|
||||
dotnet-sdk
|
||||
cacert
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
# Stripping breaks the executable
|
||||
dontStrip = args.dontStrip or true;
|
||||
|
||||
# gappsWrapperArgs gets included when wrapping for dotnet, as to avoid double wrapping
|
||||
dontWrapGApps = args.dontWrapGApps or true;
|
||||
|
||||
passthru = {
|
||||
inherit nuget-source;
|
||||
|
||||
fetch-deps = writeScript "fetch-${pname}-deps" ''
|
||||
set -euo pipefail
|
||||
cd "$(dirname "''${BASH_SOURCE[0]}")"
|
||||
|
||||
export HOME=$(mktemp -d)
|
||||
deps_file="/tmp/${pname}-deps.nix"
|
||||
|
||||
store_src="${args.src}"
|
||||
src="$(mktemp -d /tmp/${pname}.XXX)"
|
||||
cp -rT "$store_src" "$src"
|
||||
chmod -R +w "$src"
|
||||
|
||||
trap "rm -rf $src $HOME" EXIT
|
||||
pushd "$src"
|
||||
|
||||
export DOTNET_NOLOGO=1
|
||||
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
|
||||
mkdir -p "$HOME/nuget_pkgs"
|
||||
|
||||
for project in "${lib.concatStringsSep "\" \"" ((lib.toList projectFile) ++ lib.optionals (testProjectFile != "") (lib.toList testProjectFile))}"; do
|
||||
${dotnet-sdk}/bin/dotnet restore "$project" \
|
||||
${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \
|
||||
-p:ContinuousIntegrationBuild=true \
|
||||
-p:Deterministic=true \
|
||||
--packages "$HOME/nuget_pkgs" \
|
||||
${lib.optionalString (dotnetRestoreFlags != []) (builtins.toString dotnetRestoreFlags)} \
|
||||
${lib.optionalString (dotnetFlags != []) (builtins.toString dotnetFlags)}
|
||||
done
|
||||
|
||||
echo "Writing lockfile..."
|
||||
${nuget-to-nix}/bin/nuget-to-nix "$HOME/nuget_pkgs" > "$deps_file"
|
||||
echo "Succesfully wrote lockfile to: $deps_file"
|
||||
'';
|
||||
} // args.passthru or {};
|
||||
})
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
{ lib
|
||||
, callPackage
|
||||
, makeSetupHook
|
||||
, makeWrapper
|
||||
, dotnet-sdk
|
||||
, dotnet-test-sdk
|
||||
, disabledTests
|
||||
, nuget-source
|
||||
, dotnet-runtime
|
||||
, runtimeDeps
|
||||
, buildType
|
||||
}:
|
||||
|
||||
{
|
||||
dotnetConfigureHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "dotnet-configure-hook";
|
||||
deps = [ dotnet-sdk nuget-source ];
|
||||
substitutions = {
|
||||
nugetSource = nuget-source;
|
||||
};
|
||||
} ./dotnet-configure-hook.sh) { };
|
||||
|
||||
dotnetBuildHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "dotnet-build-hook";
|
||||
deps = [ dotnet-sdk ];
|
||||
substitutions = {
|
||||
inherit buildType;
|
||||
};
|
||||
} ./dotnet-build-hook.sh) { };
|
||||
|
||||
dotnetCheckHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "dotnet-check-hook";
|
||||
deps = [ dotnet-test-sdk ];
|
||||
substitutions = {
|
||||
inherit buildType;
|
||||
disabledTests = lib.optionalString (disabledTests != [])
|
||||
(lib.concatStringsSep "&FullyQualifiedName!=" disabledTests);
|
||||
};
|
||||
} ./dotnet-check-hook.sh) { };
|
||||
|
||||
dotnetInstallHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "dotnet-install-hook";
|
||||
deps = [ dotnet-sdk ];
|
||||
substitutions = {
|
||||
inherit buildType;
|
||||
};
|
||||
} ./dotnet-install-hook.sh) { };
|
||||
|
||||
dotnetFixupHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "dotnet-fixup-hook";
|
||||
deps = [ dotnet-runtime makeWrapper ];
|
||||
substitutions = {
|
||||
dotnetRuntime = dotnet-runtime;
|
||||
runtimeDeps = lib.makeLibraryPath runtimeDeps;
|
||||
};
|
||||
} ./dotnet-fixup-hook.sh) { };
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
# inherit arguments from derivation
|
||||
dotnetBuildFlags=( ${dotnetBuildFlags[@]-} )
|
||||
|
||||
dotnetBuildHook() {
|
||||
echo "Executing dotnetBuildHook"
|
||||
|
||||
runHook preBuild
|
||||
|
||||
if [ "${enableParallelBuilding-}" ]; then
|
||||
maxCpuFlag="$NIX_BUILD_CORES"
|
||||
parallelBuildFlag="true"
|
||||
else
|
||||
maxCpuFlag="1"
|
||||
parallelBuildFlag="false"
|
||||
fi
|
||||
|
||||
if [ "${version-}" ]; then
|
||||
versionFlag="-p:Version=${version-}"
|
||||
fi
|
||||
|
||||
for project in ${projectFile[@]} ${testProjectFile[@]}; do
|
||||
env \
|
||||
dotnet build "$project" \
|
||||
-maxcpucount:$maxCpuFlag \
|
||||
-p:BuildInParallel=$parallelBuildFlag \
|
||||
-p:ContinuousIntegrationBuild=true \
|
||||
-p:Deterministic=true \
|
||||
--configuration "@buildType@" \
|
||||
--no-restore \
|
||||
${versionFlag-} \
|
||||
${dotnetBuildFlags[@]} \
|
||||
${dotnetFlags[@]}
|
||||
done
|
||||
|
||||
runHook postBuild
|
||||
|
||||
echo "Finished dotnetBuildHook"
|
||||
}
|
||||
|
||||
if [[ -z "${dontDotnetBuild-}" && -z "${buildPhase-}" ]]; then
|
||||
buildPhase=dotnetBuildHook
|
||||
fi
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
# inherit arguments from derivation
|
||||
dotnetTestFlags=( ${dotnetTestFlags[@]-} )
|
||||
|
||||
dotnetCheckHook() {
|
||||
echo "Executing dotnetCheckHook"
|
||||
|
||||
runHook preCheck
|
||||
|
||||
if [ "${disabledTests-}" ]; then
|
||||
disabledTestsFlag="--filter FullyQualifiedName!=@disabledTests@"
|
||||
fi
|
||||
|
||||
for project in ${testProjectFile[@]}; do
|
||||
env \
|
||||
dotnet test "$project" \
|
||||
-maxcpucount:$maxCpuFlag \
|
||||
-p:ContinuousIntegrationBuild=true \
|
||||
-p:Deterministic=true \
|
||||
--configuration "@buildType@" \
|
||||
--no-build \
|
||||
--logger "console;verbosity=normal" \
|
||||
${disabledTestsFlag-} \
|
||||
"${dotnetTestFlags[@]}" \
|
||||
"${dotnetFlags[@]}"
|
||||
done
|
||||
|
||||
runHook postCheck
|
||||
|
||||
echo "Finished dotnetCheckHook"
|
||||
}
|
||||
|
||||
if [[ -z "${dontDotnetCheck-}" && -z "${checkPhase-}" ]]; then
|
||||
checkPhase=dotnetCheckHook
|
||||
fi
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
declare -a projectFile testProjectFile
|
||||
|
||||
# inherit arguments from derivation
|
||||
dotnetFlags=( ${dotnetFlags[@]-} )
|
||||
dotnetRestoreFlags=( ${dotnetRestoreFlags[@]-} )
|
||||
|
||||
dotnetConfigureHook() {
|
||||
echo "Executing dotnetConfigureHook"
|
||||
|
||||
runHook preConfigure
|
||||
|
||||
if [ -z "${enableParallelBuilding-}" ]; then
|
||||
parallelFlag="--disable-parallel"
|
||||
fi
|
||||
|
||||
for project in ${projectFile[@]} ${testProjectFile[@]}; do
|
||||
env \
|
||||
dotnet restore "$project" \
|
||||
-p:ContinuousIntegrationBuild=true \
|
||||
-p:Deterministic=true \
|
||||
--source "@nugetSource@/lib" \
|
||||
${parallelFlag-} \
|
||||
${dotnetRestoreFlags[@]} \
|
||||
${dotnetFlags[@]}
|
||||
done
|
||||
|
||||
runHook postConfigure
|
||||
|
||||
echo "Finished dotnetConfigureHook"
|
||||
}
|
||||
|
||||
if [[ -z "${dontDotnetConfigure-}" && -z "${configurePhase-}" ]]; then
|
||||
configurePhase=dotnetConfigureHook
|
||||
fi
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
# Inherit arguments from the derivation
|
||||
makeWrapperArgs=( ${makeWrapperArgs-} )
|
||||
|
||||
# First argument is the executable you want to wrap,
|
||||
# the second is the destination for the wrapper.
|
||||
wrapDotnetProgram() {
|
||||
makeWrapper "$1" "$2" \
|
||||
--set "DOTNET_ROOT" "@dotnetRuntime@" \
|
||||
--suffix "LD_LIBRARY_PATH" : "@runtimeDeps@" \
|
||||
"${gappsWrapperArgs[@]}" \
|
||||
"${makeWrapperArgs[@]}"
|
||||
|
||||
echo "Installed wrapper to: "$2""
|
||||
}
|
||||
|
||||
dotnetFixupHook() {
|
||||
echo "Executing dotnetFixupPhase"
|
||||
|
||||
if [ "${executables}" ]; then
|
||||
for executable in ${executables[@]}; do
|
||||
execPath="$out/lib/${pname}/$executable"
|
||||
|
||||
if [[ -f "$execPath" && -x "$execPath" ]]; then
|
||||
wrapDotnetProgram "$execPath" "$out/bin/$(basename "$executable")"
|
||||
else
|
||||
echo "Specified binary \"$executable\" is either not an executable, or does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
else
|
||||
for executable in $out/lib/${pname}/*; do
|
||||
if [[ -f "$executable" && -x "$executable" && "$executable" != *"dll"* ]]; then
|
||||
wrapDotnetProgram "$executable" "$out/bin/$(basename "$executable")"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Finished dotnetFixupPhase"
|
||||
}
|
||||
|
||||
if [[ -z "${dontDotnetFixup-}" ]]; then
|
||||
preFixupPhases+=" dotnetFixupHook"
|
||||
fi
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
# inherit arguments from derivation
|
||||
dotnetInstallFlags=( ${dotnetInstallFlags[@]-} )
|
||||
|
||||
dotnetInstallHook() {
|
||||
echo "Executing dotnetInstallHook"
|
||||
|
||||
runHook preInstall
|
||||
|
||||
for project in ${projectFile[@]}; do
|
||||
env \
|
||||
dotnet publish "$project" \
|
||||
-p:ContinuousIntegrationBuild=true \
|
||||
-p:Deterministic=true \
|
||||
--output "$out/lib/${pname}" \
|
||||
--configuration "@buildType@" \
|
||||
--no-build \
|
||||
--no-self-contained \
|
||||
${dotnetInstallFlags[@]} \
|
||||
${dotnetFlags[@]}
|
||||
done
|
||||
|
||||
if [[ "${packNupkg-}" ]]; then
|
||||
for project in ${projectFile[@]}; do
|
||||
env \
|
||||
dotnet pack "$project" \
|
||||
-p:ContinuousIntegrationBuild=true \
|
||||
-p:Deterministic=true \
|
||||
--output "$out/share" \
|
||||
--configuration "@buildType@" \
|
||||
--no-build \
|
||||
${dotnetPackFlags[@]} \
|
||||
${dotnetFlags[@]}
|
||||
done
|
||||
fi
|
||||
|
||||
runHook postInstall
|
||||
|
||||
echo "Finished dotnetInstallHook"
|
||||
}
|
||||
|
||||
if [[ -z "${dontDotnetInstall-}" && -z "${installPhase-}" ]]; then
|
||||
installPhase=dotnetInstallHook
|
||||
fi
|
||||
116
pkgs/build-support/dotnet/build-dotnet-package/default.nix
Normal file
116
pkgs/build-support/dotnet/build-dotnet-package/default.nix
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
{ stdenv, lib, makeWrapper, pkg-config, mono, dotnetbuildhelpers }:
|
||||
|
||||
attrsOrig @
|
||||
{ pname
|
||||
, version
|
||||
, nativeBuildInputs ? []
|
||||
, xBuildFiles ? [ ]
|
||||
, xBuildFlags ? [ "/p:Configuration=Release" ]
|
||||
, outputFiles ? [ "bin/Release/*" ]
|
||||
, dllFiles ? [ "*.dll" ]
|
||||
, exeFiles ? [ "*.exe" ]
|
||||
# Additional arguments to pass to the makeWrapper function, which wraps
|
||||
# generated binaries.
|
||||
, makeWrapperArgs ? [ ]
|
||||
, ... }:
|
||||
let
|
||||
arrayToShell = (a: toString (map (lib.escape (lib.stringToCharacters "\\ ';$`()|<>\t") ) a));
|
||||
|
||||
attrs = {
|
||||
inherit pname version;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
makeWrapper
|
||||
dotnetbuildhelpers
|
||||
mono
|
||||
] ++ nativeBuildInputs;
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
[ -z "''${dontPlacateNuget-}" ] && placate-nuget.sh
|
||||
[ -z "''${dontPlacatePaket-}" ] && placate-paket.sh
|
||||
[ -z "''${dontPatchFSharpTargets-}" ] && patch-fsharp-targets.sh
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
echo Building dotNET packages...
|
||||
|
||||
# Probably needs to be moved to fsharp
|
||||
if pkg-config FSharp.Core
|
||||
then
|
||||
export FSharpTargetsPath="$(dirname $(pkg-config FSharp.Core --variable=Libraries))/Microsoft.FSharp.Targets"
|
||||
fi
|
||||
|
||||
ran=""
|
||||
for xBuildFile in ${arrayToShell xBuildFiles} ''${xBuildFilesExtra}
|
||||
do
|
||||
ran="yes"
|
||||
xbuild ${arrayToShell xBuildFlags} ''${xBuildFlagsArray} $xBuildFile
|
||||
done
|
||||
|
||||
[ -z "$ran" ] && xbuild ${arrayToShell xBuildFlags} ''${xBuildFlagsArray}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
dontStrip = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
target="$out/lib/dotnet/${pname}"
|
||||
mkdir -p "$target"
|
||||
|
||||
cp -rv ${arrayToShell outputFiles} "''${outputFilesArray[@]}" "$target"
|
||||
|
||||
if [ -z "''${dontRemoveDuplicatedDlls-}" ]
|
||||
then
|
||||
pushd "$out"
|
||||
remove-duplicated-dlls.sh
|
||||
popd
|
||||
fi
|
||||
|
||||
set -f
|
||||
for dllPattern in ${arrayToShell dllFiles} ''${dllFilesArray[@]}
|
||||
do
|
||||
set +f
|
||||
for dll in "$target"/$dllPattern
|
||||
do
|
||||
[ -f "$dll" ] || continue
|
||||
if pkg-config $(basename -s .dll "$dll")
|
||||
then
|
||||
echo "$dll already exported by a buildInputs, not re-exporting"
|
||||
else
|
||||
create-pkg-config-for-dll.sh "$out/lib/pkgconfig" "$dll"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
set -f
|
||||
for exePattern in ${arrayToShell exeFiles} ''${exeFilesArray[@]}
|
||||
do
|
||||
set +f
|
||||
for exe in "$target"/$exePattern
|
||||
do
|
||||
[ -f "$exe" ] || continue
|
||||
mkdir -p "$out"/bin
|
||||
commandName="$(basename -s .exe "$(echo "$exe" | tr "[A-Z]" "[a-z]")")"
|
||||
makeWrapper \
|
||||
"${mono}/bin/mono" \
|
||||
"$out"/bin/"$commandName" \
|
||||
--add-flags "\"$exe\"" \
|
||||
''${makeWrapperArgs}
|
||||
done
|
||||
done
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation (attrs // (builtins.removeAttrs attrsOrig [ "nativeBuildInputs" ] ))
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
targetDir="$1"
|
||||
dllFullPath="$2"
|
||||
|
||||
dllVersion="$(monodis --assembly "$dllFullPath" | grep ^Version: | cut -f 2 -d : | xargs)"
|
||||
[ -z "$dllVersion" ] && echo "Defaulting dllVersion to 0.0.0" && dllVersion="0.0.0"
|
||||
dllFileName="$(basename $dllFullPath)"
|
||||
dllRootName="$(basename -s .dll $dllFileName)"
|
||||
targetPcFile="$targetDir"/"$dllRootName".pc
|
||||
|
||||
mkdir -p "$targetDir"
|
||||
|
||||
cat > $targetPcFile << EOF
|
||||
Libraries=$dllFullPath
|
||||
|
||||
Name: $dllRootName
|
||||
Description: $dllRootName
|
||||
Version: $dllVersion
|
||||
Libs: -r:$dllFileName
|
||||
EOF
|
||||
|
||||
echo "Created $targetPcFile"
|
||||
18
pkgs/build-support/dotnet/dotnetbuildhelpers/default.nix
Normal file
18
pkgs/build-support/dotnet/dotnetbuildhelpers/default.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{ runCommand, mono, pkg-config }:
|
||||
runCommand
|
||||
"dotnetbuildhelpers"
|
||||
{ preferLocalBuild = true; }
|
||||
''
|
||||
target="$out/bin"
|
||||
mkdir -p "$target"
|
||||
|
||||
for script in ${./create-pkg-config-for-dll.sh} ${./patch-fsharp-targets.sh} ${./remove-duplicated-dlls.sh} ${./placate-nuget.sh} ${./placate-paket.sh}
|
||||
do
|
||||
scriptName="$(basename "$script" | cut -f 2- -d -)"
|
||||
cp -v "$script" "$target"/"$scriptName"
|
||||
chmod 755 "$target"/"$scriptName"
|
||||
patchShebangs "$target"/"$scriptName"
|
||||
substituteInPlace "$target"/"$scriptName" --replace pkg-config ${pkg-config}/bin/${pkg-config.targetPrefix}pkg-config
|
||||
substituteInPlace "$target"/"$scriptName" --replace monodis ${mono}/bin/monodis
|
||||
done
|
||||
''
|
||||
20
pkgs/build-support/dotnet/dotnetbuildhelpers/patch-fsharp-targets.sh
Executable file
20
pkgs/build-support/dotnet/dotnetbuildhelpers/patch-fsharp-targets.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Some project files look for F# targets in $(FSharpTargetsPath)
|
||||
# so it's a good idea to add something like this to your ~/.bash_profile:
|
||||
|
||||
# export FSharpTargetsPath=$(dirname $(which fsharpc))/../lib/mono/4.0/Microsoft.FSharp.Targets
|
||||
|
||||
# In build scripts, you would add somehting like this:
|
||||
|
||||
# export FSharpTargetsPath="${fsharp}/lib/mono/4.0/Microsoft.FSharp.Targets"
|
||||
|
||||
# However, some project files look for F# targets in the main Mono directory. When that happens
|
||||
# patch the project files using this script so they will look in $(FSharpTargetsPath) instead.
|
||||
|
||||
echo "Patching F# targets in fsproj files..."
|
||||
|
||||
find -iname \*.fsproj -print -exec \
|
||||
sed --in-place=.bak \
|
||||
-e 's,<FSharpTargetsPath>\([^<]*\)</FSharpTargetsPath>,<FSharpTargetsPath Condition="Exists('\'\\1\'')">\1</FSharpTargetsPath>,'g \
|
||||
{} \;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo Placating Nuget in nuget.targets
|
||||
find -iname nuget.targets -print -exec sed --in-place=bak -e 's,mono --runtime[^<]*,true NUGET PLACATED BY buildDotnetPackage,g' {} \;
|
||||
|
||||
echo Just to be sure, replacing Nuget executables by empty files.
|
||||
find . -iname nuget.exe \! -size 0 -exec mv -v {} {}.bak \; -exec touch {} \;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo Placating Paket in paket.targets
|
||||
find -iname paket.targets -print -exec sed --in-place=bak -e 's,mono --runtime[^<]*,true PAKET PLACATED BY buildDotnetPackage,g' {} \;
|
||||
|
||||
echo Just to be sure, replacing Paket executables by empty files.
|
||||
find . -iname paket\*.exe \! -size 0 -exec mv -v {} {}.bak \; -exec touch {} \;
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
IFS="
|
||||
"
|
||||
|
||||
for dll in $(find -iname \*.dll)
|
||||
do
|
||||
baseName="$(basename "$dll" | sed "s/.dll$//i")"
|
||||
if pkg-config "$baseName"
|
||||
then
|
||||
candidateDll="$(pkg-config "$baseName" --variable=Libraries)"
|
||||
|
||||
if diff "$dll" "$candidateDll" >/dev/null
|
||||
then
|
||||
echo "$dll is identical to $candidateDll. Substituting..."
|
||||
rm -vf "$dll"
|
||||
ln -sv "$candidateDll" "$dll"
|
||||
else
|
||||
echo "$dll and $candidateDll share the same name but have different contents, leaving alone."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
20
pkgs/build-support/dotnet/dotnetenv/Wrapper/Wrapper.sln
Normal file
20
pkgs/build-support/dotnet/dotnetenv/Wrapper/Wrapper.sln
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wrapper", "Wrapper\Wrapper.csproj", "{D01B3597-E85E-42F4-940A-EF5AE712942F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D01B3597-E85E-42F4-940A-EF5AE712942F}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{D01B3597-E85E-42F4-940A-EF5AE712942F}.Debug|x86.Build.0 = Debug|x86
|
||||
{D01B3597-E85E-42F4-940A-EF5AE712942F}.Release|x86.ActiveCfg = Release|x86
|
||||
{D01B3597-E85E-42F4-940A-EF5AE712942F}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Wrapper")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Philips Healthcare")]
|
||||
[assembly: AssemblyProduct("Wrapper")]
|
||||
[assembly: AssemblyCopyright("Copyright © Philips Healthcare 2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("2045ce22-78c7-4cd6-ad0a-9367f8a49738")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
|
||||
namespace @NAMESPACE@Wrapper
|
||||
{
|
||||
class @MAINCLASSNAME@Wrapper
|
||||
{
|
||||
private String[] AssemblySearchPaths = { @ASSEMBLYSEARCHPATH@ };
|
||||
|
||||
private String ExePath = @"@EXEPATH@";
|
||||
|
||||
private String MainClassName = "@NAMESPACE@.@MAINCLASSNAME@";
|
||||
|
||||
private Assembly exeAssembly;
|
||||
|
||||
public @MAINCLASSNAME@Wrapper(string[] args)
|
||||
{
|
||||
// Attach the resolve event handler to the AppDomain so that missing library assemblies will be searched
|
||||
AppDomain currentDomain = AppDomain.CurrentDomain;
|
||||
currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
|
||||
|
||||
// Dynamically load the executable assembly
|
||||
exeAssembly = Assembly.LoadFrom(ExePath);
|
||||
|
||||
// Lookup the main class
|
||||
Type mainClass = exeAssembly.GetType(MainClassName);
|
||||
|
||||
// Lookup the main method
|
||||
MethodInfo mainMethod = mainClass.GetMethod("Main");
|
||||
|
||||
// Invoke the main method
|
||||
mainMethod.Invoke(this, new Object[] {args});
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
new @MAINCLASSNAME@Wrapper(args);
|
||||
}
|
||||
|
||||
private Assembly MyResolveEventHandler(object sender, ResolveEventArgs args)
|
||||
{
|
||||
// This handler is called only when the common language runtime tries to bind to the assembly and fails.
|
||||
|
||||
Assembly MyAssembly;
|
||||
String assemblyPath = "";
|
||||
String requestedAssemblyName = args.Name.Substring(0, args.Name.IndexOf(","));
|
||||
|
||||
// Search for the right path of the library assembly
|
||||
foreach (String currentAssemblyPath in AssemblySearchPaths)
|
||||
{
|
||||
assemblyPath = currentAssemblyPath + "/" + requestedAssemblyName + ".dll";
|
||||
|
||||
if (File.Exists(assemblyPath))
|
||||
break;
|
||||
}
|
||||
|
||||
// Load the assembly from the specified path.
|
||||
MyAssembly = Assembly.LoadFrom(assemblyPath);
|
||||
|
||||
// Return the loaded assembly.
|
||||
return MyAssembly;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D01B3597-E85E-42F4-940A-EF5AE712942F}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>@ROOTNAMESPACE@</RootNamespace>
|
||||
<AssemblyName>@ASSEMBLYNAME@</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Wrapper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
85
pkgs/build-support/dotnet/dotnetenv/build-solution.nix
Normal file
85
pkgs/build-support/dotnet/dotnetenv/build-solution.nix
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
{ lib, stdenv, dotnetfx }:
|
||||
{ name
|
||||
, src
|
||||
, baseDir ? "."
|
||||
, slnFile
|
||||
, targets ? "ReBuild"
|
||||
, verbosity ? "detailed"
|
||||
, options ? "/p:Configuration=Debug;Platform=Win32"
|
||||
, assemblyInputs ? []
|
||||
, preBuild ? ""
|
||||
, modifyPublicMain ? false
|
||||
, mainClassFile ? null
|
||||
}:
|
||||
|
||||
assert modifyPublicMain -> mainClassFile != null;
|
||||
|
||||
stdenv.mkDerivation {
|
||||
inherit name src;
|
||||
|
||||
buildInputs = [ dotnetfx ];
|
||||
|
||||
preConfigure = ''
|
||||
cd ${baseDir}
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
${lib.optionalString modifyPublicMain ''
|
||||
sed -i -e "s|static void Main|public static void Main|" ${mainClassFile}
|
||||
''}
|
||||
${preBuild}
|
||||
'';
|
||||
|
||||
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"
|
||||
|
||||
addDeps $i
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
addDeps $i
|
||||
done
|
||||
|
||||
echo "Assembly search paths are: $assemblySearchPaths"
|
||||
|
||||
if [ "$assemblySearchPaths" != "" ]
|
||||
then
|
||||
echo "Using assembly search paths args: $assemblySearchPathsArg"
|
||||
export AssemblySearchPaths=$assemblySearchPaths
|
||||
fi
|
||||
|
||||
mkdir -p $out
|
||||
MSBuild.exe ${toString slnFile} /nologo /t:${targets} /p:IntermediateOutputPath=$(cygpath --windows $out)\\ /p:OutputPath=$(cygpath --windows $out)\\ /verbosity:${verbosity} ${options}
|
||||
|
||||
# Because .NET assemblies store strings as UTF-16 internally, we cannot detect
|
||||
# hashes. Therefore a text files containing the proper paths is created
|
||||
# We can also use this file the propagate transitive dependencies.
|
||||
|
||||
mkdir -p $out/nix-support
|
||||
|
||||
for i in ${toString assemblyInputs}
|
||||
do
|
||||
echo $i >> $out/nix-support/dotnet-assemblies
|
||||
done
|
||||
'';
|
||||
}
|
||||
17
pkgs/build-support/dotnet/dotnetenv/default.nix
Normal file
17
pkgs/build-support/dotnet/dotnetenv/default.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ lib, stdenv, dotnetfx }:
|
||||
|
||||
let dotnetenv =
|
||||
{
|
||||
buildSolution = import ./build-solution.nix {
|
||||
inherit lib stdenv;
|
||||
dotnetfx = dotnetfx.pkg;
|
||||
};
|
||||
|
||||
buildWrapper = import ./wrapper.nix {
|
||||
inherit dotnetenv;
|
||||
};
|
||||
|
||||
inherit (dotnetfx) assembly20Path wcfPath referenceAssembly30Path referenceAssembly35Path;
|
||||
};
|
||||
in
|
||||
dotnetenv
|
||||
64
pkgs/build-support/dotnet/dotnetenv/wrapper.nix
Normal file
64
pkgs/build-support/dotnet/dotnetenv/wrapper.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{dotnetenv}:
|
||||
|
||||
{ name
|
||||
, src
|
||||
, baseDir ? "."
|
||||
, slnFile
|
||||
, targets ? "ReBuild"
|
||||
, verbosity ? "detailed"
|
||||
, options ? "/p:Configuration=Debug;Platform=Win32"
|
||||
, assemblyInputs ? []
|
||||
, preBuild ? ""
|
||||
, namespace
|
||||
, mainClassName
|
||||
, mainClassFile
|
||||
, modifyPublicMain ? true
|
||||
}:
|
||||
|
||||
let
|
||||
application = dotnetenv.buildSolution {
|
||||
inherit name src baseDir slnFile targets verbosity;
|
||||
inherit options assemblyInputs preBuild;
|
||||
inherit modifyPublicMain mainClassFile;
|
||||
};
|
||||
in
|
||||
dotnetenv.buildSolution {
|
||||
name = "${name}-wrapper";
|
||||
src = ./Wrapper;
|
||||
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 $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
|
||||
done
|
||||
|
||||
sed -e "s|@ROOTNAMESPACE@|${namespace}Wrapper|" \
|
||||
-e "s|@ASSEMBLYNAME@|${namespace}|" \
|
||||
Wrapper/Wrapper.csproj.in > Wrapper/Wrapper.csproj
|
||||
|
||||
sed -e "s|@NAMESPACE@|${namespace}|g" \
|
||||
-e "s|@MAINCLASSNAME@|${mainClassName}|g" \
|
||||
-e "s|@EXEPATH@|$exePath|g" \
|
||||
-e "s|@ASSEMBLYSEARCHPATH@|$assemblySearchArray|" \
|
||||
Wrapper/Wrapper.cs.in > Wrapper/Wrapper.cs
|
||||
'';
|
||||
}
|
||||
43
pkgs/build-support/dotnet/fetchnuget/default.nix
Normal file
43
pkgs/build-support/dotnet/fetchnuget/default.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{ fetchurl, buildDotnetPackage, unzip }:
|
||||
|
||||
attrs @
|
||||
{ pname
|
||||
, version
|
||||
, url ? "https://www.nuget.org/api/v2/package/${pname}/${version}"
|
||||
, sha256 ? ""
|
||||
, md5 ? ""
|
||||
, ...
|
||||
}:
|
||||
if md5 != "" then
|
||||
throw "fetchnuget does not support md5 anymore, please use sha256"
|
||||
else
|
||||
buildDotnetPackage ({
|
||||
src = fetchurl {
|
||||
inherit url sha256;
|
||||
name = "${pname}.${version}.zip";
|
||||
};
|
||||
|
||||
sourceRoot = ".";
|
||||
|
||||
nativeBuildInputs = [ unzip ];
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
preInstall = ''
|
||||
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
|
||||
'';
|
||||
} // attrs)
|
||||
9
pkgs/build-support/dotnet/make-nuget-deps/default.nix
Normal file
9
pkgs/build-support/dotnet/make-nuget-deps/default.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{ linkFarmFromDrvs, fetchurl }:
|
||||
{ name, nugetDeps }:
|
||||
linkFarmFromDrvs "${name}-nuget-deps" (nugetDeps {
|
||||
fetchNuGet = { pname, version, sha256 }: fetchurl {
|
||||
name = "${pname}-${version}.nupkg";
|
||||
url = "https://www.nuget.org/api/v2/package/${pname}/${version}";
|
||||
inherit sha256;
|
||||
};
|
||||
})
|
||||
38
pkgs/build-support/dotnet/make-nuget-source/default.nix
Normal file
38
pkgs/build-support/dotnet/make-nuget-source/default.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{ dotnetPackages, lib, xml2, stdenvNoCC }:
|
||||
|
||||
{ name
|
||||
, description ? ""
|
||||
, deps ? []
|
||||
}:
|
||||
|
||||
let
|
||||
nuget-source = stdenvNoCC.mkDerivation rec {
|
||||
inherit name;
|
||||
|
||||
meta.description = description;
|
||||
nativeBuildInputs = [ dotnetPackages.Nuget xml2 ];
|
||||
|
||||
buildCommand = ''
|
||||
export HOME=$(mktemp -d)
|
||||
mkdir -p $out/{lib,share}
|
||||
|
||||
${lib.concatMapStringsSep "\n" (dep: ''
|
||||
nuget init "${dep}" "$out/lib"
|
||||
'') deps}
|
||||
|
||||
# Generates a list of all licenses' spdx ids, if available.
|
||||
# Note that this currently ignores any license provided in plain text (e.g. "LICENSE.txt")
|
||||
find "$out/lib" -name "*.nuspec" -exec sh -c \
|
||||
"NUSPEC=\$(xml2 < {}) && echo "\$NUSPEC" | grep license/@type=expression | tr -s \ '\n' | grep "license=" | cut -d'=' -f2" \
|
||||
\; | sort -u > $out/share/licenses
|
||||
'';
|
||||
} // { # We need data from `$out` for `meta`, so we have to use overrides as to not hit infinite recursion.
|
||||
meta.licence = let
|
||||
depLicenses = lib.splitString "\n" (builtins.readFile "${nuget-source}/share/licenses");
|
||||
in (lib.flatten (lib.forEach depLicenses (spdx:
|
||||
if (spdx != "")
|
||||
then lib.getLicenseFromSpdxId spdx
|
||||
else []
|
||||
)));
|
||||
};
|
||||
in nuget-source
|
||||
27
pkgs/build-support/dotnet/nuget-to-nix/default.nix
Normal file
27
pkgs/build-support/dotnet/nuget-to-nix/default.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{ lib
|
||||
, runCommandLocal
|
||||
, runtimeShell
|
||||
, substituteAll
|
||||
, nix
|
||||
, coreutils
|
||||
, findutils
|
||||
, gnused
|
||||
}:
|
||||
|
||||
runCommandLocal "nuget-to-nix" {
|
||||
script = substituteAll {
|
||||
src = ./nuget-to-nix.sh;
|
||||
inherit runtimeShell;
|
||||
|
||||
binPath = lib.makeBinPath [
|
||||
nix
|
||||
coreutils
|
||||
findutils
|
||||
gnused
|
||||
];
|
||||
};
|
||||
|
||||
meta.description = "Convert a nuget packages directory to a lockfile for buildDotnetModule";
|
||||
} ''
|
||||
install -Dm755 $script $out/bin/nuget-to-nix
|
||||
''
|
||||
29
pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
Executable file
29
pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!@runtimeShell@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
export PATH="@binPath@"
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
>&2 echo "Usage: $0 [packages directory] > deps.nix"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pkgs=$1
|
||||
tmpfile=$(mktemp /tmp/nuget-to-nix.XXXXXX)
|
||||
trap "rm -f ${tmpfile}" EXIT
|
||||
|
||||
echo "{ fetchNuGet }: ["
|
||||
|
||||
while read pkg_spec; do
|
||||
{ read pkg_name; read pkg_version; } < <(
|
||||
# Build version part should be ignored: `3.0.0-beta2.20059.3+77df2220` -> `3.0.0-beta2.20059.3`
|
||||
sed -nE 's/.*<id>([^<]*).*/\1/p; s/.*<version>([^<+]*).*/\1/p' "$pkg_spec")
|
||||
pkg_sha256="$(nix-hash --type sha256 --flat --base32 "$(dirname "$pkg_spec")"/*.nupkg)"
|
||||
|
||||
echo " (fetchNuGet { pname = \"$pkg_name\"; version = \"$pkg_version\"; sha256 = \"$pkg_sha256\"; })" >> ${tmpfile}
|
||||
done < <(find $1 -name '*.nuspec')
|
||||
|
||||
LC_ALL=C sort --ignore-case ${tmpfile}
|
||||
|
||||
echo "]"
|
||||
Loading…
Add table
Add a link
Reference in a new issue