Skip to content
Open
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
29 changes: 9 additions & 20 deletions modules/programs/texlive.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ let
inherit (lib) mkOption types;

cfg = config.programs.texlive;

texlive = cfg.packageSet;
texlivePkgs = cfg.extraPackages texlive;

in
{
meta.maintainers = [ lib.maintainers.rycee ];
Expand All @@ -20,22 +16,22 @@ in
programs.texlive = {
enable = lib.mkEnableOption "TeX Live";

packageSet = mkOption {
default = pkgs.texlive;
defaultText = lib.literalExpression "pkgs.texlive";
package = mkOption {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (blocking): keep this deprecation fix API-compatible

No migration helper is needed here. Retain packageSet, the read-only package result, and the current extraPackages contract, then replace only the implementation:

programs.texlive.package = cfg.packageSet.withPackages (
  tpkgs: lib.attrValues (cfg.extraPackages tpkgs)
);

Please move the naming redesign into a separate change with a staged migration.

type = types.package;
default = pkgs.texliveSmall;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: retain the current default behavior

Keeping packageSet = pkgs.texlive and the existing extraPackages default preserves the current collection-basic result. Remove the switch to pkgs.texliveSmall from this compatibility fix.

description = "TeX Live package set to use.";
};

extraPackages = mkOption {
default = tpkgs: { inherit (tpkgs) collection-basic; };
defaultText = "tpkgs: { inherit (tpkgs) collection-basic; }";
default = _ps: [ ];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: cover the existing caller contract

Keep a regression test where extraPackages returns an attribute set. The lib.attrValues bridge at the withPackages call site should make that existing configuration continue to evaluate.

defaultText = "_ps: [ ];";
example = lib.literalExpression ''
tpkgs: { inherit (tpkgs) collection-fontsrecommended algorithms; }
ps: with ps; [ collection-fontsrecommended algorithms ];
'';
description = "Extra packages available to TeX Live.";
};

package = mkOption {
finalPackage = mkOption {
type = types.package;
description = "Resulting customized TeX Live package.";
readOnly = true;
Expand All @@ -44,15 +40,8 @@ in
};

config = lib.mkIf cfg.enable {
assertions = [
{
assertion = texlivePkgs != { };
message = "Must provide at least one extra package in" + " 'programs.texlive.extraPackages'.";
}
];

home.packages = [ cfg.package ];
home.packages = [ cfg.finalPackage ];

programs.texlive.package = texlive.combine texlivePkgs;
programs.texlive.finalPackage = cfg.package.withPackages cfg.extraPackages;
};
}
49 changes: 29 additions & 20 deletions tests/modules/programs/texlive/texlive-minimal.nix
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
{ lib, pkgs, ... }:
{
config = {
programs.texlive.enable = true;
pkgs,
config,
...
}:

# Set up a minimal mocked texlive package set.
nixpkgs.overlays = [
(_self: _super: {
texlive = {
collection-basic = pkgs.writeTextDir "collection-basic" "";
combine =
tpkgs:
pkgs.symlinkJoin {
name = "dummy-texlive-combine";
paths = lib.attrValues tpkgs;
};
};
})
];
let
inherit (config.lib.test) mkStubPackage;

nmt.script = ''
assertFileExists home-path/collection-basic
'';
fakeTexliveSet = {
collection-basic = pkgs.writeTextDir "collection-basic" "";
};
in
{
programs.texlive = {
enable = true;
package = mkStubPackage {
name = "texlive";
extraAttrs = {
withPackages =
tpkgs:
pkgs.symlinkJoin {
name = "dummy-texlive-combine";
paths = tpkgs fakeTexliveSet;
};
};
};
extraPackages = ps: with ps; [ collection-basic ];
};

nmt.script = ''
assertFileExists home-path/collection-basic
'';
}
Loading