diff --git a/README.adoc b/README.adoc index b85a83b..7020331 100644 --- a/README.adoc +++ b/README.adoc @@ -30,14 +30,30 @@ include::./install.adoc[] === Adding `matlab` executables to your system -TODO:: Write this +With what was done now, you run Matlab from the command line with: + +.... +# Legacy nix users (inside a clone of this repo) +$(nix-build)/bin/matlab +# Flake nix users (without cloning) +nix run gitlab:doronbehar/nix-matlab +.... + +But it's likely you'd like to make Matlab survive garbage collections and add a +desktop launcher to your system. To do that you can follow one of the following +paths according to your setup. ==== For NixOS users with a flakes setup + + ==== For NixOS users without a flakes setup ==== Home Manager setup == Previous work -TODO:: Add links to tviti's repo etc. +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. diff --git a/flake.nix b/flake.nix index f408eb9..409b0f4 100644 --- a/flake.nix +++ b/flake.nix @@ -29,11 +29,29 @@ exit 2 fi ''; + desktopItem = pkgs.makeDesktopItem { + desktopName = "Matlab"; + name = "matlab"; + exec = "${builtins.placeholder "out"}/bin/matlab %F"; + icon = "matlab"; + # Most of the following are copied from octave's desktop launcher + categories = "Utility;TextEditor;Development;IDE;"; + mimeType = "text/x-octave;text/x-matlab;"; + extraEntries = '' + Keywords=science;math;matrix;numerical computation;plotting; + ''; + }; in { packages.x86_64-linux.matlab = pkgs.buildFHSUserEnv { name = "matlab"; inherit targetPkgs; + extraInstallCommands = '' + install -Dm644 ${desktopItem}/share/applications/matlab.desktop $out/share/applications/matlab.desktop + install -Dm644 ${./icons/hicolor/256x256/matlab.png} $out/share/icons/hicolor/256x256/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 + ''; runScript = runScriptPrefix + '' exec $INSTALL_DIR/bin/matlab "$@" ''; @@ -60,7 +78,7 @@ exec bash ''; }; - packages.x86_64-linux.mlint = pkgs.buildFHSUserEnv { + packages.x86_64-linux.matlab-mlint = pkgs.buildFHSUserEnv { name = "mlint"; inherit targetPkgs; runScript = runScriptPrefix + '' @@ -68,7 +86,7 @@ ''; }; overlay = final: prev: { - inherit (self.packages.x86_64-linux) matlab matlab-shell mlint; + inherit (self.packages.x86_64-linux) matlab matlab-shell matlab-mlint; }; devShell.x86_64-linux = pkgs.mkShell { buildInputs = (targetPkgs pkgs) ++ [ diff --git a/icons/hicolor/256x256/matlab.png b/icons/hicolor/256x256/matlab.png new file mode 100644 index 0000000..2c4c75f Binary files /dev/null and b/icons/hicolor/256x256/matlab.png differ diff --git a/icons/hicolor/512x512/matlab.png b/icons/hicolor/512x512/matlab.png new file mode 100644 index 0000000..5180c3a Binary files /dev/null and b/icons/hicolor/512x512/matlab.png differ diff --git a/icons/hicolor/64x64/matlab.png b/icons/hicolor/64x64/matlab.png new file mode 100644 index 0000000..a56bbbb Binary files /dev/null and b/icons/hicolor/64x64/matlab.png differ