unify papis config dir

This commit is contained in:
Yan Lin 2025-10-24 11:49:23 +02:00
parent 575a4bd26f
commit 6c1cfc9afa

View file

@ -1,10 +1,15 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let
# Platform-aware papis config directory
papisConfigDir = if pkgs.stdenv.isDarwin then "Library/Application Support/papis" else ".config/papis";
in
{ {
# Install papis package # Install papis package
home.packages = [ pkgs.papis ]; home.packages = [ pkgs.papis ];
# Papis configuration # Papis configuration
home.file.${if pkgs.stdenv.isDarwin then "Library/Application Support/papis/config" else ".config/papis/config"}.text = '' home.file."${papisConfigDir}/config".text = ''
[settings] [settings]
default-library = main default-library = main
editor = nvim editor = nvim
@ -39,7 +44,7 @@
''; '';
# Papis bibliography template # Papis bibliography template
home.file."Library/Application Support/papis/templates/bibitem.template".text = '' home.file."${papisConfigDir}/templates/bibitem.template".text = ''
{doc[title]} ({doc[year]}). {doc[author]}. {doc[title]} ({doc[year]}). {doc[author]}.
Venue: {doc[journal]} {doc[booktitle]} {doc[eprinttype]} {doc[eprint]} {doc[eventtitle]} Venue: {doc[journal]} {doc[booktitle]} {doc[eprinttype]} {doc[eprint]} {doc[eventtitle]}
Tags: {doc[tags]} Tags: {doc[tags]}
@ -48,7 +53,7 @@
''; '';
# Papis BibTeX template # Papis BibTeX template
home.file."Library/Application Support/papis/templates/bibtex.template".text = '' home.file."${papisConfigDir}/templates/bibtex.template".text = ''
@{doc[type]}{{{doc[ref]}, @{doc[type]}{{{doc[ref]},
author = {{{doc[author]}}}, author = {{{doc[author]}}},
title = {{{doc[title]}}}, title = {{{doc[title]}}},
@ -64,30 +69,30 @@
''; '';
# Papis citation template # Papis citation template
home.file."Library/Application Support/papis/templates/citation.template".text = '' home.file."${papisConfigDir}/templates/citation.template".text = ''
{doc[author]}. "{doc[title]}." {doc[journal]}{doc[booktitle]} ({doc[year]}). {doc[author]}. "{doc[title]}." {doc[journal]}{doc[booktitle]} ({doc[year]}).
''; '';
# Shell aliases for papis workflow # Shell aliases for papis workflow
programs.zsh.shellAliases = { programs.zsh.shellAliases = {
# Bibliography formatting # Bibliography formatting
pals = "papis list --template \"$HOME/Library/Application Support/papis/templates/bibitem.template\""; pals = "papis list --template \"$HOME/${papisConfigDir}/templates/bibitem.template\"";
# Add new entry with bibtex # Add new entry with bibtex
paadd = "papis add --from bibtex"; paadd = "papis add --from bibtex";
# BibTeX export # BibTeX export
pabib = "papis list --template \"$HOME/Library/Application Support/papis/templates/bibtex.template\""; pabib = "papis list --template \"$HOME/${papisConfigDir}/templates/bibtex.template\"";
# Citation formatting # Citation formatting
pacite = "papis list --template \"$HOME/Library/Application Support/papis/templates/citation.template\""; pacite = "papis list --template \"$HOME/${papisConfigDir}/templates/citation.template\"";
# File operations # File operations
paurl = "papis addto -u"; paurl = "papis addto -u";
# Open documents # Open documents
paopen = "papis open"; paopen = "papis open";
# Cache management # Cache management
pareset = "papis cache reset"; pareset = "papis cache reset";
}; };