diff --git a/pkgs/quartus/quartus-unwrapped.nix b/pkgs/quartus/quartus-unwrapped.nix index 7ef542f..6b7fade 100644 --- a/pkgs/quartus/quartus-unwrapped.nix +++ b/pkgs/quartus/quartus-unwrapped.nix @@ -1,11 +1,10 @@ { + buildFHSEnv, + stdenvNoCC, fetchurl, lib, - mkDerivation, quartusOptions, quartusSource, - unstick, - unzip, }: let @@ -89,73 +88,90 @@ let patches = quartusSource.patches or [ ]; in -mkDerivation { - inherit version; - pname = "quartus-prime-${quartusSource.variant}-unwrapped"; - - nativeBuildInputs = [ - unstick - unzip - ]; - - buildCommand = - let - - copyExecutable = - { path, name }: +stdenvNoCC.mkDerivation ( + finalAttrs: + let + # leaves enabled: quartus, devinfo + disabledComponents = [ + "quartus_help" + "quartus_update" + ] + ++ (if hasQuesta then ([ "questa_fe" ] ++ (lib.optional (!withQuesta) "questa_fse")) else [ ]) + ++ unselectedDevices; + + installerFHS = buildFHSEnv { + pname = "quartus-prime-${quartusSource.variant}-installer"; + executableName = "install-quartus"; + inherit (finalAttrs) version; + targetPkgs = pkgs: [ pkgs.unstick ]; + extraBwrapArgs = [ + "--bind $out $out" + ] + ++ ( + # --bind the qdz's instead of copying them as we don't need to modify with chmod + map (component: ''--bind "${component}" "$TEMP/${component.name}"'') components + ); + profile = + let + copyExecutable = + { path, name }: + '' + cp "${path}" "$TEMP/${name}" + chmod +x "$TEMP/${name}" + ''; + in '' - # `$(cat $NIX_CC/nix-support/dynamic-linker) $src[0]` often segfaults, so cp + patchelf - cp ${path} $TEMP/${name} - chmod u+w,+x $TEMP/${name} - patchelf --interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $TEMP/${name} + echo "Entered installer FHSEnv..." + + ${lib.concatMapStringsSep "\n" ( + installer: + copyExecutable { + path = installer; + inherit (installer) name; + } + ) installers} + + echo "Running Quartus installer..." + unstick $TEMP/${(builtins.head installers).name} \ + --disable-components ${lib.concatStringsSep "," disabledComponents} \ + --mode unattended \ + --installdir $out \ + --accept_eula 1 + + # https://community.altera.com/kb/knowledge-base/why-do-i-unexpectedly-observe-intermittent-ddm-errors/349714 + ${lib.concatMapStringsSep "\n" (patch: '' + ${copyExecutable { + path = patch; + name = baseNameOf patch; + }} + echo "Applying patch ${baseNameOf patch}..." + unstick $TEMP/${baseNameOf patch} \ + --mode unattended \ + --installdir $out \ + --accept_eula 1 \ + --patch_to quartus + '') patches} + + echo "Exiting installer FHSEnv..." ''; - copyInstaller = - installer: - copyExecutable { - path = installer; - inherit (installer) name; - }; - copyComponent = component: "cp ${component} $TEMP/${component.name}"; - # leaves enabled: quartus, devinfo - disabledComponents = [ - "quartus_help" - "quartus_update" - ] - ++ (if hasQuesta then ([ "questa_fe" ] ++ (lib.optional (!withQuesta) "questa_fse")) else [ ]) - ++ unselectedDevices; - - # https://community.altera.com/kb/knowledge-base/why-do-i-unexpectedly-observe-intermittent-ddm-errors/349714 - applyPatch = patcher: '' - echo "setting up patcher..." - ${copyExecutable { - path = patcher; - name = baseNameOf patcher; - }} - - echo "executing patcher..." - unstick $TEMP/${baseNameOf patcher} \ - --mode unattended --installdir $out --accept_eula 1 --patch_to quartus - ''; - in - '' - echo "setting up installer..." - ${lib.concatMapStringsSep "\n" copyInstaller installers} - ${lib.concatMapStringsSep "\n" copyComponent components} - - echo "executing installer..." - # "Could not load seccomp program: Invalid argument" might occur if unstick - # itself is compiled for x86_64 instead of the non-x86 host. In that case, - # override the input. - unstick $TEMP/${(builtins.head installers).name} \ - --disable-components ${lib.concatStringsSep "," disabledComponents} \ - --mode unattended --installdir $out --accept_eula 1 - - ${lib.concatMapStringsSep "\n" applyPatch patches} + runScript = ""; + }; + in + { + pname = "quartus-prime-${quartusSource.variant}-unwrapped"; + inherit version; + + nativeBuildInputs = [ installerFHS ]; + phases = [ "installPhase" ]; + + installPhase = '' + mkdir -p $out + install-quartus # cat all the logs so we can see them in nix log cat $out/logs/* - echo "cleaning up..." + echo "Cleaning up logs..." rm -r $out/uninstall $out/logs # replace /proc pentium check with a true statement. this allows usage under emulation. @@ -165,11 +181,12 @@ mkDerivation { ''} ''; - meta = { - homepage = "https://fpgasoftware.intel.com"; - description = "FPGA design and simulation software"; - sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; - license = lib.licenses.unfree; - platforms = [ "x86_64-linux" ]; - }; -} + meta = { + homepage = "https://fpgasoftware.intel.com"; + description = "FPGA design and simulation software"; + sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; + license = lib.licenses.unfree; + platforms = [ "x86_64-linux" ]; + }; + } +) diff --git a/pkgs/quartus/quartus.nix b/pkgs/quartus/quartus.nix index e13ab69..2ea8431 100644 --- a/pkgs/quartus/quartus.nix +++ b/pkgs/quartus/quartus.nix @@ -1,5 +1,4 @@ { - stdenv, buildFHSEnv, callPackage, lib, @@ -13,7 +12,6 @@ installs = quartusSource.defaultInstalls; # from quartusSource.installers e.g. "QuestaSetup" }, unwrapped ? callPackage ./quartus-unwrapped.nix { - inherit (stdenv) mkDerivation; inherit quartusSource quartusOptions; }, extraProfile ? "",