Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a bunch of riscv-related packages #213222

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3790bb8
Add GenericNerdyUsername to maintainer-list.nix
GenericNerdyUsername Sep 15, 2022
1eedee1
python3Packages.mbstrdecoder: init at 1.1.1
GenericNerdyUsername Jan 26, 2023
353ba79
python3Packages.typepy: init at 1.3.0
GenericNerdyUsername Jan 26, 2023
21b4685
python3Packages.tcolorpy: init at 0.1.2
GenericNerdyUsername Jan 26, 2023
3f9b190
python3Packages.dataproperty: init at 0.55.0
GenericNerdyUsername Jan 26, 2023
ab24ccf
python3Packages.tabledata: init at 1.3.0
GenericNerdyUsername Jan 26, 2023
6369162
python3Packages.pytablewriter: init at 0.64.2
GenericNerdyUsername Jan 26, 2023
4230e35
python3Packages.riscv-isac: init at 0.16.1
GenericNerdyUsername Jan 26, 2023
27e9f60
python3Packages.ipyxact: init at 0.3.2
GenericNerdyUsername Jan 27, 2023
7d8b0f0
python3Packages.zipfile2: init at 0.0.12
GenericNerdyUsername Jan 27, 2023
76234cd
python3Packages.okonomiyaki: init at 1.3.2
GenericNerdyUsername Jan 27, 2023
002982f
python3Packages.simplesat: init at 0.8.2
GenericNerdyUsername Jan 27, 2023
bd0320a
python3Packages.fusesoc: init at 1.12.0
GenericNerdyUsername Jan 27, 2023
e2960e7
python3Packages.riscv-config: init at 3.5.0
GenericNerdyUsername Jan 27, 2023
525b19b
ocamlPackages.lem: init at 2022-12-10
GenericNerdyUsername Jan 27, 2023
e50a8b7
ocamlPackages.linksem: init at 0.8
GenericNerdyUsername Jan 27, 2023
d20823e
ocamlPackages.sail: init at 0.15
GenericNerdyUsername Jan 27, 2023
5084ca9
sail-riscv-*: init at 0.5
GenericNerdyUsername Jan 27, 2023
a69397e
python3Packages.riscof: init at 1.25.2
GenericNerdyUsername Jan 28, 2023
935f374
riscv-gnu-toolchain-*: init at 2023.01.04
GenericNerdyUsername Jan 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5130,6 +5130,16 @@
githubId = 313929;
name = "Gabriel Ebner";
};
genericnerdyusername = {
name = "GenericNerdyUsername";
email = "genericnerdyusername@proton.me";

github = "GenericNerdyUsername";
githubId = 111183546;
keys = [{
fingerprint = "58CE D4BE 6B10 149E DA80 A990 2F48 6356 A4CB 30F3";
}];
};
genofire = {
name = "genofire";
email = "geno+dev@fireorbit.de";
Expand Down
47 changes: 47 additions & 0 deletions pkgs/applications/virtualization/sail-riscv/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ stdenv
, fetchFromGitHub

, arch

, ocamlPackages
, ncurses
, ocaml
, zlib
, z3
}:


