mirror of
https://git.adityakumar.xyz/nix-matlab.git
synced 2024-12-26 18:22:53 +00:00
Introduce a flake, modern setup
This commit is contained in:
parent
a476a83bc7
commit
11817b35d1
8 changed files with 184 additions and 93 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
result
|
23
README.adoc
Normal file
23
README.adoc
Normal file
|
@ -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 +++<s>stable</s>+++ 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.
|
110
common.nix
110
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
|
||||
])
|
||||
|
|
19
default.nix
19
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
|
||||
|
|
42
flake.lock
Normal file
42
flake.lock
Normal file
|
@ -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
|
||||
}
|
56
flake.nix
Normal file
56
flake.nix
Normal file
|
@ -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;
|
||||
|
||||
};
|
||||
}
|
17
matlab.nix
17
matlab.nix
|
@ -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";
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
{ common, buildFHSUserEnv }:
|
||||
|
||||
buildFHSUserEnv {
|
||||
name = "mlint";
|
||||
|
||||
inherit (common) targetPkgs;
|
||||
|
||||
runScript = with common; "${runPath}/bin/glnxa64/mlint";
|
||||
}
|
Loading…
Reference in a new issue