diff --git a/README.adoc b/README.adoc
index 583a4e9..b5fd01b 100644
--- a/README.adoc
+++ b/README.adoc
@@ -1,17 +1,37 @@
= Matlab for Nix users
-This repo is a collection of files that should help Nix and NixOS users install matlab imperatively.
+This repo is a collection of files that should help Nix and NixOS users install Matlab imperatively.
-== How to use this
+== Install
-=== Installation of matlab itself
+Like any other Matlab user, you should first go to your Matlab account on
+Mathworks' website, at: https://www.mathworks.com/mwaccount/ and download the
+installation zip file. Extract the zip file and note the `install` executable
+you just extracted. To run that file, you'll need to get into a FHS environment
+that a nix-shell will provide.
-==== Run `matlab-shell` with +++stable+++ legacy Nix
+=== Run `matlab-shell` with an unstable Nix
-==== Run `matlab-shell` with an unstable Nix
+....
+nix run github:doronbehar/nix-matlab#matlab-shell
+....
+
+=== Run `matlab-shell` with +++stable+++ legacy Nix
+
+....
+git clone https://github.com/doronbehar/nix-matlab
+cd nix-matlab
+nix-shell
+....
+
+=== Installation of Matlab itself
+
+include::./install.adoc[]
=== Adding `matlab` executables to your system
+TODO:: Write this
+
==== For NixOS users with a flakes setup
==== For NixOS users without a flakes setup
diff --git a/flake.nix b/flake.nix
index dd182e0..f408eb9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -13,12 +13,21 @@
# supported
pkgs = nixpkgs.legacyPackages.x86_64-linux;
targetPkgs = import ./common.nix;
- # TODO: Make it possible to override this - imperatively or declaratively?
- defaultRunPath = "$HOME/downloads/software/matlab/installation";
runScriptPrefix = ''
#!${pkgs.bash}/bin/bash
# Needed for simulink even on wayland systems
export QT_QPA_PLATFORM=xcb
+ # Search for an imperative declaration of the installation directory of matlab
+ if [[ -f ~/.config/matlab/nix.sh ]]; then
+ source ~/.config/matlab/nix.sh
+ else
+ echo "nix-matlab-error: Did not find ~/.config/matlab/nix.sh" >&2
+ exit 1
+ fi
+ if [[ ! -d "$INSTALL_DIR" ]]; then
+ echo "nix-matlab-error: INSTALL_DIR $INSTALL_DIR isn't a directory" >&2
+ exit 2
+ fi
'';
in {
@@ -26,18 +35,36 @@
name = "matlab";
inherit targetPkgs;
runScript = runScriptPrefix + ''
- exec ${defaultRunPath}/bin/matlab "$@"
+ exec $INSTALL_DIR/bin/matlab "$@"
'';
};
packages.x86_64-linux.matlab-shell = pkgs.buildFHSUserEnv {
name = "matlab-shell";
inherit targetPkgs;
+ runScript = ''
+ #!${pkgs.bash}/bin/bash
+ # needed for simulink in fact, but doesn't harm here as well.
+ export QT_QPA_PLATFORM=xcb
+ cat <