stdenv.mkDerivation rec {
pname = "sail-riscv";
version = "0.5";

nativeBuildInputs = with ocamlPackages; [ sail ocamlbuild findlib ncurses ocaml zlib.dev z3 ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use zlib.dev here, zlib is enough, stdenv automatically selects the correct output. Also only compilers/tools should reside in nativeBuildInputs, libraries should be in buildInputs. You may set strictDeps = true; to make sure everything is correctly located.


src = fetchFromGitHub {
owner = "riscv";
repo = pname;
rev = version;
hash = "sha256-7PZNNUMaCZEBf0lOCqkquewRgZPooBOjIbGF7JlLnEo=";
};

ARCH = arch;

outputs = [ "out" "ocaml_emu" "isabelle_model" "coq_model" "hol4_model" ];

preConfigure = "sed 's/^SAIL:=$(/SAIL:=sail #/' -i Makefile";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set makeFlags = [ "SAIL=sail" ] is normally enough, no need to patch the Makefile.


SAIL_DIR = "${ocamlPackages.sail}/share/sail";
SAIL = "sail";
Comment on lines +33 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these to makeFlags if possible.


installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp c_emulator/riscv_sim_${arch} $out/bin
mkdir -p $ocaml_emu/bin
cp ocaml_emulator/riscv_ocaml_sim_${arch} $ocaml_emu/bin
cp -r generated_definitions/coq/ $coq_model
cp -r generated_definitions/isabelle/ $isabelle_model
cp -r generated_definitions/hol4/ $hol4_model
runHook postInstall
Comment on lines +37 to +45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these files extremely large or something? Keeping everything in $out is fine in most cases.

Suggested change
runHook preInstall
mkdir -p $out/bin
cp c_emulator/riscv_sim_${arch} $out/bin
mkdir -p $ocaml_emu/bin
cp ocaml_emulator/riscv_ocaml_sim_${arch} $ocaml_emu/bin
cp -r generated_definitions/coq/ $coq_model
cp -r generated_definitions/isabelle/ $isabelle_model
cp -r generated_definitions/hol4/ $hol4_model
runHook postInstall
runHook preInstall
install -Dm755 c_emulator/riscv_sim_${arch} $out/bin/riscv_sim_${arch}
install -Dm755 ocaml_emulator/riscv_ocaml_sim_${arch} $ocaml_emu/bin/riscv_ocaml_sim_${arch}
cp -r generated_definitions/coq/ $coq_model
cp -r generated_definitions/isabelle/ $isabelle_model
cp -r generated_definitions/hol4/ $hol4_model
runHook postInstall

'';
}
125 changes: 125 additions & 0 deletions pkgs/development/compilers/riscv-gnu-toolchain/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{ stdenv
, lib
, fetchFromGitHub
, fetchurl

, gcc12
, glibc
, newlib
, gdb
, qemu
, musl
, spike
, riscv-pk

, autoconf
, curl
, automake
, python3
, libmpc
, gawk
, bison
, flex
, texinfo
, gperf
, libtool
, expat
, gmp
, mpfr
, flock

, srcs ? {
binutils = {
url = "mirror://gnu/binutils/binutils-2.39.tar.bz2";
hash = "sha256-2iSoT+8iAQLdJAQt8G/eqFHCYUpTd/hu/6KPM7exYUg=";
};
dejagnu = {
url = "mirror://gnu/dejagnu/dejagnu-1.6.3.tar.gz";
hash = "sha256-h9rvrNeVi0pp+IxoVtvRY0JhljxBQHnQw3H1ic1mouM=";
};
gcc = {
url = gcc12.cc.src.url;
hash = gcc12.cc.src.outputHash;
};
glibc = {
url = glibc.src.url;
hash = glibc.src.outputHash;
};
newlib = {
url = newlib.src.url;
hash = "sha256-8pbjcvUTJCJNOHzBFtw3pr05cZh1Z0b5OisC6aXUAVQ=";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same for spike and pk) Why override the hash here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original (newlib/spike/pk).src uses fetchurl, not fetchzip, so its just more convenient

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However the url could change as the versions are updated, these override would slowly rotten.

};
gdb = {
url = gdb.src.url;
hash = gdb.src.outputHash;
};
qemu = {
url = qemu.src.url;
hash = qemu.src.outputHash;
};
musl = {
url = musl.src.url;
hash = musl.src.outputHash;
};
spike = {
url = spike.src.url;
hash = "sha256-mynCIP7R6GfjvqS1xWXyYpI31SWk2f4WaGmcRAYAOh8=";
};
pk = {
url = riscv-pk.src.url;
hash = "sha256-Rf6ACDD0WptZK6XU/bdDo+TCEmZT+DTZBKXKuScQf/Y=";
};
}

, isa ? "rv64gc"
, withLinux ? false
}:
with lib;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Globally scoped with lib; is hard to read.

