fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.7 KiB63 linesraw
1{ config, lib, pkgs, ... }:
2
3let
4
5  cfg = config.programs.sagemath;
6
7  inherit (lib) literalExpression mkEnableOption mkOption types;
8
9in {
10  meta.maintainers = [ lib.maintainers.kirelagin ];
11
12  options.programs.sagemath = {
13    enable = mkEnableOption "SageMath, a mathematics software system";
14
15    package = mkOption {
16      type = types.package;
17      default = pkgs.sage;
18      defaultText = literalExpression "pkgs.sage";
19      description = "The SageMath package to use.";
20    };
21
22    configDir = mkOption {
23      type = types.str;
24      default = "${config.xdg.configHome}/sage";
25      defaultText = literalExpression "\${config.xdg.configHome}/sage";
26      description = ''
27        Directory where the {file}`sage.init` file will be stored.
28        Note that the upstream default is {file}`~/.sage`,
29        but our default is to follow XDG.
30      '';
31    };
32
33    dataDir = mkOption {
34      type = types.str;
35      default = "${config.xdg.dataHome}/sage";
36      defaultText = literalExpression "\${config.xdg.dataHome}/sage";
37      description = ''
38        Location for {env}`DOT_SAGE`.
39        Note that the upstream default is {file}`~/.sage`,
40        but our default is to follow XDG.
41      '';
42    };
43
44    initScript = mkOption {
45      type = types.lines;
46      default = "";
47      example = "%colors linux";
48      description = ''
49        Contents of the {file}`init.sage` file that is loaded on startup.
50      '';
51    };
52  };
53
54  config = lib.mkIf cfg.enable {
55    home.packages = [ cfg.package ];
56
57    home.file."${cfg.configDir}/init.sage".text = cfg.initScript;
58    home.sessionVariables = {
59      DOT_SAGE = cfg.dataDir;
60      SAGE_STARTUP_FILE = "${cfg.configDir}/init.sage";
61    };
62  };
63}