From e150dd4a66f0747241d4b77b997a6eed964a59d6 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 9 Jan 2019 02:09:23 +0100 Subject: [PATCH] texlive: always require at least one extra package Fixes #526 --- modules/programs/texlive.nix | 17 ++++++++++++++--- tests/default.nix | 1 + tests/modules/programs/texlive-minimal.nix | 13 +++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/modules/programs/texlive-minimal.nix diff --git a/modules/programs/texlive.nix b/modules/programs/texlive.nix index e857a062..0f8953e9 100644 --- a/modules/programs/texlive.nix +++ b/modules/programs/texlive.nix @@ -6,6 +6,8 @@ let cfg = config.programs.texlive; + texlivePkgs = cfg.extraPackages pkgs.texlive; + in { @@ -16,7 +18,8 @@ in enable = mkEnableOption "Texlive"; extraPackages = mkOption { - default = self: {}; + default = tpkgs: { inherit (tpkgs) collection-basic; }; + defaultText = "tpkgs: { inherit (tpkgs) collection-basic; }"; example = literalExample '' tpkgs: { inherit (tpkgs) collection-fontsrecommended algorithms; } ''; @@ -32,8 +35,16 @@ in }; config = mkIf cfg.enable { + assertions = [ + { + assertion = texlivePkgs != {}; + message = "Must provide at least one extra package in" + + " 'programs.texlive.extraPackages'."; + } + ]; + home.packages = [ cfg.package ]; - programs.texlive.package = - pkgs.texlive.combine (cfg.extraPackages pkgs.texlive); + + programs.texlive.package = pkgs.texlive.combine texlivePkgs; }; } diff --git a/tests/default.nix b/tests/default.nix index a17bdadb..1935a37c 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -18,6 +18,7 @@ import nmt { tests = { "git/with-most-options" = ./modules/programs/git.nix; "git/with-str-extra-config" = ./modules/programs/git-with-str-extra-config.nix; + texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; }; } diff --git a/tests/modules/programs/texlive-minimal.nix b/tests/modules/programs/texlive-minimal.nix new file mode 100644 index 00000000..df143dbc --- /dev/null +++ b/tests/modules/programs/texlive-minimal.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + programs.texlive.enable = true; + + nmt.script = '' + assertFileExists home-path/bin/tex + ''; + }; +}