let

extract = file: stdenv.mkDerivation {
name = file.name + "-unpacked";
src = file;
dontPatch = true;
dontConfigure = true;
dontBuild = true;
installPhase = "cp -r . $out";
dontFixup = true;
};

srcs_fetched = mapAttrs (name: value: if value ? outPath then value else fetchurl value) srcs;
srcs_extracted = mapAttrs (name: value: extract value) srcs_fetched;
srcFlags = mapAttrsToList (name: value: "--with-${name}-src=${value}") srcs_extracted;

in stdenv.mkDerivation rec {
pname = "riscv-gnu-toolchain-" + isa;
version = "2023.01.04";

buildInputs = [ autoconf automake flock curl python3 libmpc gawk bison flex texinfo gperf libtool expat.dev gmp.dev mpfr.dev ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous comment on nativeBuildInputs and buildInputs

hardeningDisable = [ "format" ];

patches = [ ./nodotgit.patch ];
configureFlags = [
"--with-arch=${isa}"
] ++
srcFlags ++
optional withLinux "--enable-linux";

preConfigure = ''
patchShebangs .
'';

src = fetchFromGitHub {
owner = "riscv-collab";
repo = pname;
rev = version;
hash = "sha256-PXPQ/ho+fOudZRErnyQZTVFdceWGBF+geo+3y0tkNm4=";
};

meta = with lib; {
homepage = "https://github.com/riscv-collab/riscv-gnu-toolchain";
description = "RISC-V C and C++ cross-compiler";
maintainers = with maintainers; [ genericnerdyusername ];
license = with licenses; [ bsd3 gpl2 lgpl21 ];
};
}
15 changes: 15 additions & 0 deletions pkgs/development/compilers/riscv-gnu-toolchain/nodotgit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/Makefile.in b/Makefile.in
index 09c5772..a988d0d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -279,9 +279,7 @@ GCCPKGVER :=
endif

$(srcdir)/%/.git:
- cd $(srcdir) && \
- flock `git rev-parse --git-dir`/config git submodule init $(dir $@) && \
- flock `git rev-parse --git-dir`/config git submodule update $(dir $@)
+ true

#
# GLIBC
46 changes: 46 additions & 0 deletions pkgs/development/ocaml-modules/lem/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{ stdenv
, fetchFromGitHub
, lib
, ncurses
, makeWrapper

, ocamlbuild
, findlib
, ocaml
, num
, zarith
}:

stdenv.mkDerivation rec {
pname = "lem";
version = "2022-12-10";

minimalOCamlVersion = "4.07";

nativeBuildInputs = [ makeWrapper ocamlbuild findlib ocaml ];
buildInputs = [ ncurses num ];
propagatedBuildInputs = [ zarith ];

installFlags = "INSTALL_DIR=$(out)";

preInstall = "mkdir -p $OCAMLFIND_DESTDIR";
postInstall = ''
mv $out/bin/lem $out/bin/.lem_wrapped
makeWrapper $out/bin/.lem_wrapped $out/bin/lem --set LEMLIB $out/share/lem/library
Comment on lines +28 to +29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use wrapProgram in stead of makeWrapper, which automatically handles creating .foo-wrapped.

'';

src = fetchFromGitHub {
owner = "rems-project";
repo = pname;
rev = version;
hash = "sha256-ZQgcuIVRkJS0KtpzjbO4OPHGg6B0TadWA6XpRir30y8=";
};


meta = with lib; {
homepage = "https://github.com/rems-project/lem";
description = "A tool for lightweight executable mathematics";
maintainers = with maintainers; [ genericnerdyusername ];
license = with licenses; [ bsd3 gpl2 ];
};
}
35 changes: 35 additions & 0 deletions pkgs/development/ocaml-modules/linksem/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ lib
, fetchFromGitHub
, stdenv

, findlib
, ocaml
, lem
, num
}:

