Use pkgs.writeScript for the runScript FHS argument

It seems it's problematic for FHS to run full scripts, because it
`exec`s them internally.

Also, for the matlab-shell: Don't source the shellHooksCommon as it's
not needed if you install Matlab for the first time.
This commit is contained in:
Doron Behar 2022-10-31 13:56:17 +02:00
parent 2780a166f0
commit a0f354e409

View file

@ -118,9 +118,9 @@
install -Dm644 ${./icons/hicolor/512x512/matlab.png} $out/share/icons/hicolor/512x512/matlab.png install -Dm644 ${./icons/hicolor/512x512/matlab.png} $out/share/icons/hicolor/512x512/matlab.png
install -Dm644 ${./icons/hicolor/64x64/matlab.png} $out/share/icons/hicolor/64x64/matlab.png install -Dm644 ${./icons/hicolor/64x64/matlab.png} $out/share/icons/hicolor/64x64/matlab.png
''; '';
runScript = runScriptPrefix + '' runScript = pkgs.writeScript "matlab-runner" (runScriptPrefix + ''
exec $INSTALL_DIR/bin/matlab "$@" exec $INSTALL_DIR/bin/matlab "$@"
''; '');
meta = metaCommon // { meta = metaCommon // {
description = "Matlab itself - the GUI launcher"; description = "Matlab itself - the GUI launcher";
}; };
@ -128,7 +128,7 @@
packages.x86_64-linux.matlab-shell = pkgs.buildFHSUserEnv { packages.x86_64-linux.matlab-shell = pkgs.buildFHSUserEnv {
name = "matlab-shell"; name = "matlab-shell";
inherit targetPkgs; inherit targetPkgs;
runScript = shellHooksCommon + '' runScript = pkgs.writeScript "matlab-shell-runner" ''
cat <<EOF cat <<EOF
============================ ============================
welcome to nix-matlab shell! welcome to nix-matlab shell!
@ -178,10 +178,10 @@
packages.x86_64-linux.matlab-python-shell = pkgs.buildFHSUserEnv { packages.x86_64-linux.matlab-python-shell = pkgs.buildFHSUserEnv {
name = "matlab-python-shell"; name = "matlab-python-shell";
inherit targetPkgs; inherit targetPkgs;
runScript = shellHooksCommon + '' runScript = pkgs.writeScript "matlab-python-shell-runner" (shellHooksCommon + ''
export PYTHONPATH=${self.packages.x86_64-linux.matlab-python-package}/${pkgs.python3.sitePackages} export PYTHONPATH=${self.packages.x86_64-linux.matlab-python-package}/${pkgs.python3.sitePackages}
exec python "$@" exec python "$@"
''; '');
meta = metaCommon // { meta = metaCommon // {
homepage = "https://www.mathworks.com/help/matlab/matlab-engine-for-python.html"; homepage = "https://www.mathworks.com/help/matlab/matlab-engine-for-python.html";
description = "A python shell from which you can use matlab's python engine"; description = "A python shell from which you can use matlab's python engine";
@ -190,9 +190,9 @@
packages.x86_64-linux.matlab-mlint = pkgs.buildFHSUserEnv { packages.x86_64-linux.matlab-mlint = pkgs.buildFHSUserEnv {
name = "mlint"; name = "mlint";
inherit targetPkgs; inherit targetPkgs;
runScript = runScriptPrefix + '' runScript = pkgs.writeScript "matlab-mlint-runner" (runScriptPrefix + ''
exec $INSTALL_DIR/bin/glnxa64/mlint "$@" exec $INSTALL_DIR/bin/glnxa64/mlint "$@"
''; '');
meta = metaCommon // { meta = metaCommon // {
homepage = "https://www.mathworks.com/help/matlab/ref/mlint.html"; homepage = "https://www.mathworks.com/help/matlab/ref/mlint.html";
description = "Check MATLAB code files for possible problems"; description = "Check MATLAB code files for possible problems";
@ -201,9 +201,9 @@
packages.x86_64-linux.matlab-mex = pkgs.buildFHSUserEnv { packages.x86_64-linux.matlab-mex = pkgs.buildFHSUserEnv {
name = "mex"; name = "mex";
inherit targetPkgs; inherit targetPkgs;
runScript = runScriptPrefix + '' runScript = pkgs.writeScript "matlab-mex-runner" (runScriptPrefix + ''
exec $INSTALL_DIR/bin/glnxa64/mex "$@" exec $INSTALL_DIR/bin/glnxa64/mex "$@"
''; '');
meta = metaCommon // { meta = metaCommon // {
homepage = "https://www.mathworks.com/help/matlab/ref/mex.html"; homepage = "https://www.mathworks.com/help/matlab/ref/mex.html";
description = "Build MEX function or engine application"; description = "Build MEX function or engine application";