@@ -56,11 +56,27 @@ func installHooks(cmd *cobra.Command, args []string) { |
| 56 | 56 | hookFile = "parrot-hook.sh" |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | | - possiblePaths := []string{ |
| 60 | | - filepath.Join("/usr/share/parrot", hookFile), // RPM installation |
| 61 | | - filepath.Join("/usr/local/share/parrot", hookFile), // Manual installation |
| 62 | | - filepath.Join(".", hookFile), // Development |
| 59 | + // Build list of possible paths, starting with most specific |
| 60 | + possiblePaths := []string{} |
| 61 | + |
| 62 | + // Check relative to executable (works for NixOS, Homebrew, and other non-FHS systems) |
| 63 | + if exePath, err := os.Executable(); err == nil { |
| 64 | + // Resolve symlinks to get actual binary location |
| 65 | + if realPath, err := filepath.EvalSymlinks(exePath); err == nil { |
| 66 | + exePath = realPath |
| 67 | + } |
| 68 | + exeDir := filepath.Dir(exePath) |
| 69 | + // Try ../share/parrot/ relative to bin directory |
| 70 | + possiblePaths = append(possiblePaths, filepath.Join(exeDir, "..", "share", "parrot", hookFile)) |
| 63 | 71 | } |
| 72 | + |
| 73 | + // Standard FHS and user paths |
| 74 | + possiblePaths = append(possiblePaths, |
| 75 | + filepath.Join("/usr/share/parrot", hookFile), // RPM/system installation |
| 76 | + filepath.Join("/usr/local/share/parrot", hookFile), // Manual system installation |
| 77 | + filepath.Join(homeDir, ".local/share/parrot", hookFile), // make install (user local) |
| 78 | + filepath.Join(".", hookFile), // Development |
| 79 | + ) |
| 64 | 80 | |
| 65 | 81 | for _, path := range possiblePaths { |
| 66 | 82 | if _, err := os.Stat(path); err == nil { |