stdenv.mkDerivation rec {
pname = "linksem";
version = "0.8";

minimalOCamlVersion = "4.06";

nativeBuildInputs = [ findlib ocaml ];
buildInputs = [ lem num ];

preInstall = "mkdir -p $OCAMLFIND_DESTDIR";

src = fetchFromGitHub {
owner = "rems-project";
repo = pname;
rev = version;
hash = "sha256-7/YfDK3TruKCckMzAPLRrwBkHRJcX1S+AzXHWRxkZPA=";
};

meta = with lib; {
homepage = "https://github.com/rems-project/linksem";
description = "Linksem is a formalisation of substantial parts of ELF linking and DWARF debug information";
maintainers = with maintainers; [ genericnerdyusername ];
license = licenses.bsd2;
};
}
67 changes: 67 additions & 0 deletions pkgs/development/ocaml-modules/sail/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{ lib
, fetchFromGitHub
, buildDunePackage

, base64
, omd
, menhir
, ott
, linenoise
, dune-site
, pprint
, makeWrapper
, lem
, z3
, linksem
, num
}:

buildDunePackage rec {
pname = "sail";
version = "0.15";

src = fetchFromGitHub {
owner = "rems-project";
repo = "sail";
rev = version;
hash = "sha256-eNdFOSzkniNvSCZeORRJ/IYAu+9P4HSouwmhd4BQLPk=";
};

duneVersion = "3";
minimalOCamlVersion = "4.08";

SAIL_DIR = "$out";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be moved to makeFlags (or equivalent for buildDunePackage, I know little about ocaml packaging.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part in the project need this ? maybe their is a better way.


nativeBuildInputs = [ base64 omd menhir ott linenoise dune-site pprint makeWrapper ];

propagatedBuildInputs = [ lem z3 linksem num ];

buildPhase = ''
runHook preBuild
rm -r aarch* # Remove code derived from non-bsd2 arm spec
rm -r snapshots # Some of this might be derived from stuff in the aarch dir, it builds fine without it
Comment on lines +41 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define it un preBuild hook ? since you rewrite a part of buildDunePackage

dune build --release ''${enableParallelBuild:+-j $NIX_BUILD_CORES}
runHook postBuild
'';
checkPhase = ''
runHook preCheck
dune runtest ''${enableParallelBuild:+-j $NIX_BUILD_CORES}
runHook postCheck
'';
installPhase = ''
runHook preInstall
dune install --prefix $out --libdir $OCAMLFIND_DESTDIR
runHook postInstall
'';
Comment on lines +39 to +55
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these should have been handled by buildDunePackage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildDunePackage only builds a single package from a source tree, sail has multiple packages in the same source tree

postInstall = ''
mv $out/bin/sail $out/bin/.sail_wrapped
makeWrapper $out/bin/.sail_wrapped $out/bin/sail --set SAIL_DIR $out/share/sail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use wrapProgram

'';

meta = with lib; {
homepage = "https://github.com/rems-project/sail";
description = "Sail is a language for describing the instruction-set architecture (ISA) semantics of processors";
maintainers = with maintainers; [ genericnerdyusername ];
license = licenses.bsd2;
};
}
29 changes: 29 additions & 0 deletions pkgs/development/python-modules/dataproperty/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ buildPythonPackage
, mbstrdecoder
, typepy

, fetchFromGitHub
, lib
}:

buildPythonPackage rec {
pname = "dataproperty";
version = "0.55.0";

propagatedBuildInputs = [ mbstrdecoder typepy ];
doCheck = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why disabling test ?


src = fetchFromGitHub {
owner = "thombashi";
repo = pname;
rev = "v${version}";
hash = "sha256-ODSrKZ8M/ni9r2gkVIKWaKkdr+3AVi4INkEKJ+cmb44=";
};

meta = with lib; {
homepage = "https://github.com/thombashi/dataproperty";
description = "A Python library for extract property from data";
maintainers = with maintainers; [ genericnerdyusername ];
license = licenses.mit;
};
}
Loading