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, ... }:
let
# Platform-aware papis config directory
papisConfigDir = if pkgs.stdenv.isDarwin then "Library/Application Support/papis" else ".config/papis";
in
{
# Install papis package
home.packages = [ pkgs.papis ];
# 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]
default-library = main
editor = nvim
@ -39,7 +44,7 @@
'';
# 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]}.
Venue: {doc[journal]} {doc[booktitle]} {doc[eprinttype]} {doc[eprint]} {doc[eventtitle]}
Tags: {doc[tags]}
@ -48,7 +53,7 @@
'';
# Papis BibTeX template
home.file."Library/Application Support/papis/templates/bibtex.template".text = ''
home.file."${papisConfigDir}/templates/bibtex.template".text = ''
@{doc[type]}{{{doc[ref]},
author = {{{doc[author]}}},
title = {{{doc[title]}}},
@ -64,30 +69,30 @@
'';
# 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]}).
'';
# Shell aliases for papis workflow
programs.zsh.shellAliases = {
# 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
paadd = "papis add --from bibtex";
# 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
pacite = "papis list --template \"$HOME/Library/Application Support/papis/templates/citation.template\"";
pacite = "papis list --template \"$HOME/${papisConfigDir}/templates/citation.template\"";
# File operations
paurl = "papis addto -u";
# Open documents
paopen = "papis open";
# Cache management
pareset = "papis cache reset";
};