renode: use buildDotnetModule (#419116)

This commit is contained in:
David McFarland
2025-08-11 19:34:26 -03:00
committed by GitHub
6 changed files with 1536 additions and 82 deletions
+111
View File
@@ -0,0 +1,111 @@
{
stdenv,
lib,
fetchFromGitHub,
fetchurl,
fetchpatch,
autoPatchelfHook,
makeWrapper,
nix-update-script,
glibcLocales,
python3Packages,
dotnetCorePackages,
gtk-sharp-3_0,
gtk3-x11,
dconf,
}:
let
pythonLibs =
with python3Packages;
makePythonPath [
construct
psutil
pyyaml
requests
tkinter
# from tools/csv2resd/requirements.txt
construct
# from tools/execution_tracer/requirements.txt
pyelftools
(robotframework.overrideDerivation (oldAttrs: {
src = fetchFromGitHub {
owner = "robotframework";
repo = "robotframework";
rev = "v6.1";
hash = "sha256-l1VupBKi52UWqJMisT2CVnXph3fGxB63mBVvYdM1NWE=";
};
patches = (oldAttrs.patches or [ ]) ++ [
(fetchpatch {
# utest: Improve filtering of output sugar for Python 3.13+
name = "python3.13-support.patch";
url = "https://github.com/robotframework/robotframework/commit/921e352556dc8538b72de1e693e2a244d420a26d.patch";
hash = "sha256-aSaror26x4kVkLVetPEbrJG4H1zstHsNWqmwqOys3zo=";
})
];
}))
];
in
stdenv.mkDerivation (finalAttrs: {
pname = "renode";
version = "1.16.0";
src = fetchurl {
url = "https://github.com/renode/renode/releases/download/v${finalAttrs.version}/renode-${finalAttrs.version}.linux-dotnet.tar.gz";
hash = "sha256-oNlTz5LBggPkjKM4TJO2UDKQdt2Ga7rBTdgyGjN8/zA=";
};
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
];
propagatedBuildInputs = [
gtk-sharp-3_0
];
strictDeps = true;
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,libexec/renode}
mv * $out/libexec/renode
mv .renode-root $out/libexec/renode
makeWrapper "$out/libexec/renode/renode" "$out/bin/renode" \
--prefix PATH : "$out/libexec/renode:${lib.makeBinPath [ dotnetCorePackages.runtime_8_0 ]}" \
--prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gtk3-x11 ]}" \
--prefix PYTHONPATH : "${pythonLibs}" \
--set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive"
makeWrapper "$out/libexec/renode/renode-test" "$out/bin/renode-test" \
--prefix PATH : "$out/libexec/renode:${lib.makeBinPath [ dotnetCorePackages.runtime_8_0 ]}" \
--prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gtk3-x11 ]}" \
--prefix PYTHONPATH : "${pythonLibs}" \
--set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive"
substituteInPlace "$out/libexec/renode/renode-test" \
--replace '$PYTHON_RUNNER' '${python3Packages.python}/bin/python3'
runHook postInstall
'';
passthru.updateScript = nix-update-script { };
meta = {
description = "Virtual development framework for complex embedded systems";
homepage = "https://renode.io";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [
otavio
znaniye
];
platforms = [ "x86_64-linux" ];
};
})
@@ -0,0 +1,38 @@
{
fetchurl,
renode-bin,
writeScript,
}:
renode-bin.overrideAttrs (
finalAttrs: _: {
pname = "renode-unstable";
version = "1.16.0+20250805git769469683";
src = fetchurl {
url = "https://builds.renode.io/renode-${finalAttrs.version}.linux-dotnet.tar.gz";
hash = "sha256-UZSfdJ14igoqaFCwCZmy29MfKZcxr7j8RtI/epHs2WI=";
};
passthru.updateScript =
let
versionRegex = "[0-9\\.\\+]+[^\\+]*.";
in
writeScript "${finalAttrs.pname}-updater" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts curl gnugrep gnused pup
latestVersion=$(
curl -sS https://builds.renode.io \
| pup 'a text{}' \
| egrep 'renode-${versionRegex}\.linux-dotnet\.tar\.gz' \
| head -n1 \
| sed -e 's,renode-\(.*\)\.linux-dotnet\.tar\.gz,\1,g'
)
update-source-version ${finalAttrs.pname} "$latestVersion" \
--file=pkgs/by-name/re/${finalAttrs.pname}/package.nix \
--system=x86_64-linux
'';
}
)
+26 -32
View File
@@ -1,38 +1,32 @@
{
fetchFromGitHub,
nix-update-script,
renode,
fetchurl,
writeScript,
...
}:
renode.overrideAttrs (old: rec {
pname = "renode-unstable";
version = "1.16.0-unstable-2025-08-08";
renode.overrideAttrs (
finalAttrs: _: {
pname = "renode-unstable";
version = "1.16.0+20250805git769469683";
src = fetchFromGitHub {
owner = "renode";
repo = "renode";
rev = "194d90650a9337a05cd81e8855474773d23d4396";
hash = "sha256-oRtbjup5RKbVzKMTa0yiY1gGhDqUrQ4N3SgwQ7lm8Ho=";
fetchSubmodules = true;
};
src = fetchurl {
url = "https://builds.renode.io/renode-${finalAttrs.version}.linux-dotnet.tar.gz";
hash = "sha256-UZSfdJ14igoqaFCwCZmy29MfKZcxr7j8RtI/epHs2WI=";
prePatch = ''
substituteInPlace tools/building/createAssemblyInfo.sh \
--replace CURRENT_INFORMATIONAL_VERSION="`git rev-parse --short=8 HEAD`" \
CURRENT_INFORMATIONAL_VERSION="${builtins.substring 0 8 src.rev}"
'';
passthru = old.passthru // {
updateScript = nix-update-script {
extraArgs = [
"--version=branch"
];
};
passthru.updateScript =
let
versionRegex = "[0-9\\.\\+]+[^\\+]*.";
in
writeScript "${finalAttrs.pname}-updater" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts curl gnugrep gnused pup
latestVersion=$(
curl -sS https://builds.renode.io \
| pup 'a text{}' \
| egrep 'renode-${versionRegex}\.linux-dotnet\.tar\.gz' \
| head -n1 \
| sed -e 's,renode-\(.*\)\.linux-dotnet\.tar\.gz,\1,g'
)
update-source-version ${finalAttrs.pname} "$latestVersion" \
--file=pkgs/by-name/re/${finalAttrs.pname}/package.nix \
--system=x86_64-linux
'';
}
)
};
})
+1192
View File
File diff suppressed because it is too large Load Diff
+141 -50
View File
@@ -1,21 +1,36 @@
{
stdenv,
lib,
fetchFromGitHub,
fetchurl,
fetchpatch,
autoPatchelfHook,
makeWrapper,
nix-update-script,
glibcLocales,
python3Packages,
dotnetCorePackages,
gtk-sharp-3_0,
gtk3-x11,
buildDotnetModule,
cmake,
dconf,
dotnet-runtime_8,
dotnet-sdk_6,
fetchFromGitHub,
fetchpatch,
gcc,
glibcLocales,
gtk3-x11,
gtk3,
lib,
mono,
nix-update-script,
python3Packages,
}:
let
resources = fetchFromGitHub {
owner = "renode";
repo = "renode-resources";
rev = "d3d69f8f17ed164ee23e46f0c06844a69bf4c004";
hash = "sha256-wR3heL58NOQLENwCzL4lPM4KuvT/ON7dlc/KUqrlRjg=";
};
assemblyVersion =
s:
let
part = lib.strings.splitString "-" s;
result = builtins.head part;
in
result;
pythonLibs =
with python3Packages;
makePythonPath [
@@ -48,58 +63,134 @@ let
];
}))
];
in
stdenv.mkDerivation (finalAttrs: {
buildDotnetModule rec {
pname = "renode";
version = "1.16.0";
src = fetchurl {
url = "https://github.com/renode/renode/releases/download/v${finalAttrs.version}/renode-${finalAttrs.version}.linux-dotnet.tar.gz";
hash = "sha256-oNlTz5LBggPkjKM4TJO2UDKQdt2Ga7rBTdgyGjN8/zA=";
src = fetchFromGitHub {
owner = "renode";
repo = "renode";
rev = "20ad06d9379997829df309c5724be94ba4effedd";
hash = "sha256-I/W3OAzHCN8rEIlDyBwI1ZDvKfHYYBDiqE9XkWHxo7o=";
fetchSubmodules = true;
};
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
];
projectFile = "Renode_NET.sln";
propagatedBuildInputs = [
gtk-sharp-3_0
];
dotnet-runtime = dotnet-runtime_8;
dotnet-sdk = dotnet-sdk_6;
strictDeps = true;
nugetDeps = ./deps.json;
installPhase = ''
runHook preInstall
patches = [ ./renode-test.patch ];
mkdir -p $out/{bin,libexec/renode}
mv * $out/libexec/renode
mv .renode-root $out/libexec/renode
makeWrapper "$out/libexec/renode/renode" "$out/bin/renode" \
--prefix PATH : "$out/libexec/renode:${lib.makeBinPath [ dotnetCorePackages.runtime_8_0 ]}" \
--prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gtk3-x11 ]}" \
--prefix PYTHONPATH : "${pythonLibs}" \
--set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive"
makeWrapper "$out/libexec/renode/renode-test" "$out/bin/renode-test" \
--prefix PATH : "$out/libexec/renode:${lib.makeBinPath [ dotnetCorePackages.runtime_8_0 ]}" \
--prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gtk3-x11 ]}" \
--prefix PYTHONPATH : "${pythonLibs}" \
--set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive"
substituteInPlace "$out/libexec/renode/renode-test" \
--replace '$PYTHON_RUNNER' '${python3Packages.python}/bin/python3'
runHook postInstall
prePatch = ''
substituteInPlace tools/building/createAssemblyInfo.sh \
--replace CURRENT_INFORMATIONAL_VERSION="`git rev-parse --short=8 HEAD`" \
CURRENT_INFORMATIONAL_VERSION="${builtins.substring 0 8 src.rev}"
'';
postPatch = ''
# https://github.com/dotnet/roslyn/issues/37379#issuecomment-513371985
cat << EOF > Directory.Build.props
<Project>
<ItemGroup>
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
</ItemGroup>
</Project>
EOF
patchShebangs build.sh tools/
# Fixes determinism build error
sed -i 's/AssemblyVersion("%VERSION%.*")/AssemblyVersion("${assemblyVersion version}")/g' src/Renode/Properties/AssemblyInfo.template
sed -i 's/AssemblyVersion("1.0.*")/AssemblyVersion("1.0.0.0")/g' lib/AntShell/AntShell/Properties/AssemblyInfo.cs lib/CxxDemangler/CxxDemangler/Properties/AssemblyInfo.cs
'';
# https://github.com/NixOS/nixpkgs/issues/38991
# bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
env.LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive";
nativeBuildInputs = [
cmake
gcc
];
runtimeDeps = [
gtk3
mono
];
dontUseCmakeConfigure = true;
enableParallelBuilding = false;
preBuild = ''
mkdir -p lib/resources
ln -s ${resources}/* lib/resources/
mkdir output
mv src/Infrastructure/src/Emulator/Cores/linux-properties.csproj output/properties.csproj
sed -i "s#/usr/bin/gcc#${gcc}/bin/gcc#g" output/properties.csproj
sed -i "s#/usr/bin/ar#${gcc}/bin/ar#g" output/properties.csproj
# To fix value "" error in element <Import>
rm -rf src/Directory.Build.targets
CORES=(arm.le arm.be arm64.le arm-m.le arm-m.be ppc.le ppc.be ppc64.le ppc64.be i386.le x86_64.le riscv.le riscv64.le sparc.le sparc.be xtensa.le)
for core_config in ''${CORES[@]}
do
CORE="$(echo $core_config | cut -d '.' -f 1)"
ENDIAN="$(echo $core_config | cut -d '.' -f 2)"
BITS=32
if [[ $CORE =~ "64" ]]; then
BITS=64
fi
SOURCE="${src}/src/Infrastructure/src/Emulator/Cores"
CMAKE_CONF_FLAGS="-DTARGET_ARCH=$CORE -DTARGET_WORD_SIZE=$BITS -DCMAKE_BUILD_TYPE=Release -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$out/lib"
CORE_DIR=build/$CORE/$ENDIAN
mkdir -p $CORE_DIR
pushd $CORE_DIR
if [[ $ENDIAN == "be" ]]; then
CMAKE_CONF_FLAGS+=" -DTARGET_WORDS_BIGENDIAN=1"
fi
cmake $CMAKE_CONF_FLAGS -DHOST_ARCH=i386 $SOURCE
cmake --build . -j$NIX_BUILD_CORES
popd
done
mkdir -p src/Infrastructure/src/Emulator/Cores/bin/Release/lib
ln -s $out/lib/*.so src/Infrastructure/src/Emulator/Cores/bin/Release/lib
'';
dotnetInstallFlags = [ "-p:TargetFramework=net6.0" ];
postInstall = ''
mkdir -p $out/lib/renode
mv * .renode-root $out/lib/renode
makeWrapper "$out/lib/renode/renode-test" "$out/bin/renode-test" \
--prefix PATH : "$out/lib/renode:${lib.makeBinPath [ dotnet-sdk ]}" \
--prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gtk3-x11 ]}" \
--prefix PYTHONPATH : "${pythonLibs}" \
--set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive" \
'';
executables = [ "Renode" ];
passthru.updateScript = nix-update-script { };
meta = {
changelog = "https://github.com/renode/renode/blob/${version}/CHANGELOG.rst";
description = "Virtual development framework for complex embedded systems";
downloadPage = "https://github.com/renode/renode";
homepage = "https://renode.io";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [
@@ -108,4 +199,4 @@ stdenv.mkDerivation (finalAttrs: {
];
platforms = [ "x86_64-linux" ];
};
})
}
+28
View File
@@ -0,0 +1,28 @@
diff --git a/renode-test b/renode-test
index 0f8f8d0..1fdfe23 100755
--- a/renode-test
+++ b/renode-test
@@ -5,22 +5,17 @@ set -u
# this is to support running renode-test from an external directory and via a symlink
ROOT_PATH="$(cd $(dirname $(readlink -f $0 2>/dev/null || echo $0)); echo $PWD)"
-TESTS_FILE="$ROOT_PATH/tests/tests.yaml"
-TESTS_RESULTS="$ROOT_PATH/output/tests"
. "${ROOT_PATH}/tools/common.sh"
set +e
STTY_CONFIG=`stty -g 2>/dev/null`
-$PYTHON_RUNNER -u "`get_path "$ROOT_PATH/tests/run_tests.py"`" --exclude "skip_${DETECTED_OS}" --exclude "skip_host_${DETECTED_ARCH}" --properties-file "`get_path "$ROOT_PATH/output/properties.csproj"`" -r "`get_path "$TESTS_RESULTS"`" -t "`get_path "$TESTS_FILE"`" "$@"
+$PYTHON_RUNNER -u "`get_path "$ROOT_PATH/tests/run_tests.py"`" --exclude "skip_${DETECTED_OS}" -r $(pwd) --runner=dotnet "$@"
RESULT_CODE=$?
set -e
if [ -n "${STTY_CONFIG:-}" ]
then
- # SIGTTOU might be sent when trying to change the terminal settings when "renode-test" runs in the background so trap the signal.
- trap "" SIGTTOU
stty "$STTY_CONFIG"
- trap - SIGTTOU
fi
exit $RESULT_CODE