mirror of
https://git.adityakumar.xyz/nix-matlab.git
synced 2024-11-12 17:29:44 +00:00
Use the ~/.config/matlab/nix.sh file only if it exists
Turn the runScriptPrefix into a function with default behavior - fix #7.
This commit is contained in:
parent
a0f354e409
commit
0d2553781d
1 changed files with 14 additions and 8 deletions
22
flake.nix
22
flake.nix
|
@ -13,19 +13,20 @@
|
||||||
# supported
|
# supported
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
targetPkgs = import ./common.nix;
|
targetPkgs = import ./common.nix;
|
||||||
runScriptPrefix = ''
|
runScriptPrefix = {errorOut ? true}: ''
|
||||||
# Needed for simulink even on wayland systems
|
# Needed for simulink even on wayland systems
|
||||||
export QT_QPA_PLATFORM=xcb
|
export QT_QPA_PLATFORM=xcb
|
||||||
# Search for an imperative declaration of the installation directory of matlab
|
# Search for an imperative declaration of the installation directory of matlab
|
||||||
if [[ -f ~/.config/matlab/nix.sh ]]; then
|
if [[ -f ~/.config/matlab/nix.sh ]]; then
|
||||||
source ~/.config/matlab/nix.sh
|
source ~/.config/matlab/nix.sh
|
||||||
else
|
'' + pkgs.lib.optionalString errorOut ''else
|
||||||
echo "nix-matlab-error: Did not find ~/.config/matlab/nix.sh" >&2
|
echo "nix-matlab-error: Did not find ~/.config/matlab/nix.sh" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ ! -d "$INSTALL_DIR" ]]; then
|
if [[ ! -d "$INSTALL_DIR" ]]; then
|
||||||
echo "nix-matlab-error: INSTALL_DIR $INSTALL_DIR isn't a directory" >&2
|
echo "nix-matlab-error: INSTALL_DIR $INSTALL_DIR isn't a directory" >&2
|
||||||
exit 2
|
exit 2
|
||||||
|
'' + ''
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
desktopItem = pkgs.makeDesktopItem {
|
desktopItem = pkgs.makeDesktopItem {
|
||||||
|
@ -58,7 +59,7 @@
|
||||||
# Might be useful for usage of this flake in another flake with devShell +
|
# Might be useful for usage of this flake in another flake with devShell +
|
||||||
# direnv setup. See:
|
# direnv setup. See:
|
||||||
# https://gitlab.com/doronbehar/nix-matlab/-/merge_requests/1#note_631741222
|
# https://gitlab.com/doronbehar/nix-matlab/-/merge_requests/1#note_631741222
|
||||||
shellHooksCommon = runScriptPrefix + ''
|
shellHooksCommon = (runScriptPrefix {}) + ''
|
||||||
export C_INCLUDE_PATH=$INSTALL_DIR/extern/include:$C_INCLUDE_PATH
|
export C_INCLUDE_PATH=$INSTALL_DIR/extern/include:$C_INCLUDE_PATH
|
||||||
export CPLUS_INCLUDE_PATH=$INSTALL_DIR/extern/include:$CPLUS_INCLUDE_PATH
|
export CPLUS_INCLUDE_PATH=$INSTALL_DIR/extern/include:$CPLUS_INCLUDE_PATH
|
||||||
# Rename the variable for others to extend it in their shellHook
|
# Rename the variable for others to extend it in their shellHook
|
||||||
|
@ -118,7 +119,7 @@
|
||||||
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 = pkgs.writeScript "matlab-runner" (runScriptPrefix + ''
|
runScript = pkgs.writeScript "matlab-runner" ((runScriptPrefix {}) + ''
|
||||||
exec $INSTALL_DIR/bin/matlab "$@"
|
exec $INSTALL_DIR/bin/matlab "$@"
|
||||||
'');
|
'');
|
||||||
meta = metaCommon // {
|
meta = metaCommon // {
|
||||||
|
@ -128,7 +129,12 @@
|
||||||
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 = pkgs.writeScript "matlab-shell-runner" ''
|
runScript = pkgs.writeScript "matlab-shell-runner" (
|
||||||
|
(runScriptPrefix {
|
||||||
|
# If the user hasn't setup a ~/.config/matlab/nix.sh file yet, don't
|
||||||
|
# yell at them that it's missing
|
||||||
|
errorOut = false;
|
||||||
|
}) + ''
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
============================
|
============================
|
||||||
welcome to nix-matlab shell!
|
welcome to nix-matlab shell!
|
||||||
|
@ -142,7 +148,7 @@
|
||||||
============================
|
============================
|
||||||
EOF
|
EOF
|
||||||
exec bash
|
exec bash
|
||||||
'';
|
'');
|
||||||
meta = metaCommon // {
|
meta = metaCommon // {
|
||||||
description = "A bash shell from which you can install matlab or launch matlab from CLI";
|
description = "A bash shell from which you can install matlab or launch matlab from CLI";
|
||||||
};
|
};
|
||||||
|
@ -190,7 +196,7 @@
|
||||||
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 = pkgs.writeScript "matlab-mlint-runner" (runScriptPrefix + ''
|
runScript = pkgs.writeScript "matlab-mlint-runner" ((runScriptPrefix {}) + ''
|
||||||
exec $INSTALL_DIR/bin/glnxa64/mlint "$@"
|
exec $INSTALL_DIR/bin/glnxa64/mlint "$@"
|
||||||
'');
|
'');
|
||||||
meta = metaCommon // {
|
meta = metaCommon // {
|
||||||
|
@ -201,7 +207,7 @@
|
||||||
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 = pkgs.writeScript "matlab-mex-runner" (runScriptPrefix + ''
|
runScript = pkgs.writeScript "matlab-mex-runner" ((runScriptPrefix {}) + ''
|
||||||
exec $INSTALL_DIR/bin/glnxa64/mex "$@"
|
exec $INSTALL_DIR/bin/glnxa64/mex "$@"
|
||||||
'');
|
'');
|
||||||
meta = metaCommon // {
|
meta = metaCommon // {
|
||||||
|
|
Loading…
Reference in a new issue