2013-10-16 17:23:58 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.gurobi;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
programs.gurobi = {
|
|
|
|
license = mkOption {
|
|
|
|
default = null;
|
|
|
|
|
|
|
|
description = "Path to the Gurobi license file if not using a token server";
|
|
|
|
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
};
|
|
|
|
|
|
|
|
tokenServerAddress = mkOption {
|
|
|
|
default = null;
|
|
|
|
|
|
|
|
description = "Address of the token server";
|
|
|
|
|
|
|
|
type = types.nullOr types.string;
|
|
|
|
};
|
|
|
|
};
|
2013-10-16 22:01:27 +02:00
|
|
|
};
|
2013-10-16 17:23:58 +02:00
|
|
|
|
2013-10-16 22:01:27 +02:00
|
|
|
config = mkIf (cfg.license != null || cfg.tokenServerAddress != null) {
|
|
|
|
assertions = [ {
|
|
|
|
assertion = cfg.license == null || cfg.tokenServerAddress == null;
|
|
|
|
message = "Please only set one of a gurobi license file and a gurobi token server address";
|
|
|
|
} ];
|
|
|
|
|
|
|
|
environment.variables.GRB_LICENSE_FILE = if cfg.license != null
|
|
|
|
then cfg.license
|
|
|
|
else pkgs.writeTextFile {
|
|
|
|
name = "gurobi-generated-license";
|
|
|
|
text = "TOKENSERVER=${cfg.tokenServerAddress}";
|
|
|
|
};
|
2013-10-16 17:26:39 +02:00
|
|
|
|
2013-10-16 22:01:27 +02:00
|
|
|
environment.systemPackages = [ pkgs.gurobi ];
|
2013-10-16 17:23:58 +02:00
|
|
|
};
|
|
|
|
}
|