mirror of
https://git.adityakumar.xyz/nix-matlab.git
synced 2025-02-05 09:30:01 +00:00
Add shellHooksCommon attribute and explain how to use it
This commit is contained in:
parent
02deef3152
commit
bbfb3b26b9
2 changed files with 42 additions and 0 deletions
32
README.adoc
32
README.adoc
|
@ -121,9 +121,41 @@ Add to your `configration.nix` (untested, but should work):
|
|||
|
||||
TODO
|
||||
|
||||
==== Usage in Other Flakes / `shell.nix`
|
||||
|
||||
Some people may wish to not install matlab globally, and only making it part of
|
||||
the `buildInputs` of their project. Usually this paradigm follows along with
|
||||
https://direnv.net/[`direnv`] +
|
||||
https://nixos.wiki/wiki/Development_environment_with_nix-shell#Using_Direnv[`shell.nix`]
|
||||
/ https://nixos.wiki/wiki/Flakes#Direnv_integration[`flake.nix`] setup. For
|
||||
example you can create in your project a `shell.nix`, or define `devShell` in
|
||||
your `flake.nix` similarly to this:
|
||||
|
||||
[source,nix]
|
||||
----
|
||||
{ pkgs, nix-matlab }:
|
||||
|
||||
pkgs.mkShell {
|
||||
buildInputs = (with nix-matlab.packages.x86_64-linux; [
|
||||
matlab
|
||||
matlab-mlint
|
||||
matlab-mex
|
||||
]);
|
||||
# Define C include path env vars for c development
|
||||
shellHook = nix-matlab.shellHooksCommon;
|
||||
}
|
||||
----
|
||||
|
||||
Note that Matlab still needs to be installed in a user-writeable location for
|
||||
this `shellHook` to work, as explained xref:#user-content-install[here].
|
||||
|
||||
== Previous work / Credits
|
||||
|
||||
Core parts of this repo are based on
|
||||
https://github.com/tviti/nix-cfg/tree/e6531426e86273e450c6133a0deae9008411fffd/pkgs/matlab[@tviti's
|
||||
work]. My part was making it a bit more accessible for modern Nix flake setup,
|
||||
and making the shell and steps a bit more approachable.
|
||||
|
||||
The idea for a `shellHooksCommon` was by
|
||||
https://gitlab.com/DavidRConnell[@DavidRConnell], first discussed in
|
||||
https://gitlab.com/doronbehar/nix-matlab/-/merge_requests/1#note_631741222[!1].
|
||||
|
|
10
flake.nix
10
flake.nix
|
@ -98,6 +98,16 @@
|
|||
overlay = final: prev: {
|
||||
inherit (self.packages.x86_64-linux) matlab matlab-shell matlab-mlint matlab-mex;
|
||||
};
|
||||
# Might be useful for usage of this flake in another flake with devShell +
|
||||
# direnv setup. See:
|
||||
# https://gitlab.com/doronbehar/nix-matlab/-/merge_requests/1#note_631741222
|
||||
shellHooksCommon = runScriptPrefix + ''
|
||||
export C_INCLUDE_PATH=$INSTALL_DIR/extern/include:$C_INCLUDE_PATH
|
||||
export CPLUS_INCLUDE_PATH=$INSTALL_DIR/extern/include:$CPLUS_INCLUDE_PATH
|
||||
# Rename the variable for others to extend it in their shellHook
|
||||
export MATLAB_INSTALL_DIR="$INSTALL_DIR"
|
||||
unset INSTALL_DIR
|
||||
'';
|
||||
devShell.x86_64-linux = pkgs.mkShell {
|
||||
buildInputs = (targetPkgs pkgs) ++ [
|
||||
self.packages.x86_64-linux.matlab-shell
|
||||
|
|
Loading…
Reference in a new issue