~ruther/nix-fpga

4044b23264515cd61d77cda65962bac3cefeeb1d — Rutherther 1 year, 12 days ago d32ae55
fix: require INSTALL_DIR only in final packages, not in shells
M flake.nix => flake.nix +1 -21
@@ 9,30 9,10 @@
        inherit system;
      };

      myLib = import ./pkgs/common.nix { inherit pkgs; };

      # diamondTargetPkgs = pkgs: with pkgs; [
      #   fontconfig
      #   libgcc
      #   glibc
      #   stdenv.cc.cc.lib
      #   xorg.libXext
      #   xorg.libXft
      #   xorg.libX11
      #   xorg.libXrender
      # ];
      myLib = import ./pkgs/common.nix { inherit pkgs; inherit (pkgs) lib; };

    in {
      packages.${system} = {
        # diamond-shell = pkgs.buildFHSEnv {
        #   multiPkgs = diamondTargetPkgs;
        #   name = "diamond-shell";
        #   multiArch = true;
        #   runScript = pkgs.writeScript "diamond-shell" ''
        #     export LD_LIBRARY_PATH=/lib:$LD_LIBRARY_PATH
        #     exec bash
        #   '';
        # };

        questa-shell = pkgs.callPackage ./pkgs/questa/fhs-shell.nix { inherit myLib; };
        questa = pkgs.callPackage ./pkgs/questa/fhs-package.nix { inherit myLib; };

M pkgs/common.nix => pkgs/common.nix +15 -2
@@ 1,4 1,4 @@
{ pkgs, ... }:
{ lib, pkgs, ... }:

{
  runScriptPrefix = package: required: ''


@@ 6,11 6,24 @@
    error=0
    if [[ -f ~/.config/${package}/nix.sh ]]; then
      source ~/.config/${package}/nix.sh

    '' +

    lib.optionalString required ''
    else
      echo "nix-${package}-error: Did not find ~/.config/${package}/nix.sh" >&2
      error=1
    fi
    if [[ ! -d "$INSTALL_DIR" ]]; then
    '' +

    lib.optionalString (!required) ''
    else
      echo "nix-${package}-warn: Did not find ~/.config/${package}/nix.sh"
    fi
    '' +

    ''
    if [[ ! -z "$INSTALL_DIR" && ! -d "$INSTALL_DIR" ]]; then
      echo "nix-${package}-error: INSTALL_DIR $INSTALL_DIR isn't a directory" >&2
      error=2
  '' + ''

M pkgs/intel/quartus/fhs-package.nix => pkgs/intel/quartus/fhs-package.nix +1 -1
@@ 3,7 3,7 @@
myLib.finalPkgGenerator.override {
  mainProgram = "quartus";

  fhsEnv = pkgs.callPackage ./fhs.nix {  inherit myLib; };
  fhsEnv = pkgs.callPackage ./fhs.nix { inherit myLib; requireInstallDir = true; };

  executables = [
    "clearbox"

M pkgs/intel/quartus/fhs.nix => pkgs/intel/quartus/fhs.nix +2 -2
@@ 1,4 1,4 @@
{pkgs, lib, myLib }:
{pkgs, lib, myLib, requireInstallDir ? false }:

pkgs.buildFHSEnv {
  targetPkgs =


@@ 38,7 38,7 @@ pkgs.buildFHSEnv {

  runScript = pkgs.writeScript "questasim-env" ''
    #!/usr/bin/env bash
    ${myLib.runScriptPrefix "quartus" true}
    ${myLib.runScriptPrefix "quartus" requireInstallDir}
    if [[ ! -z $INSTALL_DIR ]]; then
      export PATH=$INSTALL_DIR/quartus/bin:$PATH
    fi

M pkgs/questa/fhs-package.nix => pkgs/questa/fhs-package.nix +1 -1
@@ 3,7 3,7 @@
myLib.finalPkgGenerator.override {
  mainProgram = "vsim";

  fhsEnv = pkgs.callPackage ./fhs.nix {  inherit myLib licenseInterface; };
  fhsEnv = pkgs.callPackage ./fhs.nix { inherit myLib licenseInterface; requireInstallDir = true; };

  executables = [
    "crd2bin" "dumplog64" "flps_util" "hdloffice" "hm_entity" "jobspy" "mc2com"

M pkgs/questa/fhs.nix => pkgs/questa/fhs.nix +4 -2
@@ 1,4 1,4 @@
{pkgs, lib, myLib, licenseInterface ? "" }:
{pkgs, lib, myLib, requireInstallDir ? false, licenseInterface ? "" }:

let
  bypassNetwork = licenseInterface == true || (licenseInterface != "");


@@ 8,6 8,8 @@ in pkgs.buildFHSEnv {
  targetPkgs =
  pkgs: with pkgs; [
    stdenv.cc.cc.lib
    ncurses.lib
    libuuid
    zlib
    glib
    libxcrypt-legacy


@@ 48,7 50,7 @@ in pkgs.buildFHSEnv {

  runScript = ''
    #!/usr/bin/env bash
    ${myLib.runScriptPrefix "questa" true}
    ${myLib.runScriptPrefix "questa" requireInstallDir}
    if [[ ! -z $INSTALL_DIR ]]; then
      export PATH=$INSTALL_DIR/bin:$PATH
    fi

M pkgs/xilinx/ise/fhs-package.nix => pkgs/xilinx/ise/fhs-package.nix +1 -1
@@ 3,7 3,7 @@
myLib.finalPkgGenerator.override {
  mainProgram = "ise";

  fhsEnv = pkgs.callPackage ./fhs.nix {  inherit myLib ise-fw; };
  fhsEnv = pkgs.callPackage ./fhs.nix { inherit myLib ise-fw; requireInstallDir = true; };

  executables = [
    # TODO

M pkgs/xilinx/ise/fhs.nix => pkgs/xilinx/ise/fhs.nix +2 -2
@@ 1,4 1,4 @@
{ pkgs, myLib, ise-fw, ... }:
{ pkgs, myLib, ise-fw, requireInstallDir ? false, ... }:

pkgs.buildFHSEnv {
  targetPkgs = pkgs: ((import ../common.nix).targetPkgs pkgs) ++ [


@@ 8,7 8,7 @@ pkgs.buildFHSEnv {
  name = "ise";

  runScript = ''
    ${myLib.runScriptPrefix "ise" false}
    ${myLib.runScriptPrefix "ise" requireInstallDir}
    if [[ ! -z $INSTALL_DIR ]]; then
      source $INSTALL_DIR/settings64.sh "$INSTALL_DIR"
    fi

M pkgs/xilinx/vivado/fhs-package.nix => pkgs/xilinx/vivado/fhs-package.nix +1 -1
@@ 3,7 3,7 @@
myLib.finalPkgGenerator.override {
  mainProgram = "vivado";

  fhsEnv = pkgs.callPackage ./fhs.nix {  inherit myLib; };
  fhsEnv = pkgs.callPackage ./fhs.nix { inherit myLib; requireInstallDir = true; };

  executables = [
    # From Vivado bin folder

M pkgs/xilinx/vivado/fhs.nix => pkgs/xilinx/vivado/fhs.nix +2 -2
@@ 1,4 1,4 @@
{ pkgs, myLib }:
{ pkgs, myLib, requireInstallDir ? false, ... }:

pkgs.buildFHSEnv {
  targetPkgs = (import ../common.nix).targetPkgs;


@@ 6,7 6,7 @@ pkgs.buildFHSEnv {
  name = "vivado";

  runScript = ''
    ${myLib.runScriptPrefix "vivado" false}
    ${myLib.runScriptPrefix "vivado" requireInstallDir}
    if [[ ! -z $INSTALL_DIR ]]; then
      source $INSTALL_DIR/settings64.sh $INSTALL_DIR
    fi

Do not follow this link