nixpkgs/pkgs/applications/networking/mailreaders/aerc/runtime-sharedir.patch

61 lines
2 KiB
Diff
Raw Normal View History

2021-01-20 16:30:03 +01:00
From c715a96c693baa0e6c8ab3c96b6c10e0a40bf7af Mon Sep 17 00:00:00 2001
From: Tadeo Kondrak <me@tadeo.ca>
2021-01-20 16:30:03 +01:00
Date: Thu, 21 Jan 2021 10:40:49 +0100
Subject: [PATCH] Fix aerc breaking every time the package is rebuilt.
On NixOS, the SHAREDIR changes on every rebuild to the package, but aerc
fills it in as part of the default config and then installs that config
to the users home folder. Fix this by not substituting @SHAREDIR@ in the
default config until runtime.
---
2021-01-20 16:30:03 +01:00
Makefile | 2 +-
config/config.go | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
2021-01-20 16:30:03 +01:00
index 77f5e61..98cbc11 100644
--- a/Makefile
+++ b/Makefile
2021-01-20 16:30:03 +01:00
@@ -23,7 +23,7 @@ aerc: $(GOSRC)
-o $@
2021-01-20 16:30:03 +01:00
aerc.conf: config/aerc.conf.in
- sed -e 's:@SHAREDIR@:$(SHAREDIR):g' > $@ < config/aerc.conf.in
+ cat config/aerc.conf.in > $@
2021-01-20 16:30:03 +01:00
debug: $(GOSRC)
GOFLAGS="-tags=notmuch" \
diff --git a/config/config.go b/config/config.go
2021-01-20 16:30:03 +01:00
index 87d183a..cb6611a 100644
--- a/config/config.go
+++ b/config/config.go
2021-01-20 16:30:03 +01:00
@@ -470,6 +470,16 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
return nil, err
}
}
+ if sec, err := file.GetSection("templates"); err == nil {
+ if key, err := sec.GetKey("template-dirs"); err == nil {
+ sec.NewKey("template-dirs", strings.ReplaceAll(key.String(), "@SHAREDIR@", sharedir))
+ }
2021-01-20 16:30:03 +01:00
+ }
+ if sec, err := file.GetSection("ui"); err == nil {
+ if key, err := sec.GetKey("stylesets-dirs"); err == nil {
+ sec.NewKey("stylesets-dirs", strings.ReplaceAll(key.String(), "@SHAREDIR@", sharedir))
+ }
+ }
file.NameMapper = mapName
config := &AercConfig{
Bindings: BindingConfig{
2021-01-20 16:30:03 +01:00
@@ -547,6 +557,9 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
return nil, err
}
2020-12-29 13:47:57 +01:00
+ for i, filter := range config.Filters {
+ config.Filters[i].Command = strings.ReplaceAll(filter.Command, "@SHAREDIR@", sharedir)
+ }
if ui, err := file.GetSection("general"); err == nil {
if err := ui.MapTo(&config.General); err != nil {
return nil, err
2021-01-20 16:30:03 +01:00
--
2.30.0