Skip to content

Commit

Permalink
TMP: libresoc: import derivations from upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Leightcap <[email protected]>
  • Loading branch information
jleightcap committed Mar 29, 2024
1 parent bc0f45e commit fb83045
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
);
args = {
inherit (pkgs) lib;
inherit callPackage;
inherit callPackage runCommand;
};
result = (import ./pkgs/by-name args) // (import ./pkgs args);
in
Expand Down
1 change: 1 addition & 0 deletions pkgs/by-name/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
lib,
callPackage,
runCommand,
}: let
baseDirectory = ./.;

Expand Down
6 changes: 6 additions & 0 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
lib,
callPackage,
runCommand,
}: let
self = rec {
# LiberaForms is intentionally disabled.
Expand Down Expand Up @@ -28,6 +29,11 @@
pretalx-venueless
pretalx-public-voting
;

libresoc = rec {
pinmux = callPackage ./libresoc/pinmux.nix {};
verilog = callPackage ./libresoc/verilog.nix {inherit pinmux;};
};
};
in
self
31 changes: 31 additions & 0 deletions pkgs/libresoc/pinmux.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
stdenv,
fetchgit,
python3,
}:
stdenv.mkDerivation {
name = "libresoc-pinmux";

src = fetchgit {
url = "https://git.libre-soc.org/git/pinmux.git";
hash = "sha256-Tux2RvcRmlpXMsHwve/+5rOyBRSThg9MVW2NGP3ZJxs=";
};

nativeBuildInputs = [python3];

configurePhase = "true";

buildPhase = ''
runHook preBuild
python src/pinmux_generator.py -v -s ls180 -o ls180
runHook postBuild
'';

installPhase = ''
runHook preInstall
mv ls180 $out
runHook postInstall
'';

fixupPhase = "true";
}
48 changes: 48 additions & 0 deletions pkgs/libresoc/soc.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
lib,
buildPythonPackage,
yosys,
runCommand,
c4m-jtag,
nmigen-soc,
libresoc-ieee754fpu,
libresoc-openpower-isa,
python,
}: let
# If we use ../. as source, then any change to
# any unrelated Nix file would cause a rebuild,
# since the build would have access to it.
src = runCommand "libresoc-soc-source" {} ''
mkdir $out
cp -r ${../src} -T $out/src
cp -r ${../setup.py} -T $out/setup.py
cp -r ${../README.md} -T $out/README.md
cp -r ${../NEWS.txt} -T $out/NEWS.txt
'';
in
buildPythonPackage {
pname = "libresoc-soc";
inherit src;

propagatedBuildInputs = [
c4m-jtag
nmigen-soc
python
libresoc-ieee754fpu
libresoc-openpower-isa
yosys
];

doCheck = false;

prePatch = ''
rm -r src/soc/litex
'';

pythonImportsCheck = ["soc"];

meta = with lib; {
homepage = "https://libre-soc.org/";
license = licenses.lgpl3Plus;
};
}
24 changes: 24 additions & 0 deletions pkgs/libresoc/verilog.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
runCommand,
python3,
python3Packages,
pinmux,
}: let
script = ''
mkdir pinmux
ln -s ${pinmux} pinmux/ls180
export PINMUX="$(realpath ./pinmux)"
python3 -m soc.simple.issuer_verilog \
--debug=jtag --enable-core --enable-pll \
--enable-xics --enable-sram4x4kblock --disable-svp64 \
$out
'';
in
runCommand "libresoc.v" {
nativeBuildInputs =
(with python3Packages; [
libresoc-soc
])
++ [pinmux];
}
script

0 comments on commit fb83045

Please sign in to comment.