aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wells <chris@mathematicaster.org>2026-02-22 22:57:53 -0600
committerChris Wells <chris@mathematicaster.org>2026-02-22 22:57:53 -0600
commit51728e2a5b26518cecd135ef32377798c55c78d6 (patch)
treef6f31416f843e61b612ba9ea35e54db0ff515e74
parentba9ba34bd10cfa59ad4fe2945eb5c9976b2b609b (diff)
downloadtex-shell-51728e2a5b26518cecd135ef32377798c55c78d6.tar
tex-shell-51728e2a5b26518cecd135ef32377798c55c78d6.tar.gz
tex-shell-51728e2a5b26518cecd135ef32377798c55c78d6.tar.bz2
tex-shell-51728e2a5b26518cecd135ef32377798c55c78d6.tar.lz
tex-shell-51728e2a5b26518cecd135ef32377798c55c78d6.tar.xz
tex-shell-51728e2a5b26518cecd135ef32377798c55c78d6.tar.zst
tex-shell-51728e2a5b26518cecd135ef32377798c55c78d6.zip
Added formatters
-rw-r--r--.envrc1
-rw-r--r--flake.lock53
-rw-r--r--flake.nix43
-rw-r--r--module.nix114
-rw-r--r--template/flake.nix44
5 files changed, 170 insertions, 85 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..a5dbbcb
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake .
diff --git a/flake.lock b/flake.lock
index 99004ba..c692a95 100644
--- a/flake.lock
+++ b/flake.lock
@@ -18,6 +18,21 @@
"type": "github"
}
},
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1771817828,
+ "narHash": "sha256-G+UqAH3kbz9Ux7uM0+iazOBxoX4DVy9zJzTbDx+OXEs=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "56d662f5e3fdfaf7e87f96b9000d0aec012f13ff",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
"nixpkgs-lib": {
"locked": {
"lastModified": 1769909678,
@@ -33,10 +48,28 @@
"type": "github"
}
},
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1770107345,
+ "narHash": "sha256-tbS0Ebx2PiA1FRW8mt8oejR0qMXmziJmPaU1d4kYY9g=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "4533d9293756b63904b7238acb84ac8fe4c8c2c4",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
"root": {
"inputs": {
"flake-parts": "flake-parts",
- "systems": "systems"
+ "nixpkgs": "nixpkgs",
+ "systems": "systems",
+ "treefmt-nix": "treefmt-nix"
}
},
"systems": {
@@ -53,6 +86,24 @@
"repo": "default",
"type": "github"
}
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": "nixpkgs_2"
+ },
+ "locked": {
+ "lastModified": 1770228511,
+ "narHash": "sha256-wQ6NJSuFqAEmIg2VMnLdCnUc0b7vslUohqqGGD+Fyxk=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "337a4fe074be1042a35086f15481d763b8ddc0e7",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
+ }
}
},
"root": "root",
diff --git a/flake.nix b/flake.nix
index d17aca5..ba74979 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,18 +2,47 @@
description = "TeX devShell for flake-parts";
inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
+ treefmt-nix.url = "github:numtide/treefmt-nix";
systems.url = "github:nix-systems/default";
};
- outputs = inputs @ { self, flake-parts, ... }: flake-parts.lib.mkFlake { inherit self inputs; } {
- systems = import inputs.systems;
+ outputs =
+ inputs@{ self, flake-parts, ... }:
+ flake-parts.lib.mkFlake { inherit self inputs; } {
+ systems = import inputs.systems;
- flake.flakeModules.default = ./module.nix;
+ imports = [ inputs.treefmt-nix.flakeModule ];
- flake.templates.default = {
- path = ./template;
- description = "TeX-utils default template";
+ flake.flakeModules.default = ./module.nix;
+
+ flake.templates.default = {
+ path = ./template;
+ description = "TeX-utils default template";
+ };
+
+ perSystem =
+ { config, pkgs, ... }:
+ {
+ treefmt = {
+ programs = {
+ nixfmt = {
+ enable = true;
+ strict = true;
+ };
+ };
+ };
+
+ devShells.default = pkgs.mkShellNoCC {
+ inputsFrom = [ config.treefmt.build.devShell ];
+ nativeBuildInputs = with pkgs; [
+ nixd
+ statix
+ deadnix
+ ];
+ };
+
+ };
};
- };
}
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 ]);
};
- };
- });
+ }
+ );
}
diff --git a/template/flake.nix b/template/flake.nix
index 498cda1..59878c1 100644
--- a/template/flake.nix
+++ b/template/flake.nix
@@ -8,32 +8,30 @@
systems.url = "github:nix-systems/default";
};
- outputs = inputs @ { self, flake-parts, ... }: flake-parts.lib.mkFlake { inherit self inputs; } {
- systems = import inputs.systems;
+ outputs =
+ inputs@{ self, flake-parts, ... }:
+ flake-parts.lib.mkFlake { inherit self inputs; } {
+ systems = import inputs.systems;
- imports = [
- inputs.tex-shell.flakeModules.default
- ];
+ imports = [ inputs.tex-shell.flakeModules.default ];
- perSystem = { pkgs, config, ... }: {
+ perSystem =
+ { pkgs, config, ... }:
+ {
- texShell = {
- scheme = pkgs.texliveSmall;
- latexmk = {
- enable = true;
- rc = /* perl */ ''
- $out_dir = '.latex-build';
- $pdf_mode = 1;
- $pdflatex = 'pdflatex -interaction=nonstopmode %O %S';
- '';
- };
- };
+ texShell = {
+ scheme = pkgs.texliveSmall;
+ latexmk = {
+ enable = true;
+ rc = /* perl */ ''
+ $out_dir = '.latex-build';
+ $pdf_mode = 1;
+ $pdflatex = 'pdflatex -interaction=nonstopmode %O %S';
+ '';
+ };
+ };
- devShells.default = pkgs.mkShell {
- inputsFrom = [
- config.devShells.texShell
- ];
- };
+ devShells.default = pkgs.mkShellNoCC { inputsFrom = [ config.texShell.build.devShell ]; };
+ };
};
- };
}