Repository: JanDeDobbeleer/oh-my-posh
Pull request #5385 (2024-07-30 17:35:46)

Nix Shell Segment
### Prerequisites

- [x] I have read and understood the [contributing guide][CONTRIBUTING.md].
- [x] The commit message follows the [conventional commits][cc] guidelines.
- [x] Tests for the changes have been added (for bug fixes / features).
- [x] Docs have been added/updated (for bug fixes / features).

### Description

This adds a segment for [Nix Shell](https://nixos.org/guides/nix-pills/developing-with-nix-shell.html).

Please review and let me know if there are any improvements needed in the code or documentation.

<!---

Tips:

If you're not comfortable with working with Git,
we're working a guide (https://ohmyposh.dev/docs/contributing/git) to help you out.
Oh My Posh advises GitKraken (https://www.gitkraken.com/invite/nQmDPR9D) as your preferred cross platform Git GUI power tool.

-->

[CONTRIBUTING.md]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/CONTRIBUTING.md
[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary



Patch:
diff --git a/src/config/segment_types.go b/src/config/segment_types.go
index 752420c8..54ddb850 100644
--- a/src/config/segment_types.go
+++ b/src/config/segment_types.go
@@ -27,7 +27,6 @@ const (
 	Accordion SegmentStyle = "accordion"
 	// Diamond writes the prompt shaped with a leading and trailing symbol
 	Diamond SegmentStyle = "diamond"
-
 	// ANGULAR writes which angular cli version us currently active
 	ANGULAR SegmentType = "angular"
 	// ARGOCD writes the current argocd context
@@ -128,6 +127,8 @@ const (
 	NPM SegmentType = "npm"
 	// NX writes which Nx version us currently active
 	NX SegmentType = "nx"
+	// NIXSHELL writes the active nix shell details
+	NIXSHELL SegmentType = "nix-shell"
 	// OCAML writes the active Ocaml version
 	OCAML SegmentType = "ocaml"
 	// OS write os specific icon
@@ -266,6 +267,7 @@ var Segments = map[SegmentType]func() SegmentWriter{
 	NIGHTSCOUT:      func() SegmentWriter { return &segments.Nightscout{} },
 	NODE:            func() SegmentWriter { return &segments.Node{} },
 	NPM:             func() SegmentWriter { return &segments.Npm{} },
+	NIXSHELL:        func() SegmentWriter { return &segments.NixShell{} },
 	NX:              func() SegmentWriter { return &segments.Nx{} },
 	OCAML:           func() SegmentWriter { return &segments.OCaml{} },
 	OS:              func() SegmentWriter { return &segments.Os{} },
diff --git a/src/segments/nba.go b/src/segments/nba.go
index 22bcc782..501cb3e5 100644
--- a/src/segments/nba.go
+++ b/src/segments/nba.go
@@ -54,7 +54,7 @@ const (
 	NBAScoreURL    string = "https://cdn.nba.com/static/json/liveData/scoreboard/todaysScoreboard_00.json"
 	NBAScheduleURL string = "https://stats.nba.com/stats/internationalbroadcasterschedule?LeagueID=00&Season=%s&Date=%s&RegionID=1&EST=Y"
 
-	Unknown = "Unknown"
+	UNKNOWN = "unknown"
 
 	currentNBASeason = "2023"
 	NBADateFormat    = "02/01/2006"
@@ -92,7 +92,7 @@ func (gs GameStatus) String() string {
 	case NotFound:
 		return "Not Found"
 	default:
-		return Unknown
+		return UNKNOWN
 	}
 }
 
diff --git a/src/segments/nixshell.go b/src/segments/nixshell.go
new file mode 100644
index 00000000..40c00e42
--- /dev/null
+++ b/src/segments/nixshell.go
@@ -0,0 +1,65 @@
+package segments
+
+import (
+	"path/filepath"
+	"strings"
+
+	"github.com/jandedobbeleer/oh-my-posh/src/properties"
+	"github.com/jandedobbeleer/oh-my-posh/src/runtime"
+)
+
+const (
+	NONE = "none"
+)
+
+type NixShell struct {
+	props properties.Properties
+	env   runtime.Environment
+
+	Type string
+}
+
+func (n *NixShell) Template() string {
+	return "via {{ .Type }}-shell"
+}
+
+func (n *NixShell) DetectType() string {
+	shellType := n.env.Getenv("IN_NIX_SHELL")
+
+	switch shellType {
+	case "pure", "impure":
+		return shellType
+	default:
+		if n.InNewNixShell() {
+			return UNKNOWN
+		}
+
+		return NONE
+	}
+}
+
+// Hack to detect if we're in a `nix shell` (in contrast to a `nix-shell`).
+// A better way to do this will be enabled by https://github.com/NixOS/nix/issues/6677
+// so we check if the PATH contains a nix store.
+func (n *NixShell) InNewNixShell() bool {
+	paths := filepath.SplitList(n.env.Getenv("PATH"))
+
+	for _, p := range paths {
+		if strings.Contains(p, "/nix/store") {
+			return true
+		}
+	}
+
+	return false
+}
+
+func (n *NixShell) Init(props properties.Properties, env runtime.Environment) {
+	n.props = props
+	n.env = env
+}
+
+func (n *NixShell) Enabled() bool {
+	n.Type = n.DetectType()
+
+	return n.Type != NONE
+}
diff --git a/src/segments/umbraco.go b/src/segments/umbraco.go
index bc8c53c2..bac1e1db 100644
--- a/src/segments/umbraco.go
+++ b/src/segments/umbraco.go
@@ -156,7 +156,7 @@ func (u *Umbraco) TryFindLegacyUmbraco(configPath string) bool {
 			u.Modern = false
 
 			if len(appSetting.Value) == 0 {
-				u.Version = Unknown
+				u.Version = UNKNOWN
 			} else {
 				u.Version = appSetting.Value
 			}
diff --git a/themes/schema.json b/themes/schema.json
index dac6b650..e4d64e3b 100644
--- a/themes/schema.json
+++ b/themes/schema.json
@@ -351,6 +351,7 @@
             "mvn",
             "nbgv",
             "nightscout",
+            "nix-shell",
             "node",
             "npm",
             "nx",
@@ -520,7 +521,7 @@
           },
           "then": {
             "title": "Project Segment",
-            "description": "https://ohmyposh.dev/docs/segments/project",
+            "description": "https://ohmyposh.dev/docs/segments/system/project",
             "properties": {
               "properties": {
                 "properties": {
@@ -545,7 +546,7 @@
           },
           "then": {
             "title": "NPM Segment",
-            "description": "https://ohmyposh.dev/docs/segments/npm",
+            "description": "https://ohmyposh.dev/docs/segments/cli/npm",
             "properties": {
               "properties": {
                 "properties": {
@@ -653,14 +654,14 @@
           },
           "then": {
             "title": "Azure Segment",
-            "description": "https://ohmyposh.dev/docs/segments/az",
+            "description": "https://ohmyposh.dev/docs/segments/cloud/az",
             "properties": {
               "properties": {
                 "properties": {
                   "source": {
                     "type": "string",
                     "title": "Source",
-                    "description": "https://ohmyposh.dev/docs/segments/az#properties",
+                    "description": "https://ohmyposh.dev/docs/segments/cloud/az#properties",
                     "default": "first_match",
                     "enum": [
                       "first_match",
@@ -683,12 +684,7 @@
           },
           "then": {
             "title": "Azure Developer CLI Segment",
-            "description": "https://ohmyposh.dev/docs/segments/azd",
-            "properties": {
-              "properties": {
-                "properties": { }
-              }
-            }
+            "description": "https://ohmyposh.dev/docs/segments/cloud/azd"
           }
         },
         {
@@ -701,7 +697,7 @@
           },
           "then": {
             "title": "Battery Segment",
-            "description": "https://ohmyposh.dev/docs/segments/battery",
+            "description": "https://ohmyposh.dev/docs/segments/system/battery",
             "properties": {
               "properties": {
                 "properties": {
@@ -750,7 +746,7 @@
           },
           "then": {
             "title": "Bazel Segment",
-            "description": "https://ohmyposh.dev/docs/segments/bazel",
+            "description": "https://ohmyposh.dev/docs/segments/cli/bazel",
             "properties": {
               "properties": {
                 "properties": {
@@ -822,7 +818,7 @@
           },
           "then": {
             "title": "Buf Segment",
-            "description": "https://ohmyposh.dev/docs/segments/buf",
+            "description": "https://ohmyposh.dev/docs/segments/cli/buf",
             "properties": {
               "properties": {
                 "properties": {
@@ -875,7 +871,7 @@
           },
           "then": {
             "title": "Bun CLI Segment",
-            "description": "https://ohmyposh.dev/docs/segments/bun",
+            "description": "https://ohmyposh.dev/docs/segments/cli/bun",
             "properties": {
               "properties": {
                 "properties": {
@@ -951,7 +947,7 @@
           },
           "then": {
             "title": "Command Segment",
-            "description": "https://ohmyposh.dev/docs/segments/command",
+            "description": "https://ohmyposh.dev/docs/segments/system/command",
             "properties": {
               "properties": {
                 "properties": {
@@ -988,7 +984,7 @@
           },
           "then": {
             "title": "Connection Segment",
-            "description": "https://ohmyposh.dev/docs/segments/connection",
+            "description": "https://ohmyposh.dev/docs/segments/system/connection",
             "properties": {
               "properties": {
                 "properties": {
@@ -1037,7 +1033,7 @@
           },
           "then": {
             "title": "Cmake Segment",
-            "description": "https://ohmyposh.dev/docs/segments/cmake",
+            "description": "https://ohmyposh.dev/docs/segments/cli/cmake",
             "properties": {
               "properties": {
                 "properties": {
@@ -1089,7 +1085,7 @@
           },
           "then": {
             "title": "Docker Segment",
-            "description": "https://ohmyposh.dev/docs/segments/docker"
+            "description": "https://ohmyposh.dev/docs/segments/cli/docker"
           }
         },
         {
@@ -1102,7 +1098,7 @@
           },
           "then": {
             "title": "Dotnet Segment",
-            "description": "https://ohmyposh.dev/docs/segments/dotnet",
+            "description": "https://ohmyposh.dev/docs/segments/languages/dotnet",
             "properties": {
               "properties": {
                 "properties": {
@@ -1163,7 +1159,7 @@
           },
           "then": {
             "title": "Status Segment",
-            "description": "https://ohmyposh.dev/docs/segments/status",
+            "description": "https://ohmyposh.dev/docs/segments/system/status",
             "properties": {
               "properties": {
                 "properties": {
@@ -1200,7 +1196,7 @@
           },
           "then": {
             "title": "Flutter Segment",
-            "description": "https://ohmyposh.dev/docs/segments/flutter",
+            "description": "https://ohmyposh.dev/docs/segments/cli/flutter",
             "properties": {
               "properties": {
                 "properties": {
@@ -1262,7 +1258,7 @@
           },
           "then": {
             "title": "Fossil Segment",
-            "description": "https://ohmyposh.dev/docs/segments/fossil",
+            "description": "https://ohmyposh.dev/docs/segments/scm/fossil",
             "properties": {
               "properties": {
                 "properties": {
@@ -1284,7 +1280,7 @@
           },
           "then": {
             "title": "Git Segment",
-            "description": "https://ohmyposh.dev/docs/segments/git",
+            "description": "https://ohmyposh.dev/docs/segments/scm/git",
             "properties": {
               "properties": {
                 "properties": {
@@ -1495,7 +1491,7 @@
           },
           "then": {
             "title": "Golang Segment",
-            "description": "https://ohmyposh.dev/docs/segments/golang",
+            "description": "https://ohmyposh.dev/docs/segments/languages/golang",
             "properties": {
               "properties": {
                 "properties": {
@@ -1553,7 +1549,7 @@
           },
           "then": {
             "title": "Dart Segment",
-            "description": "https://ohmyposh.dev/docs/segments/dart",
+            "description": "https://ohmyposh.dev/docs/segments/languages/dart",
             "properties": {
               "properties": {
                 "properties": {
@@ -1615,7 +1611,7 @@
           },
           "then": {
             "title": "Deno CLI Segment",
-            "description": "https://ohmyposh.dev/docs/segments/deno",
+            "description": "https://ohmyposh.dev/docs/segments/cli/deno",
             "properties": {
               "properties": {
                 "properties": {
@@ -1668,7 +1664,7 @@
           },
           "then": {
             "title": "Crystal Segment",
-            "description": "https://ohmyposh.dev/docs/segments/crystal",
+            "description": "https://ohmyposh.dev/docs/segments/languages/crystal",
             "properties": {
               "properties": {
                 "properties": {
@@ -1720,7 +1716,7 @@
           },
           "then": {
             "title": "Julia Segment",
-            "description": "https://ohmyposh.dev/docs/segments/julia",
+            "description": "https://ohmyposh.dev/docs/segments/languages/julia",
             "properties": {
               "properties": {
                 "properties": {
@@ -1771,7 +1767,7 @@
           },
           "then": {
             "title": "Perl Segment",
-            "description": "https://ohmyposh.dev/docs/segments/perl",
+            "description": "https://ohmyposh.dev/docs/segments/languages/perl",
             "properties": {
               "properties": {
                 "properties": {
@@ -1825,7 +1821,7 @@
           },
           "then": {
             "title": "PHP Segment",
-            "description": "https://ohmyposh.dev/docs/segments/php",
+            "description": "https://ohmyposh.dev/docs/segments/languages/php",
             "properties": {
               "properties": {
                 "properties": {
@@ -1879,7 +1875,7 @@
           },
           "then": {
             "title": "Java Segment",
-            "description": "https://ohmyposh.dev/docs/segments/java",
+            "description": "https://ohmyposh.dev/docs/segments/languages/java",
             "properties": {
               "properties": {
                 "properties": {
@@ -1939,7 +1935,7 @@
           },
           "then": {
             "title": "Ruby Segment",
-            "description": "https://ohmyposh.dev/docs/segments/ruby",
+            "description": "https://ohmyposh.dev/docs/segments/languages/ruby",
             "properties": {
               "properties": {
                 "properties": {
@@ -1989,7 +1985,7 @@
           },
           "then": {
             "title": "Rust Segment",
-            "description": "https://ohmyposh.dev/docs/segments/rust",
+            "description": "https://ohmyposh.dev/docs/segments/languages/rust",
             "properties": {
               "properties": {
                 "properties": {
@@ -2039,7 +2035,7 @@
           },
           "then": {
             "title": "XMake Segment",
-            "description": "https://ohmyposh.dev/docs/segments/xmake",
+            "description": "https://ohmyposh.dev/docs/segments/cli/xmake",
             "properties": {
               "properties": {
                 "properties": {
@@ -2090,7 +2086,7 @@
           },
           "then": {
             "title": "Kubectl Segment",
-            "description": "https://ohmyposh.dev/docs/segments/kubectl",
+            "description": "https://ohmyposh.dev/docs/segments/cli/kubectl",
             "properties": {
               "properties": {
                 "properties": {
@@ -2127,7 +2123,7 @@
           },
           "then": {
             "title": "AWS Segment",
-            "description": "https://ohmyposh.dev/docs/segments/aws",
+            "description": "https://ohmyposh.dev/docs/segments/cloud/aws",
             "properties": {
               "properties": {
                 "properties": {
@@ -2152,7 +2148,7 @@
           },
           "then": {
             "title": "Node Segment",
-            "description": "https://ohmyposh.dev/docs/segments/node",
+            "description": "https://ohmyposh.dev/docs/segments/languages/node",
             "properties": {
               "properties": {
                 "properties": {
@@ -2227,7 +2223,7 @@
           },
           "then": {
             "title": "Azure Function Segment",
-            "description": "https://ohmyposh.dev/docs/segments/azfunc",
+            "description": "https://ohmyposh.dev/docs/segments/cloud/azfunc",
             "properties": {
               "properties": {
                 "properties": {
@@ -2258,7 +2254,7 @@
           },
           "then": {
             "title": "Operating System Segment",
-            "description": "https://ohmyposh.dev/docs/segments/os",
+            "description": "https://ohmyposh.dev/docs/segments/system/os",
             "properties": {
               "properties": {
                 "properties": {
@@ -2439,7 +2435,7 @@
           },
           "then": {
             "title": "Path Segment",
-            "description": "https://ohmyposh.dev/docs/segments/path",
+            "description": "https://ohmyposh.dev/docs/segments/system/path",
             "properties": {
               "properties": {
                 "properties": {
@@ -2592,7 +2588,7 @@
           },
           "then": {
             "title": "Python Segment",
-            "description": "https://ohmyposh.dev/docs/segments/python",
+            "description": "https://ohmyposh.dev/docs/segments/languages/python",
             "properties": {
               "properties": {
                 "properties": {
@@ -2670,7 +2666,7 @@
           },
           "then": {
             "title": "Pulumi Segment",
-            "description": "https://ohmyposh.dev/docs/segments/pulumi",
+            "description": "https://ohmyposh.dev/docs/segments/cloud/pulumi",
             "properties": {
               "properties": {
                 "properties": {
@@ -2701,7 +2697,7 @@
           },
           "then": {
             "title": "Quasar Segment",
-            "description": "https://ohmyposh.dev/docs/segments/quasar",
+            "description": "https://ohmyposh.dev/docs/segments/cli/quasar",
             "properties": {
               "properties": {
                 "properties": {
@@ -2756,7 +2752,7 @@
           },
           "then": {
             "title": "Root Segment",
-            "description": "https://ohmyposh.dev/docs/segments/root"
+            "description": "https://ohmyposh.dev/docs/segments/system/root"
           }
         },
         {
@@ -2769,7 +2765,7 @@
           },
           "then": {
             "title": "Sapling Segment",
-            "description": "https://ohmyposh.dev/docs/segments/sapling",
+            "description": "https://ohmyposh.dev/docs/segments/scm/sapling",
             "properties": {
               "properties": {
                 "properties": {
@@ -2800,7 +2796,7 @@
           },
           "then": {
             "title": "Session Segment",
-            "description": "https://ohmyposh.dev/docs/segments/session",
+            "description": "https://ohmyposh.dev/docs/segments/system/session",
             "properties": {
               "properties": {
                 "properties": {
@@ -2825,7 +2821,7 @@
           },
           "then": {
             "title": "Shell Segment",
-            "description": "https://ohmyposh.dev/docs/segments/shell",
+            "description": "https://ohmyposh.dev/docs/segments/system/shell",
             "properties": {
               "properties": {
                 "properties": {
@@ -2850,7 +2846,7 @@
           },
           "then": {
             "title": "Sitecore Segment",
-            "description": "https://ohmyposh.dev/docs/segments/sitecore",
+            "description": "https://ohmyposh.dev/docs/segments/cloud/sitecore",
             "properties": {
               "properties": {
                 "properties": {
@@ -2875,7 +2871,7 @@
           },
           "then": {
             "title": "Spotify Segment",
-            "description": "https://ohmyposh.dev/docs/segments/spotify",
+            "description": "https://ohmyposh.dev/docs/segments/music/spotify",
             "properties": {
               "properties": {
                 "properties": {
@@ -2912,7 +2908,7 @@
           },
           "then": {
             "title": "Terraform Segment",
-            "description": "https://ohmyposh.dev/docs/segments/terraform",
+            "description": "https://ohmyposh.dev/docs/segments/cli/terraform",
             "properties": {
               "properties": {
                 "properties": {
@@ -2937,19 +2933,7 @@
           },
           "then": {
             "title": "Text Segment",
-            "description": "https://ohmyposh.dev/docs/segments/text",
-            "properties": {
-              "properties": {
-                "properties": {
-                  "text": {
-                    "type": "string",
-                    "title": "Text",
-                    "description": "Text/icon to display",
-                    "default": ""
-                  }
-                }
-              }
-            }
+            "description": "https://ohmyposh.dev/docs/segments/system/text"
           }
         },
         {
@@ -2962,7 +2946,7 @@
           },
           "then": {
             "title": "Talosctl Segment",
-            "description": "https://ohmyposh.dev/docs/segments/talosctl"
+            "description": "https://ohmyposh.dev/docs/segments/cli/talosctl"
           }
         },
         {
@@ -2975,7 +2959,7 @@
           },
           "then": {
             "title": "Time Segment",
-            "description": "https://ohmyposh.dev/docs/segments/time",
+            "description": "https://ohmyposh.dev/docs/segments/system/time",
             "properties": {
               "properties": {
                 "properties": {
@@ -3000,7 +2984,7 @@
           },
           "then": {
             "title": "YouTube Music Desktop App Segment",
-            "description": "https://ohmyposh.dev/docs/segments/ytm",
+            "description": "https://ohmyposh.dev/docs/segments/music/ytm",
             "properties": {
               "properties": {
                 "properties": {
@@ -3094,7 +3078,7 @@
           },
           "then": {
             "title": "Elixir Segment",
-            "description": "https://ohmyposh.dev/docs/segments/elixir",
+            "description": "https://ohmyposh.dev/docs/segments/languages/elixir",
             "properties": {
               "properties": {
                 "properties": {
@@ -3146,7 +3130,7 @@
           },
           "then": {
             "title": "Displays the execution time of the previously executed command",
-            "description": "https://ohmyposh.dev/docs/segments/executiontime",
+            "description": "https://ohmyposh.dev/docs/segments/system/executiontime",
             "properties": {
               "properties": {
                 "properties": {
@@ -3194,7 +3178,7 @@
           },
           "then": {
             "title": "Get sysinfo",
-            "description": "https://ohmyposh.dev/docs/segments/sysinfo",
+            "description": "https://ohmyposh.dev/docs/segments/system/sysinfo",
             "properties": {
               "properties": {
                 "properties": {
@@ -3219,7 +3203,7 @@
           },
           "then": {
             "title": "Display training data from Strava",
-            "description": "https://ohmyposh.dev/docs/segments/strava",
+            "description": "https://ohmyposh.dev/docs/segments/health/strava",
             "properties": {
               "properties": {
                 "properties": {
@@ -3289,7 +3273,7 @@
           },
           "then": {
             "title": "SVN Segment",
-            "description": "https://ohmyposh.dev/docs/segments/svn",
+            "description": "https://ohmyposh.dev/docs/segments/scm/svn",
             "properties": {
               "properties": {
                 "properties": {
@@ -3320,7 +3304,7 @@
           },
           "then": {
             "title": "Angular CLI Segment",
-            "description": "https://ohmyposh.dev/docs/segments/angular",
+            "description": "https://ohmyposh.dev/docs/segments/cli/angular",
             "properties": {
               "properties": {
                 "properties": {
@@ -3371,7 +3355,7 @@
           },
           "then": {
             "title": "React Segment",
-            "description": "https://ohmyposh.dev/docs/segments/react",
+            "description": "https://ohmyposh.dev/docs/segments/cli/react",
             "properties": {
               "properties": {
                 "properties": {
@@ -3422,7 +3406,7 @@
           },
           "then": {
             "title": "Nx Segment",
-            "description": "https://ohmyposh.dev/docs/segments/nx",
+            "description": "https://ohmyposh.dev/docs/segments/cli/nx",
             "properties": {
               "properties": {
                 "properties": {
@@ -3474,7 +3458,7 @@
           },
           "then": {
             "title": "OCaml Segment",
-            "description": "https://ohmyposh.dev/docs/segments/ocaml",
+            "description": "https://ohmyposh.dev/docs/segments/languages/ocaml",
             "properties": {
               "properties": {
                 "properties": {
@@ -3560,7 +3544,7 @@
           },
           "then": {
             "title": "Windows Registry Query",
-            "description": "https://ohmyposh.dev/docs/segments/winreg",
+            "description": "https://ohmyposh.dev/docs/segments/system/winreg",
             "properties": {
               "properties": {
                 "properties": {
@@ -3591,7 +3575,7 @@
           },
           "then": {
             "title": "Display activity data from Withings",
-            "description": "https://ohmyposh.dev/docs/segments/withings",
+            "description": "https://ohmyposh.dev/docs/segments/health/withings",
             "properties": {
               "properties": {
                 "properties": {
@@ -3625,7 +3609,7 @@
           },
           "then": {
             "title": "Plastic SCM Segment",
-            "description": "https://ohmyposh.dev/docs/segments/plastic",
+            "description": "https://ohmyposh.dev/docs/segments/scm/plastic",
             "properties": {
               "properties": {
                 "properties": {
@@ -3686,7 +3670,7 @@
           },
           "then": {
             "title": "Brewfather Batch Status",
-            "description": "https://ohmyposh.dev/docs/segments/brewfather",
+            "description": "https://ohmyposh.dev/docs/segments/web/brewfather",
             "properties": {
               "properties": {
                 "properties": {
@@ -3816,7 +3800,7 @@
           },
           "then": {
             "title": "Display your external IP Address",
-            "description": "https://ohmyposh.dev/docs/segments/ipify",
+            "description": "https://ohmyposh.dev/docs/segments/web/ipify",
             "properties": {
               "properties": {
                 "properties": {
@@ -3847,7 +3831,7 @@
           },
           "then": {
             "title": "Haskell Segment",
-            "description": "https://ohmyposh.dev/docs/segments/haskell",
+            "description": "https://ohmyposh.dev/docs/segments/languages/haskell",
             "properties": {
               "properties": {
                 "properties": {
@@ -3914,7 +3898,7 @@
           },
           "then": {
             "title": "Helm segment",
-            "description": "https://ohmyposh.dev/docs/segments/helm",
+            "description": "https://ohmyposh.dev/docs/segments/cli/helm",
             "properties": {
               "properties": {
                 "properties": {
@@ -3936,7 +3920,7 @@
           },
           "then": {
             "title": "UI5 tooling CLI segment",
-            "description": "https://ohmyposh.dev/docs/segments/ui5tooling",
+            "description": "https://ohmyposh.dev/docs/segments/cli/ui5tooling",
             "properties": {
               "properties": {
                 "properties": {
@@ -3987,7 +3971,7 @@
           },
           "then": {
             "title": "Unity Segment",
-            "description": "https://ohmyposh.dev/docs/segments/unity",
+            "description": "https://ohmyposh.dev/docs/segments/cli/unity",
             "properties": {
               "properties": {
                 "properties": {
@@ -4009,7 +3993,7 @@
           },
           "then": {
             "title": "Upgrade Segment",
-            "description": "https://ohmyposh.dev/docs/segments/upgrade",
+            "description": "https://ohmyposh.dev/docs/segments/system/upgrade",
             "properties": {
               "properties": {
                 "properties": {
@@ -4031,7 +4015,7 @@
           },
           "then": {
             "title": "Vala Segment",
-            "description": "https://ohmyposh.dev/docs/segments/vala",
+            "description": "https://ohmyposh.dev/docs/segments/languages/vala",
             "properties": {
               "properties": {
                 "properties": {
@@ -4082,7 +4066,7 @@
           },
           "then": {
             "title": "Clound Foundry CLI segment",
-            "description": "https://ohmyposh.dev/docs/segments/cf",
+            "description": "https://ohmyposh.dev/docs/segments/cloud/cf",
             "properties": {
               "properties": {
                 "properties": {
@@ -4134,7 +4118,7 @@
           },
           "then": {
             "title": "Clound Foundry Target segment",
-            "description": "https://ohmyposh.dev/docs/segments/cftarget",
+            "description": "https://ohmyposh.dev/docs/segments/cloud/cftarget",
             "properties": {
               "properties": {
                 "properties": {
@@ -4163,7 +4147,7 @@
           },
           "then": {
             "title": "Kotlin Segment",
-            "description": "https://ohmyposh.dev/docs/segments/kotlin",
+            "description": "https://ohmyposh.dev/docs/segments/languages/kotlin",
             "properties": {
               "properties": {
                 "properties": {
@@ -4216,7 +4200,7 @@
           },
           "then": {
             "title": "LastFM Segment",
-            "description": "https://ohmyposh.dev/docs/segments/lastfm",
+            "description": "https://ohmyposh.dev/docs/segments/music/lastfm",
             "properties": {
               "properties": {
                 "properties": {
@@ -4265,7 +4249,7 @@
           },
           "then": {
             "title": "Lua Segment",
-            "description": "https://ohmyposh.dev/docs/segments/lua",
+            "description": "https://ohmyposh.dev/docs/segments/languages/lua",
             "properties": {
               "properties": {
                 "properties": {
@@ -4327,7 +4311,7 @@
           },
           "then": {
             "title": "Swift Segment",
-            "description": "https://ohmyposh.dev/docs/segments/swift",
+            "description": "https://ohmyposh.dev/docs/segments/languages/swift",
             "properties": {
               "properties": {
                 "properties": {
@@ -4379,7 +4363,7 @@
           },
           "then": {
             "title": "CDS (SAP CAP) segment",
-            "description": "https://ohmyposh.dev/docs/segments/cds",
+            "description": "https://ohmyposh.dev/docs/segments/cloud/cds",
             "properties": {
               "properties": {
                 "properties": {
@@ -4432,7 +4416,7 @@
           },
           "then": {
             "title": "R Segment",
-            "description": "https://ohmyposh.dev/docs/segments/r",
+            "description": "https://ohmyposh.dev/docs/segments/languages/r",
             "properties": {
               "properties": {
                 "properties": {
@@ -4489,7 +4473,7 @@
           },
           "then": {
             "title": "GCP Segment",
-            "description": "https://ohmyposh.dev/docs/segments/gcp"
+            "description": "https://ohmyposh.dev/docs/segments/cloud/gcp"
           }
         },
         {
@@ -4502,7 +4486,7 @@
           },
           "then": {
             "title": "Firebase Segment",
-            "description": "https://ohmyposh.dev/docs/segments/firebase"
+            "description": "https://ohmyposh.dev/docs/segments/cli/firebase"
           }
         },
         {
@@ -4515,7 +4499,7 @@
           },
           "then": {
             "title": "Display GitVersion segment",
-            "description": "https://ohmyposh.dev/docs/segments/gitversion",
+            "description": "https://ohmyposh.dev/docs/segments/cli/gitversion",
             "properties": {
               "properties": {
                 "properties": {
@@ -4540,7 +4524,7 @@
           },
           "then": {
             "title": "Mercurial Segment",
-            "description": "https://ohmyposh.dev/docs/segments/mercurial",
+            "description": "https://ohmyposh.dev/docs/segments/scm/mercurial",
             "properties": {
               "properties": {
                 "properties": {
@@ -4568,7 +4552,7 @@
           },
           "then": {
             "title": "Display Nightscout segment",
-            "description": "https://ohmyposh.dev/docs/segments/nightscout",
+            "description": "https://ohmyposh.dev/docs/segments/health/nightscout",
             "properties": {
               "properties": {
                 "properties": {
@@ -4610,20 +4594,8 @@
             }
           },
           "then": {
-            "title": "Display something umbraco",
-            "description": "https://ohmyposh.dev/docs/segments/umbraco",
-            "properties": {
-              "properties": {
-                "properties": {
-                  "newprop": {
-                    "type": "string",
-                    "title": "New Property",
-                    "description": "the default text to display",
-                    "default": "Hello"
-                  }
-                }
-              }
-            }
+            "title": "Umbraco Segment",
+            "description": "https://ohmyposh.dev/docs/segments/cli/umbraco"
           }
         },
         {
@@ -4636,7 +4608,7 @@
           },
           "then": {
             "title": "PNPM Segment",
-            "description": "https://ohmyposh.dev/docs/segments/pnpm",
+            "description": "https://ohmyposh.dev/docs/segments/cli/pnpm",
             "properties": {
               "properties": {
                 "properties": {
@@ -4685,7 +4657,7 @@
           },
           "then": {
             "title": "Yarn Segment",
-            "description": "https://ohmyposh.dev/docs/segments/yarn",
+            "description": "https://ohmyposh.dev/docs/segments/cli/yarn",
             "properties": {
               "properties": {
                 "properties": {
@@ -4723,6 +4695,19 @@
               }
             }
           }
+        },
+        {
+          "if": {
+            "properties": {
+              "type": {
+                "const": "nix-shell"
+              }
+            }
+          },
+          "then": {
+            "title": "Nix Shell",
+            "description": "https://ohmyposh.dev/docs/segments/cli/nix-shell"
+          }
         }
       ]
     }
diff --git a/website/docs/segments/cli/nix-shell.mdx b/website/docs/segments/cli/nix-shell.mdx
new file mode 100644
index 00000000..e4a29f60
--- /dev/null
+++ b/website/docs/segments/cli/nix-shell.mdx
@@ -0,0 +1,42 @@
+---
+id: nix-shell
+title: Nix Shell
+sidebar_label: Nix Shell
+---
+
+## What
+
+Displays the [nix shell] status if inside a nix-shell environment.
+
+## Sample Configuration
+
+import Config from "@site/src/components/Config.js";
+
+<Config
+  data={{
+    type: "nix-shell",
+    style: "powerline",
+    foreground: "blue",
+    background: "transparent",
+    template: "(nix-{{ .Type }})",
+  }}
+/>
+
+## Template ([info][templates])
+
+:::note default template
+
+```template
+via {{ .Type }}-shell"
+```
+
+:::
+
+### Properties
+
+| Name    | Type     | Description                                                 |
+| ------- | -------- | ----------------------------------------------------------- |
+| `.Type` | `string` | the type of nix shell, can be `pure`, `impure` or `unknown` |
+
+[nix shell]: https://nixos.org/guides/nix-pills/developing-with-nix-shell.html
+[templates]: /docs/configuration/templates
diff --git a/website/sidebars.js b/website/sidebars.js
index 9acb6258..1a1fbc66 100644
--- a/website/sidebars.js
+++ b/website/sidebars.js
@@ -71,6 +71,7 @@ module.exports = {
             "segments/cli/kubectl",
             "segments/cli/mvn",
             "segments/cli/nbgv",
+            "segments/cli/nix-shell",
             "segments/cli/npm",
             "segments/cli/nx",
             "segments/cli/pnpm",


Test patch:
diff --git a/src/segments/nixshell_test.go b/src/segments/nixshell_test.go
new file mode 100644
index 00000000..3dfdd058
--- /dev/null
+++ b/src/segments/nixshell_test.go
@@ -0,0 +1,73 @@
+package segments
+
+import (
+	"fmt"
+	"testing"
+
+	"github.com/alecthomas/assert"
+	"github.com/jandedobbeleer/oh-my-posh/src/properties"
+	"github.com/jandedobbeleer/oh-my-posh/src/runtime/mock"
+)
+
+const (
+	nixPath     = "/nix/store/zznw8fnzss1vaqfg5hmv3y79s3hkqczi-devshell-dir/bin"
+	defaultPath = "/users/xyz/testing"
+	fullNixPath = defaultPath + ":" + nixPath
+)
+
+func TestNixShellSegment(t *testing.T) {
+	cases := []struct {
+		name           string
+		expectedString string
+		shellType      string
+		enabled        bool
+	}{
+		{
+			name:           "Pure Nix Shell",
+			expectedString: "via pure-shell",
+			shellType:      "pure",
+			enabled:        true,
+		},
+		{
+			name:           "Impure Nix Shell",
+			expectedString: "via impure-shell",
+			shellType:      "impure",
+			enabled:        true,
+		},
+		{
+			name:           "Unknown Nix Shell",
+			expectedString: "via unknown-shell",
+			shellType:      "unknown",
+			enabled:        true,
+		},
+		{
+			name:           "No Nix Shell",
+			expectedString: "",
+			shellType:      "",
+			enabled:        false,
+		},
+	}
+
+	for _, tc := range cases {
+		t.Run(tc.name, func(t *testing.T) {
+			env := new(mock.Environment)
+			env.On("Getenv", "IN_NIX_SHELL").Return(tc.shellType)
+
+			path := defaultPath
+			if tc.shellType != "" {
+				path = fullNixPath
+			}
+
+			env.On("Getenv", "PATH").Return(path)
+
+			n := NixShell{}
+			n.Init(properties.Map{}, env)
+
+			assert.Equal(t, tc.enabled, n.Enabled(), fmt.Sprintf("Failed in case: %s", tc.name))
+
+			if tc.enabled {
+				assert.Equal(t, tc.expectedString, renderTemplate(env, n.Template(), n), tc.name)
+			}
+		})
+	}
+}