aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/hm-search/options.go8
-rw-r--r--cmd/nixos-search/options.go8
2 files changed, 16 insertions, 0 deletions
diff --git a/cmd/hm-search/options.go b/cmd/hm-search/options.go
index accd2af..dbe4b1d 100644
--- a/cmd/hm-search/options.go
+++ b/cmd/hm-search/options.go
@@ -4,6 +4,7 @@ import (
4 "encoding/json" 4 "encoding/json"
5 "fmt" 5 "fmt"
6 "os" 6 "os"
7 "sort"
7 "strings" 8 "strings"
8 9
9 nix "git.sixfoisneuf.fr/nix-tools/nix" 10 nix "git.sixfoisneuf.fr/nix-tools/nix"
@@ -29,6 +30,12 @@ type DefaultValue struct {
29 Text string 30 Text string
30} 31}
31 32
33type ByName []Option
34
35func (a ByName) Len() int { return len(a) }
36func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
37func (a ByName) Less(i, j int) bool { return a[i].Name < a[j].Name }
38
32var optionsExpr = ` 39var optionsExpr = `
33let 40let
34 hm = import <home-manager> {}; 41 hm = import <home-manager> {};
@@ -93,6 +100,7 @@ func LoadOptions(nixpkgs string) ([]Option, error) {
93 options = append(options, o) 100 options = append(options, o)
94 } 101 }
95 102
103 sort.Sort(ByName(options))
96 return options, nil 104 return options, nil
97} 105}
98 106
diff --git a/cmd/nixos-search/options.go b/cmd/nixos-search/options.go
index e5de32d..7910143 100644
--- a/cmd/nixos-search/options.go
+++ b/cmd/nixos-search/options.go
@@ -5,6 +5,7 @@ import (
5 "encoding/json" 5 "encoding/json"
6 "fmt" 6 "fmt"
7 "os" 7 "os"
8 "sort"
8 "strings" 9 "strings"
9 10
10 nix "git.sixfoisneuf.fr/nix-tools/nix" 11 nix "git.sixfoisneuf.fr/nix-tools/nix"
@@ -30,6 +31,12 @@ type DefaultValue struct {
30 Text string 31 Text string
31} 32}
32 33
34type ByName []Option
35
36func (a ByName) Len() int { return len(a) }
37func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
38func (a ByName) Less(i, j int) bool { return a[i].Name < a[j].Name }
39
33var optionsExpr = ` 40var optionsExpr = `
34let 41let
35 inherit (pkgs) options; 42 inherit (pkgs) options;
@@ -96,6 +103,7 @@ func LoadOptions(nixpkgs string) ([]Option, error) {
96 options = append(options, o) 103 options = append(options, o)
97 } 104 }
98 105
106 sort.Sort(ByName(options))
99 return options, nil 107 return options, nil
100} 108}
101 109