2021-12-30 12:47:44 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.sagemath;
|
|
|
|
|
|
|
|
inherit (lib) literalExpression mkEnableOption mkOption types;
|
|
|
|
|
|
|
|
in {
|
|
|
|
meta.maintainers = [ lib.maintainers.kirelagin ];
|
|
|
|
|
|
|
|
options.programs.sagemath = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "SageMath, a mathematics software system";
|
2021-12-30 12:47:44 +01:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.sage;
|
|
|
|
defaultText = literalExpression "pkgs.sage";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The SageMath package to use.";
|
2021-12-30 12:47:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
configDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${config.xdg.configHome}/sage";
|
|
|
|
defaultText = literalExpression "\${config.xdg.configHome}/sage";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Directory where the {file}`sage.init` file will be stored.
|
|
|
|
Note that the upstream default is {file}`~/.sage`,
|
2021-12-30 12:47:44 +01:00
|
|
|
but our default is to follow XDG.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${config.xdg.dataHome}/sage";
|
|
|
|
defaultText = literalExpression "\${config.xdg.dataHome}/sage";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Location for {env}`DOT_SAGE`.
|
|
|
|
Note that the upstream default is {file}`~/.sage`,
|
2021-12-30 12:47:44 +01:00
|
|
|
but our default is to follow XDG.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
initScript = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = "%colors linux";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Contents of the {file}`init.sage` file that is loaded on startup.
|
2021-12-30 12:47:44 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
home.file."${cfg.configDir}/init.sage".text = cfg.initScript;
|
|
|
|
home.sessionVariables = {
|
|
|
|
DOT_SAGE = cfg.dataDir;
|
|
|
|
SAGE_STARTUP_FILE = "${cfg.configDir}/init.sage";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|