diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..583a4e9 --- /dev/null +++ b/README.adoc @@ -0,0 +1,23 @@ += Matlab for Nix users + +This repo is a collection of files that should help Nix and NixOS users install matlab imperatively. + +== How to use this + +=== Installation of matlab itself + +==== Run `matlab-shell` with +++stable+++ legacy Nix + +==== Run `matlab-shell` with an unstable Nix + +=== Adding `matlab` executables to your system + +==== 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. diff --git a/common.nix b/common.nix index 98e79a3..bbed950 100644 --- a/common.nix +++ b/common.nix @@ -2,64 +2,58 @@ R2020a, available at https://github.com/mathworks-ref-arch/container-images */ +pkgs: -{ }: +(with pkgs; [ + cacert + alsaLib # libasound2 + atk + glib + glibc + cairo + cups + dbus + fontconfig + gdk-pixbuf + #gst-plugins-base + # gstreamer + gtk3 + nspr + nss + pam + pango + python27 + python36 + python37 + libselinux + libsndfile + glibcLocales + procps + unzip + zlib -rec { - runPath = "$HOME/downloads/software/matlab/installation"; - targetPkgs = pkgs: - with pkgs; - [ - cacert - alsaLib # libasound2 - atk - glib - glibc - cairo - cups - dbus - fontconfig - gdk-pixbuf - #gst-plugins-base - # gstreamer - gtk3 - nspr - nss - pam - pango - python27 - python36 - python37 - libselinux - libsndfile - glibcLocales - procps - unzip - zlib + gcc + gfortran - gcc - gfortran - - # nixos specific - udev - jre - ncurses # Needed for CLI - ] ++ (with xorg; [ - libSM - libX11 - libxcb - libXcomposite - libXcursor - libXdamage - libXext - libXfixes - libXft - libXi - libXinerama - libXrandr - libXrender - libXt - libXtst - libXxf86vm - ]); -} + # nixos specific + udev + jre + ncurses # Needed for CLI +]) ++ (with pkgs.xorg; [ + libSM + libX11 + libxcb + libXcomposite + libXcursor + libXdamage + libXext + libXfixes + libXft + libXi + libXinerama + libXrandr + libXrender + libXt + libXtst + libXxf86vm +]) diff --git a/default.nix b/default.nix index 067e3ac..f9991c1 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,10 @@ -{ callPackage }: - -# TODO: Be explicit about versions in file and object names! -let - common = import ./common.nix { }; -in { - matlab = callPackage ./matlab.nix { inherit common; }; - mlint = callPackage ./mlint.nix { inherit common; }; -} +# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; } +) { + src = ./.; +}).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5158c8a --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1606424373, + "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1620453058, + "narHash": "sha256-W10HN+A5Y0vX1TKwdEfcSelxnuPYKe5r6GBmGfufM8w=", + "owner": "doronbehar", + "repo": "nixpkgs", + "rev": "cb6c03e197a983fb440d1dd6534fdd0f986d615c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2ab6170 --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +{ + description = "Nix files made to ease imperative installation of matlab"; + + # https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix + inputs.flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + + outputs = { self, nixpkgs, flake-compat }: + let + # We don't use flake-utils.lib.eachDefaultSystem since only x86_64-linux is + # 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"; + # TODO: This doesn't work - matlab is unusable + runScriptPrefix = '' + #!${pkgs.bash}/bin/bash + export MATLAB_JAVA=/usr/lib/openjdk + export QT_QPA_PLATFORM=xcb + ''; + in { + + packages.x86_64-linux.matlab = pkgs.buildFHSUserEnv { + name = "matlab"; + inherit targetPkgs; + runScript = runScriptPrefix + '' + exec ${defaultRunPath}/bin/matlab "$@" + ''; + }; + packages.x86_64-linux.matlab-shell = pkgs.buildFHSUserEnv { + name = "matlab-shell"; + inherit targetPkgs; + }; + packages.x86_64-linux.mlint = pkgs.buildFHSUserEnv { + name = "mlint"; + inherit targetPkgs; + runScript = runScriptPrefix + '' + exec ${defaultRunPath}/bin/glnxa64/mlint "$@" + ''; + }; + overlay = final: prev: { + inherit (self.packages.x86_64-linux) matlab matlab-shell mlint; + }; + devShell.x86_64-linux = pkgs.mkShell { + buildInputs = (targetPkgs pkgs) ++ [ + self.packages.x86_64-linux.matlab-shell + ]; + }; + + defaultPackage.x86_64-linux = self.packages.x86_64-linux.matlab; + + }; +} diff --git a/matlab.nix b/matlab.nix deleted file mode 100644 index 1a270de..0000000 --- a/matlab.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ common, writeScriptBin, buildFHSUserEnv }: - -let - matlab-wrapped = with common; - writeScriptBin "matlab" '' - #!/bin/sh - export MATLAB_JAVA=/usr/lib/openjdk - export QT_QPA_PLATFORM=xcb - exec ${runPath}/bin/matlab "$@" - ''; -in buildFHSUserEnv { - name = "matlab"; - - targetPkgs = pkgs: with pkgs; (common.targetPkgs pkgs) ++ [ matlab-wrapped ]; - - runScript = "${matlab-wrapped}/bin/matlab"; -} diff --git a/mlint.nix b/mlint.nix deleted file mode 100644 index ea96854..0000000 --- a/mlint.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ common, buildFHSUserEnv }: - -buildFHSUserEnv { - name = "mlint"; - - inherit (common) targetPkgs; - - runScript = with common; "${runPath}/bin/glnxa64/mlint"; -}