Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

texlive: switch to the new withPackages API #1522

Merged
merged 7 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions docs/reference/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -6276,20 +6276,26 @@ boolean



Packages available to TeX Live
Extra packages to add to the base TeX Live set



*Type:*
non-empty (list of string)
list of string



*Default:*
` [ ] `



*Example:*

```
[
"collection-basic"
"algorithms"
"latexmk"
]
```

Expand All @@ -6312,7 +6318,12 @@ unspecified value


*Default:*
` pkgs.texlive `
` pkgs.texliveSmall `



*Example:*
` pkgs.texliveBasic `

*Declared by:*
- [https://github.com/cachix/devenv/blob/main/src/modules/languages/texlive.nix](https://github.com/cachix/devenv/blob/main/src/modules/languages/texlive.nix)
Expand Down
19 changes: 15 additions & 4 deletions docs/supported-languages/texlive.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,26 @@ boolean



Packages available to TeX Live
Extra packages to add to the base TeX Live set



*Type:*
non-empty (list of string)
list of string



*Default:*
` [ ] `



*Example:*

```
[
"collection-basic"
"algorithms"
"latexmk"
]
```

Expand All @@ -61,4 +67,9 @@ unspecified value


*Default:*
` pkgs.texlive `
` pkgs.texliveSmall `



*Example:*
` pkgs.texliveBasic `
4 changes: 4 additions & 0 deletions examples/texlive/.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -ex

which latexmk
8 changes: 7 additions & 1 deletion examples/texlive/devenv.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{ pkgs, ... }:

{
# https://nixos.org/manual/nixpkgs/stable/#sec-language-texlive
languages.texlive = {
enable = true;
packages = [ "scheme-small" "biblatex" "latexmk" ];

# Choose a base package set.
base = pkgs.texliveSmall;

# Add extra packages to the base set.
packages = [ "latexmk" ];
};
}
17 changes: 9 additions & 8 deletions src/modules/languages/texlive.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
let
cfg = config.languages.texlive;

base = cfg.base;
packages = lib.genAttrs cfg.packages (name: base.${name} or (throw "No such texlive package ${name}"));
package = base.combine packages;
getPackage = ps: name: ps.${name} or (throw "No such texlive package ${name}");
package = cfg.base.withPackages (ps: builtins.map (getPackage ps) cfg.packages);
in
{
options.languages.texlive = {
enable = lib.mkEnableOption "TeX Live";
base = lib.mkOption {
default = pkgs.texlive;
defaultText = lib.literalExpression "pkgs.texlive";
default = pkgs.texliveSmall;
defaultText = lib.literalExpression "pkgs.texliveSmall";
example = lib.literalExpression "pkgs.texliveBasic";
description = "TeX Live package set to use";
};
packages = lib.mkOption {
type = lib.types.nonEmptyListOf lib.types.str;
default = [ "collection-basic" ];
description = "Packages available to TeX Live";
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "algorithms" "latexmk" ];
description = "Extra packages to add to the base TeX Live set";
};
};
config = lib.mkIf cfg.enable {
Expand Down
Loading