From de954459eae02429c4b4c1d0da066d1751634c6c Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 23 Mar 2024 13:33:28 +0100 Subject: [PATCH] feat: add lattice-diamond --- flake.nix | 2 + pkgs/lattice/diamond/fhs-package.nix | 79 ++++++++++++++++++++ pkgs/lattice/diamond/fhs-shell.nix | 7 ++ pkgs/lattice/diamond/fhs.nix | 106 +++++++++++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 pkgs/lattice/diamond/fhs-package.nix create mode 100644 pkgs/lattice/diamond/fhs-shell.nix create mode 100644 pkgs/lattice/diamond/fhs.nix diff --git a/flake.nix b/flake.nix index 7f807c7..92c239e 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,8 @@ in { packages.${system} = { + diamond-shell = pkgs.callPackage ./pkgs/lattice/diamond/fhs-shell.nix { inherit myLib; }; + diamond = pkgs.callPackage ./pkgs/lattice/diamond/fhs-package.nix { inherit myLib; }; questa-shell = pkgs.callPackage ./pkgs/questa/fhs-shell.nix { inherit myLib; }; questa = pkgs.callPackage ./pkgs/questa/fhs-package.nix { inherit myLib; }; diff --git a/pkgs/lattice/diamond/fhs-package.nix b/pkgs/lattice/diamond/fhs-package.nix new file mode 100644 index 0000000..5250195 --- /dev/null +++ b/pkgs/lattice/diamond/fhs-package.nix @@ -0,0 +1,79 @@ +{ pkgs, myLib, licenseInterface ? "" }: + +myLib.finalPkgGenerator.override { + mainProgram = "diamond"; + + fhsEnv = pkgs.callPackage ./fhs.nix { inherit myLib licenseInterface; requireInstallDir = true; }; + + executables = [ + "cableserver" + "cableservermain" + "check_systemlibrary_diamond.bash" + "check_systemlibrary_diamond.csh" + "createdevfile" + "dbgmain" + "ddtcmain" + "ddtcmd" + "ddtmain" + "debugger" + "deployment" + "diamond" + "diamondc" + "diamond_env" + "engines" + "expwrap" + "fileutility" + "fpgac" + "fpgae" + "hdl2jhd" + "hdlparser" + "htmlrpt" + "ipexpress" + "ipxwrapper" + "istflow" + "launchmicosystem" + "licensedebug" + "mdlmain" + "mergejedec" + "messagesupport" + "mgnmain" + "model300" + "moduleparser" + "mpartrce" + "naf2sym" + "opwebhlp" + "pfumain" + "pgrcmain" + "pgrcmd" + "pgrmain" + "pnmain" + "pnmainc" + "powercal" + "programmer" + "psbasccfgwrap" + "psbascwrap" + "psbrtlwrap" + "pwcmain" + "pwcwrap" + "revealrva" + "rvamain" + "sbpgen" + "sbpmain" + "sch2sym" + "sch2vhd" + "sch2vlog" + "schexe" + "sedwrap" + "setupenv" + "shvmain" + "symexe" + "syndevgen" + "synpwrap" + "TCP2CABLE" + "tmcheck" + "toolapps" + "update" + "updwrapper" + "wetmain" + ]; +} diff --git a/pkgs/lattice/diamond/fhs-shell.nix b/pkgs/lattice/diamond/fhs-shell.nix new file mode 100644 index 0000000..a431909 --- /dev/null +++ b/pkgs/lattice/diamond/fhs-shell.nix @@ -0,0 +1,7 @@ +{ pkgs, lib, myLib, licenseInterface ? "" }: + +let + fhs = pkgs.callPackage ./fhs.nix { inherit myLib licenseInterface; }; +in pkgs.writeShellScriptBin "diamond-shell" '' + exec ${lib.getExe fhs} bash "$@" +'' diff --git a/pkgs/lattice/diamond/fhs.nix b/pkgs/lattice/diamond/fhs.nix new file mode 100644 index 0000000..f6c4c96 --- /dev/null +++ b/pkgs/lattice/diamond/fhs.nix @@ -0,0 +1,106 @@ +{ pkgs, lib, myLib, requireInstallDir ? false, licenseInterface ? "", ... }: + +let + bypassNetwork = licenseInterface == true || (licenseInterface != ""); + imperativeInterface = licenseInterface == true; + declarativeInterface = bypassNetwork && !imperativeInterface; +in pkgs.buildFHSEnv { + multiPkgs = pkgs: with pkgs; [ + coreutils + fontconfig + expat + libgcc + libjpeg + libselinux + gamin + glib + stdenv.cc.cc.lib + zlib + libpng + freetype + tcl-8_5 + alsa-lib + nss + nspr + nsss + sqlite + ncurses5 + gmp + libthai + pixman + cups.lib + avahi + audit + libtiff + dbus.lib + gnutls + keyutils.lib + cairo + pango + krb5 + libgcrypt + libgpg-error + libtasn1 + gtk2 + jasper + (perl.withPackages (ps: [ + ps.XMLRegExp + ps.XMLParser + ])) + + xorg.libXext + xorg.libXtst + xorg.libXft + xorg.libX11 + xorg.libXrender + xorg.libXi + xorg.libXft + xorg.libXrandr + xorg.libXfixes + xorg.libXdamage + xorg.libXcomposite + xorg.libXinerama + xorg.libICE + xorg.libSM + libGL + ]; + + name = "diamond"; + + multiArch = true; + + unshareNet = bypassNetwork; + + extraBwrapArgs = lib.lists.optionals bypassNetwork [ + "--cap-add CAP_NET_ADMIN" + ]; + + runScript = '' + ${myLib.runScriptPrefix "diamond" requireInstallDir} + if [[ ! -z $INSTALL_DIR ]]; then + export PATH=$INSTALL_DIR/bin/lin64:$PATH + export LD_LIBRARY_PATH=$INSTALL_DIR/bin/lin64:$LD_LIBRARY_PATH + fi + export LD_LIBRARY_PATH=/lib:$LD_LIBRARY_PATH + '' + + + (lib.optionalString imperativeInterface '' + if [[ -z $LICENSE_INTERFACE ]]; then + echo "nix-diamond-error: LICENSE_INTERFACE is not set, but imperative license interface setup has been chosen. Continuing, but expect issues with license." + else + ip link add eth0 type dummy + ip link set dev eth0 address $LICENSE_INTERFACE + fi + '') + + + (lib.optionalString declarativeInterface '' + ip link add eth0 type dummy + ip link set dev eth0 address ${licenseInterface} + '') + + + '' + exec "$@" + ''; + + meta.mainProgram = "diamond"; +} -- 2.48.1