From 44a881fcf815d88bf703e8e1f2cb0372f710a5bb Mon Sep 17 00:00:00 2001 From: 3pleX-dev Date: Fri, 4 Apr 2025 23:34:42 +0000 Subject: [PATCH] kitty: fix unreproducible build (manpage dates, fish completions) --- .../kitty/fix-fish-completion-ordering.patch | 18 ++++++++++ .../kitty/fix-timestamp-reproducibility.patch | 35 +++++++++++++++++++ pkgs/by-name/ki/kitty/package.nix | 6 ++++ 3 files changed, 59 insertions(+) create mode 100644 pkgs/by-name/ki/kitty/fix-fish-completion-ordering.patch create mode 100644 pkgs/by-name/ki/kitty/fix-timestamp-reproducibility.patch diff --git a/pkgs/by-name/ki/kitty/fix-fish-completion-ordering.patch b/pkgs/by-name/ki/kitty/fix-fish-completion-ordering.patch new file mode 100644 index 000000000000..b0689f03acbf --- /dev/null +++ b/pkgs/by-name/ki/kitty/fix-fish-completion-ordering.patch @@ -0,0 +1,18 @@ +--- a/tools/cli/fish.go 2025-04-04 23:43:16 ++++ b/tools/cli/fish.go 2025-04-04 23:44:13 +@@ -4,6 +4,7 @@ + + import ( + "fmt" ++ "sort" + "strings" + + "kitty/tools/cli/markup" +@@ -22,6 +23,7 @@ + } + if len(commands) == 0 { + commands = append(commands, utils.Keys(all_commands)...) ++ sort.Strings(commands) + } + script := strings.Builder{} + script.WriteString(`function __ksi_completions diff --git a/pkgs/by-name/ki/kitty/fix-timestamp-reproducibility.patch b/pkgs/by-name/ki/kitty/fix-timestamp-reproducibility.patch new file mode 100644 index 000000000000..3c2668d78f09 --- /dev/null +++ b/pkgs/by-name/ki/kitty/fix-timestamp-reproducibility.patch @@ -0,0 +1,35 @@ +--- a/tools/cli/help.go 2025-04-04 23:55:53 ++++ b/tools/cli/help.go 2025-04-04 23:56:59 +@@ -9,6 +9,7 @@ + "os/exec" + "slices" + "strings" ++ "strconv" + "time" + + "golang.org/x/sys/unix" +@@ -133,6 +134,15 @@ + pager.Stdout = os.Stdout + pager.Stderr = os.Stderr + _ = pager.Run() ++} ++ ++func getDeterministicTimestamp() time.Time { ++ if epochStr, exists := os.LookupEnv("SOURCE_DATE_EPOCH"); exists { ++ if epoch, err := strconv.ParseInt(epochStr, 10, 64); err == nil { ++ return time.Unix(epoch, 0).UTC() ++ } ++ } ++ return time.Now() + } + + func (self *Command) GenerateManPages(level int, recurse bool) (err error) { +@@ -149,7 +159,7 @@ + return err + } + defer outf.Close() +- fmt.Fprintf(outf, `.TH "%s" "1" "%s" "%s" "%s"`, name, time.Now().Format("Jan 02, 2006"), kitty.VersionString, "kitten Manual") ++ fmt.Fprintf(outf, `.TH "%s" "1" "%s" "%s" "%s"`, name, getDeterministicTimestamp().Format("Jan 02, 2006"), kitty.VersionString, "kitten Manual") + fmt.Fprintln(outf) + fmt.Fprintln(outf, ".SH Name") + fmt.Fprintln(outf, name, "\\-", escape_text_for_man(self.ShortDescription)) diff --git a/pkgs/by-name/ki/kitty/package.nix b/pkgs/by-name/ki/kitty/package.nix index fd8674f00f4c..6c23345246c0 100644 --- a/pkgs/by-name/ki/kitty/package.nix +++ b/pkgs/by-name/ki/kitty/package.nix @@ -159,6 +159,12 @@ buildPythonApplication rec { # Skip `test_ssh_bootstrap_with_different_launchers` when launcher is `zsh` since it causes: # OSError: master_fd is in error condition ./disable-test_ssh_bootstrap_with_different_launchers.patch + + # Makes man page generation respect SOURCE_DATE_EPOCH. Drop on next kitty release https://github.com/kovidgoyal/kitty/pull/8509 + ./fix-timestamp-reproducibility.patch + + # Ensures deterministic ordering of fish shell completions. Drop on next kitty release https://github.com/kovidgoyal/kitty/pull/8509 + ./fix-fish-completion-ordering.patch ]; hardeningDisable = [