1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

sagemath: add module

This commit is contained in:
Kirill Elagin 2021-12-30 06:47:44 -05:00 committed by Robert Helgesson
parent 5a8b29bc7a
commit 204f9808d3
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
8 changed files with 97 additions and 0 deletions

3
.github/CODEOWNERS vendored
View file

@ -194,6 +194,9 @@
/modules/programs/rtorrent.nix @marsam
/modules/programs/sagemath.nix @kirelagin
/tests/modules/programs/sagemath @kirelagin
/modules/programs/sbt.nix @kubukoz
/tests/modules/programs/sbt @kubukoz

View file

@ -2344,6 +2344,13 @@ in
A new module is available: 'services.swayidle'.
'';
}
{
time = "2022-01-11T12:26:43+00:00";
message = ''
A new module is available: 'programs.sagemath'.
'';
}
];
};
}

View file

@ -128,6 +128,7 @@ let
./programs/rofi-pass.nix
./programs/rofi.nix
./programs/rtorrent.nix
./programs/sagemath.nix
./programs/sbt.nix
./programs/scmpuff.nix
./programs/senpai.nix

View file

@ -0,0 +1,63 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.sagemath;
inherit (lib) literalExpression mkEnableOption mkOption types;
in {
meta.maintainers = [ lib.maintainers.kirelagin ];
options.programs.sagemath = {
enable = mkEnableOption "SageMath, a mathematics software system";
package = mkOption {
type = types.package;
default = pkgs.sage;
defaultText = literalExpression "pkgs.sage";
description = "The SageMath package to use.";
};
configDir = mkOption {
type = types.str;
default = "${config.xdg.configHome}/sage";
defaultText = literalExpression "\${config.xdg.configHome}/sage";
description = ''
Directory where the <filename>sage.init</filename> file will be stored.
Note that the upstream default is <filename>~/.sage</filename>,
but our default is to follow XDG.
'';
};
dataDir = mkOption {
type = types.str;
default = "${config.xdg.dataHome}/sage";
defaultText = literalExpression "\${config.xdg.dataHome}/sage";
description = ''
Location for <envar>DOT_SAGE</envar>.
Note that the upstream default is <filename>~/.sage</filename>,
but our default is to follow XDG.
'';
};
initScript = mkOption {
type = types.lines;
default = "";
example = "%colors linux";
description = ''
Contents of the <filename>init.sage</filename> file that is loaded on startup.
'';
};
};
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";
};
};
}

View file

@ -89,6 +89,7 @@ import nmt {
./modules/programs/powerline-go
./modules/programs/qutebrowser
./modules/programs/readline
./modules/programs/sagemath
./modules/programs/sbt
./modules/programs/scmpuff
./modules/programs/sm64ex

View file

@ -0,0 +1 @@
{ sagemath = ./sagemath.nix; }

View file

@ -0,0 +1 @@
%colors linux

View file

@ -0,0 +1,20 @@
{ config, ... }:
{
programs.sagemath = {
enable = true;
configDir = "${config.xdg.configHome}/sage";
dataDir = "${config.xdg.dataHome}/sage";
initScript = ''
%colors linux
'';
};
test.stubs.sage = { };
nmt.script = ''
assertFileExists home-files/.config/sage/init.sage
assertFileContent home-files/.config/sage/init.sage \
${./init-expected.sage}
'';
}