Matlab License Server

Update Matlab License to Include "SERVER {hostname} {HostID} 27000"

Update MATLAB License for DAEMON line

Matlab: Update Concurrent License

Matlab: Cleanup Config

Matlab: Hide HOSTID in secrets
master
David Crompton 2024-02-06 11:01:16 -05:00
parent 9fd4f2c67c
commit af5774ba66
8 changed files with 135 additions and 59 deletions

View File

@ -20,6 +20,7 @@
./nosleep.nix ./nosleep.nix
]; ];
sops.age.keyFile = "/root/.config/sops/age/keys.txt";
sops.defaultSopsFile = ./secrets/system.yaml; sops.defaultSopsFile = ./secrets/system.yaml;
# Support NTFS(3g) # Support NTFS(3g)

View File

@ -1,54 +1,7 @@
{ config, lib, pkgs, nix-matlab, ... }: let { config, lib, pkgs, nix-matlab, ... }: {
license-manager = pkgs.stdenv.mkDerivation rec {
pname = "matlab-license-server";
version = "R2023b";
src = pkgs.fetchurl {
url = "https://ssd.mathworks.com/supportfiles/downloads/${version}/license_manager/${version}/daemons/glnxa64/mathworks_network_license_manager_glnxa64.zip";
hash = "sha256-Btl3ETzTtAV+cjqwXf4AE4QJCtssN1s6dmmcpR1EQxY=";
};
nativeBuildInputs = [
pkgs.autoPatchelfHook
];
unpackPhase = ''
${pkgs.unzip}/bin/unzip $src
'';
installPhase = ''
mkdir $out
cp -r * $out/
addAutoPatchelfSearchPath $out/*
'';
};
matlab-server = pkgs.buildFHSUserEnv {
name = "matlab-server";
targetPkgs = (ps: nix-matlab.targetPkgs ps ++ [
license-manager
]);
runScript = pkgs.writeScript "matlab-server" (nix-matlab.shellHooksCommon + ''
exec $MATLAB_INSTALL_DIR/bin/matlab "$@"
'');
};
matlab-server-shell = pkgs.buildFHSUserEnv {
name = "matlab-server-shell";
targetPkgs = (ps: nix-matlab.targetPkgs ps ++ [
license-manager
]);
runScript = pkgs.writeScript "matlab-server-shell" (nix-matlab.shellHooksCommon + ''
echo license-server is in:
echo ${license-manager}
echo Make sure it is installed (matlab-server user)
exec bash
'');
};
in {
environment.systemPackages = (with nix-matlab.packages.x86_64-linux; [ environment.systemPackages = (with nix-matlab.packages.x86_64-linux; [
matlab matlab
matlab-shell matlab-shell
matlab-server
matlab-server-shell
matlab-mlint matlab-mlint
matlab-mex matlab-mex
]) ++ (with pkgs; [ ]) ++ (with pkgs; [

View File

@ -0,0 +1,20 @@
{
"data": "ENC[AES256_GCM,data:JrTc6ZePtcii5ygWjkFatJUJNiEUa6eFzsWVJWdPwDche9O68oD+rDpHe5CTjWzsXQB9,iv:+LkH3EAi8aUzABBLQ/FJwFPtEvgUb+MN2LFvehN+2/M=,tag:C2M9ChEdpKehzMaM5Gd3bA==,type:str]",
"sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [
{
"recipient": "age1cvmffz227lhsvy4ufh0gnkfsvs5f27hv5l90m0lf4558uphteefsj2t74j",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBvb0FWYmUwN2QvdWdWbTNS\nSll1VWVRQVRJb1FVT2YyeWVEV1A0dVljS2pZCndRTnNUYk82dytNMjdIQWZ1b3pu\nRjBQZXIwVVlza01lMlNtVlhtRm9JTTQKLS0tIHZZdEtRL1I0djhOL2dkSkhleW83\nWHM4cUZKY1M0QnpCRTMzMDRIWHJTbFEKI85Z0wTXVkUE3KtTjfyzSYCDT2EQmZWf\nSq8FZuUlzGfVfh+R+gUZ1g8V76gNwzHI55MM+CEBh6EuVSyotY0AEA==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2024-02-07T16:50:53Z",
"mac": "ENC[AES256_GCM,data:wzjlt/EoF1KJ3oDw/bqkPAxTO+hGS4eWtHERD6HT0FkseHVoXVo+n53SDAkj7z8vnsx3au8QhP8FL8JWoyDVf0SrHHk7W8cqV203eUnVapJsV9IanOvCfvcENrQ2eLV8R97t3nUfyfcABUK45fL6ku6jZ3sKsS2U1eS7/atENmU=,iv:fUWBcvAcckCnEKfYQeSebYQS+0jzzvlXtBen2VL+Lqc=,tag:Fap2p5nRewKbVXa0eEUUbg==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted",
"version": "3.8.1"
}
}

File diff suppressed because one or more lines are too long

View File

@ -10,5 +10,7 @@
./servers/overleaf.nix ./servers/overleaf.nix
# Basic remote editting in jupyer notebooks # Basic remote editting in jupyer notebooks
./servers/jupyterhub.nix ./servers/jupyterhub.nix
# MATLAB License Server
./servers/matlab-license-server.nix
]; ];
} }

View File

@ -0,0 +1,91 @@
{ config, lib, pkgs, ... }: let
# Make sure that the license manager version matches the currently
# issued license to KCNHUB in the License Centre.
license-manager = pkgs.stdenv.mkDerivation rec {
pname = "matlab-license-server";
version = "R2023b";
src = pkgs.fetchurl {
url = "https://ssd.mathworks.com/supportfiles/downloads/${version}/license_manager/${version}/daemons/glnxa64/mathworks_network_license_manager_glnxa64.zip";
hash = "sha256-Btl3ETzTtAV+cjqwXf4AE4QJCtssN1s6dmmcpR1EQxY=";
};
nativeBuildInputs = [
pkgs.autoPatchelfHook
];
unpackPhase = ''
${pkgs.unzip}/bin/unzip $src
'';
installPhase = ''
mkdir $out
cp -r * $out/
addAutoPatchelfSearchPath $out/*
'';
};
matlab-server-user = "matlab-server";
homedir = "/var/lib/${matlab-server-user}";
# Make sure this is up to date with the latest license file
# by editting secrets/matlab-network.lic
NETWORK_LICENSE = config.sops.secrets.matlab-network-license.path;
PORT = 27000;
in {
users.users.${matlab-server-user} = {
isSystemUser = true;
home = homedir;
useDefaultShell = true;
group = matlab-server-user;
};
users.groups.${matlab-server-user} = {};
sops.secrets.matlab-license = {
sopsFile = ../secrets/matlab.lic;
format = "binary";
owner = matlab-server-user;
restartUnits = [ "matlab-license-server.service" ];
};
sops.secrets.matlab-network-license = {
sopsFile = ../secrets/matlab-network.lic;
format = "binary";
owner = matlab-server-user;
mode = "0444";
restartUnits = [ "matlab-license-server.service" ];
};
systemd.services.matlab-license-server = {
# Start on boot
enable = true;
# When multi user login is loaded, matlab-server user can be used
wantedBy = [ "multi-user.target" ];
# The license server has to be after networking is available
after = [ "network.target" ];
description = "MATLAB License Server";
serviceConfig = {
Type = "forking";
User = matlab-server-user;
Group = matlab-server-user;
RuntimeDirectory = matlab-server-user;
WorkingDirectory = homedir;
ExecStartPre = pkgs.writeScript "matlab-license-serverify" ''
#!${pkgs.bash}/bin/bash
head -n1 ${NETWORK_LICENSE} > ${homedir}/license.lic
echo 'DAEMON MLM DAEMON MLM ${license-manager}/etc/glnxa64/MLM' >> ${homedir}/license.lic
cat ${config.sops.secrets.matlab-license.path} >> ${homedir}/license.lic
'';
ExecStart = "${license-manager}/etc/glnxa64/lmgrd -c ${homedir}/license.lic";
};
};
environment.sessionVariables = {
LM_LICENSE_FILE = NETWORK_LICENSE;
MLM_LICENSE_FILE = NETWORK_LICENSE;
};
networking.firewall.allowedTCPPorts = [
PORT
];
networking.firewall.allowedUDPPorts = [
PORT
];
}

View File

@ -5,7 +5,6 @@
./users/carol.nix ./users/carol.nix
./users/alan.nix ./users/alan.nix
./users/spandan.nix ./users/spandan.nix
./users/matlab-server.nix
./users/frances.nix ./users/frances.nix
./users/srikar.nix ./users/srikar.nix
./users/zhenyangsun.nix ./users/zhenyangsun.nix

View File

@ -1,10 +0,0 @@
{ pkgs, ... }: {
users.users.matlab-server = {
isNormalUser = true;
homeSize = "15g";
homeProjectId = 105;
packages = with pkgs; [
];
};
}