@@ -1,18 +1,19 @@
1−From 7ea68a2eef026723903d72f54ca54b629881ec06 Mon Sep 17 00:00:00 2001
1+From 6cf3c2e42d219b9665a43ca65f321c653b0aa102 Mon Sep 17 00:00:00 2001
22From: Tadeo Kondrak <me@tadeo.ca>
33Date: Mon, 28 Oct 2019 08:36:36 -0600
44Subject: [PATCH] Fix aerc breaking every time the package is rebuilt.
55
66On NixOS, the SHAREDIR changes on every rebuild to the package, but aerc
7−fills it in as part of the default config. Fix this by not substituting
8−@SHAREDIR@ in the default config until runtime.
7+fills it in as part of the default config and then installs that config
8+to the users home folder. Fix this by not substituting @SHAREDIR@ in the
9+default config until runtime.
910---
1011 Makefile | 2 +-
11− config/config.go | 3 +++
12− 2 files changed, 4 insertions(+), 1 deletion(-)
12+ config/config.go | 8 ++++++++
13+ 2 files changed, 9 insertions(+), 1 deletion(-)
1314
1415diff --git a/Makefile b/Makefile
15−index d3072d3..17ca0be 100644
16+index d1c755d..1185a96 100644
1617--- a/Makefile
1718+++ b/Makefile
1819@@ -24,7 +24,7 @@ aerc: $(GOSRC)
@@ -25,10 +26,22 @@ index d3072d3..17ca0be 100644
2526 DOCS := \
2627 aerc.1 \
2728diff --git a/config/config.go b/config/config.go
28−index bfcbecf..2f4e703 100644
29+index 32d07fc..8ffd3e8 100644
2930--- a/config/config.go
3031+++ b/config/config.go
31−@@ -377,6 +377,9 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
32+@@ -355,6 +355,11 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
33+ return nil, err
34+ }
35+ }
36++ if sec, err := file.GetSection("templates"); err == nil {
37++ if key, err := sec.GetKey("template-dirs"); err == nil {
38++ sec.NewKey("template-dirs", strings.ReplaceAll(key.String(), "@SHAREDIR@", sharedir))
39++ }
40++ }
41+ file.NameMapper = mapName
42+ config := &AercConfig{
43+ Bindings: BindingConfig{
44+@@ -423,6 +428,9 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
3245 if err = config.LoadConfig(file); err != nil {
3346 return nil, err
3447 }