nixpkgs/pkgs/by-name/nc/ncdns/fix-tpl-path.patch
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

28 lines
738 B
Diff

This sets a default value for the tpl directory that works for Nixpkgs.
diff --git a/server/web.go b/server/web.go
index d024a42..0522d02 100644
--- a/server/web.go
+++ b/server/web.go
@@ -10,6 +10,7 @@ import "path/filepath"
import "time"
import "strings"
import "fmt"
+import "os"
var layoutTpl *template.Template
var mainPageTpl *template.Template
@@ -44,7 +45,11 @@ func deriveTemplate(filename string) (*template.Template, error) {
}
func (s *Server) tplFilename(filename string) string {
- td := filepath.Join(s.cfg.ConfigDir, "..", "tpl")
+ ex, err := os.Executable()
+ if err != nil {
+ panic(err)
+ }
+ td := filepath.Join(filepath.Dir(ex), "..", "share", "tpl")
if s.cfg.TplPath != "" {
td = s.cfg.TplPath
}