texTemplate/flake.nix

144 lines
4.9 KiB
Nix
Raw Normal View History

{
description = "Put a short description here";
inputs = {
nixpkgs = {
type = "indirect";
id = "nixpkgs";
};
};
outputs = {self, nixpkgs} :
let
# name to be used as identifier for editor environments and such
name = "Name";
#Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
# System types to support.
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in {
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
# LaTex package dependencies
latexdeps = {inherit (pkgs.texlive) scheme-small;};
latex = pkgs.texlive.combine latexdeps;
latexrun = pkgs.latexrun;
in {
default = pkgs.stdenvNoCC.mkDerivation {
name = "output.pdf";
buildInputs = [latex latexrun pkgs.biber];
src = self;
buildPhase = ''
latexrun -o output.pdf src/Main.tex
'';
installPhase = ''
mkdir -p $out
cp output.pdf $out/output.pdf
'';
};
}
);
devShells = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
2022-06-17 15:44:01 +02:00
in ( rec {
2022-06-19 15:22:08 +02:00
# This sets the default devShell
2022-06-17 15:44:01 +02:00
default = kakoune;
kakoune =
let
texlab = pkgs.texlab;
latexTmpDir = "src/latex.out/";
myKakoune =
let
# this could also be done by generating toml with the
# nixpkgs lib, but I'm lazy
kak-lsp-config = pkgs.writeTextFile {
name = "kak-lsp-config.toml";
text = ''
[language.latex]
filetypes = ["latex"]
roots = [".git"]
command = "texlab"
# args = ["-vvvv", "--log-file", "/tmp/texlabLog"]
settings_section = "texlab"
[language.latex.settings.texlab.build]
onSave = true
executable = "latexrun"
args = ["--bibtex-cmd", "biber", "--latex-args", "'-synctex=1'","%f"]
forwardSearchAfter = true
[language.latex.settings.texlab.forwardSearch]
executable = "zathura"
args = ["--synctex-forward", "%l:1:%f", "%p"]
[language.latex.settings.texlab]
auxDirectory = "${latexTmpDir}"
'';
};
config = pkgs.writeTextFile (rec {
name = "kakrc.kak";
destination = "/share/kak/autoload/${name}";
text = ''
colorscheme solarized-dark
set global tabstop 2
set global indentwidth 2
# eval %sh{kak-lsp --kakoune --session $kak_session -c ${kak-lsp-config} --log /tmp/kak-lspLog -vvvv}
eval %sh{kak-lsp --kakoune --session $kak_session -c ${kak-lsp-config}}
hook global WinSetOption filetype=(latex) %{
lsp-auto-hover-enable
lsp-enable-window
}
add-highlighter global/ number-lines
map global normal <c-p> ': fzf-mode<ret>'
'';
});
in
pkgs.kakoune.override {
plugins = with pkgs.kakounePlugins; [fzf-kak kak-lsp config];
};
in
pkgs.mkShellNoCC {
inputsFrom = [self.outputs.packages.${system}.default];
packages = [myKakoune texlab pkgs.git pkgs.zathura pkgs.fzf];
2022-06-19 15:22:08 +02:00
# TODO only try to start the kakoune session if no session with that
# name exists
shellHook = ''
alias ..="cd .."
mkdir -p ${latexTmpDir}
export KAKOUNE_CONFIG_DIR="/dev/null/"
kak -d -s ${name} &
alias vim="kak -c ${name}"
'';
2022-06-17 15:44:01 +02:00
};
texstudio =
pkgs.mkShellNoCC {
inputsFrom = [self.outputs.packages.${system}.default];
packages = [pkgs.texstudio pkgs.git];
2022-06-19 15:22:08 +02:00
shellHook = ''
texstudio
'';
2022-06-17 15:44:01 +02:00
};
2022-06-17 15:44:01 +02:00
texmaker =
pkgs.mkShellNoCC {
inputsFrom = [self.outputs.packages.${system}.default];
packages = [pkgs.texmaker pkgs.git];
2022-06-19 15:22:08 +02:00
shellHook = ''
texmaker
'';
2022-06-17 15:44:01 +02:00
};
})
);
};
}