~ruther/nix-fpga

de954459eae02429c4b4c1d0da066d1751634c6c — Rutherther 1 year, 12 days ago f618f1a feat/lattice-diamond
feat: add lattice-diamond
M flake.nix => flake.nix +2 -0
@@ 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; };

A pkgs/lattice/diamond/fhs-package.nix => pkgs/lattice/diamond/fhs-package.nix +79 -0
@@ 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"
  ];
}

A pkgs/lattice/diamond/fhs-shell.nix => pkgs/lattice/diamond/fhs-shell.nix +7 -0
@@ 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 "$@"
''

A pkgs/lattice/diamond/fhs.nix => pkgs/lattice/diamond/fhs.nix +106 -0
@@ 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";
}

Do not follow this link