aboutsummaryrefslogtreecommitdiff
path: root/module.nix
diff options
context:
space:
mode:
Diffstat (limited to 'module.nix')
-rw-r--r--module.nix114
1 files changed, 60 insertions, 54 deletions
diff --git a/module.nix b/module.nix
index 2aabaed..37307c1 100644
--- a/module.nix
+++ b/module.nix
@@ -1,65 +1,71 @@
-{
- lib,
- flake-parts-lib,
- ...
-}:
+{ lib, flake-parts-lib, ... }:
let
- inherit (lib) mkIf mkOption mkPackageOption mkEnableOption types;
+ inherit (lib)
+ mkIf
+ mkOption
+ mkPackageOption
+ mkEnableOption
+ types
+ ;
inherit (flake-parts-lib) mkPerSystemOption;
-in {
- options.perSystem = mkPerSystemOption ({ config, ... }: {
- options = {
- texShell = {
- scheme = mkPackageOption pkgs "texliveSmall" {};
- extraPackages = mkOption {
- type = types.functionTo (types.listOf types.package);
- description = "Extra packages to add to the texlive scheme";
- default = _: [];
- };
- latexmk = {
- enable = mkEnableOption "latexmk";
- rc = mkOption {
- type = types.lines;
- description = "contents of the .latexmkrc file";
+in
+{
+ options.perSystem = mkPerSystemOption (
+ { config, pkgs, ... }:
+ {
+ options = {
+ texShell = {
+ scheme = mkPackageOption pkgs "texliveSmall" { };
+ extraPackages = mkOption {
+ type = types.functionTo (types.listOf types.package);
+ description = "Extra packages to add to the texlive scheme";
+ default = _: [ ];
};
- rcFile = mkOption {
- type = types.path;
- default = pkgs.writeText "latexmkrc" config.texShell.latexmk.rc;
- description = "the .latexmkrc file";
+ latexmk = {
+ enable = mkEnableOption "latexmk";
+ rc = mkOption {
+ type = types.lines;
+ description = "contents of the .latexmkrc file";
+ };
+ rcFile = mkOption {
+ type = types.path;
+ default = pkgs.writeText "latexmkrc" config.texShell.latexmk.rc;
+ description = "the .latexmkrc file";
+ };
+ _wrapper = mkOption {
+ type = types.functionTo types.package;
+ readOnly = true;
+ internal = true;
+ default =
+ tex:
+ pkgs.symlinkJoin {
+ inherit (tex) name;
+ nativeBuildInputs = [ pkgs.makeWrapper ];
+ paths = [ tex ];
+ postBuild = ''
+ wrapProgram $out/bin/latexmk --add-flags "-r" --add-flags "${config.texShell.latexmk.rcFile}"
+ '';
+ };
+ };
};
- _wrapper = mkOption {
- type = types.functionTo types.package;
- readOnly = true;
- internal = true;
- default = tex: pkgs.symlinkJoin {
- inherit (tex) name;
- nativeBuildInputs = [
- pkgs.makeWrapper
- ];
- paths = [
- tex
- ];
- postBuild = ''
- wrapProgram $out/bin/latexmk --add-flags "-r" --add-flags "${config.texShell.latexmk.rcFile}"
- '';
+ build = {
+ package = mkOption {
+ type = types.package;
+ readOnly = true;
+ default =
+ let
+ wrapper = if config.texShell.latexmk.enable then config.texShell.latexmk._wrapper else x: x;
+ in
+ wrapper (config.texShell.scheme.withPackages config.texShell.extraPackages);
};
+ devShell = pkgs.mkShellNoCC { nativeBuildInputs = [ config.texShell.build.package ]; };
};
};
};
- };
-
- config = {
- texShell.extraPackages = mkIf config.texShell.latexmk.enable (ps: [ ps.latexmk ]);
-
- packages.texShell = let
- wrapper = if config.texShell.latexmk.enable then config.texShell.latexmk._wrapper else x: x;
- in wrapper (config.texShell.scheme.withPackages config.texShell.scheme.extraPackages);
- devShells.texShell = pkgs.makeShell {
- nativeBuildInputs = [
- config.packages.texShell
- ];
+ config = {
+ texShell.extraPackages = mkIf config.texShell.latexmk.enable (ps: [ ps.latexmk ]);
};
- };
- });
+ }
+ );
}