@@ -75,19 +75,25 @@ function print_source_help () {
75
75
echo " if 'source' is given as 'owner/repo', it will default to 'github:owner/repo'"
76
76
}
77
77
78
+ function show_tree_without_default () {
79
+ exa ${3} -Th " $1 " | rg -v " (default\.nix|profiles|modules)" | tail -n +1 || echo " $2 "
80
+ }
81
+
78
82
GIT_CACHE=" $HOME /.cache/bud/git"
79
83
80
84
case " $1 " in
81
85
" show" )
82
86
shift 1
83
87
84
88
url=" $1 "
89
+ ty=" $2 "
85
90
86
91
if [[ -z " $url " ]]; then
87
- echo " Show profiles available in the specified source\n"
88
- echo " Usage: show source\n"
92
+ echo " Show profiles / modules / users / hosts available in the specified source\n"
93
+ echo " Usage: show source (profiles|users|hosts|modules) \n"
89
94
print_source_help
90
- echo " if 'source' is '.', it will show your own profiles"
95
+ echo " if 'source' is '.', it will show your own profiles / users / hosts / modules\n"
96
+ echo " if none of 'profiles', 'users', 'hosts' or 'modules' are specified, it will default to 'profiles'"
91
97
exit 1
92
98
fi
93
99
@@ -100,19 +106,37 @@ case "$1" in
100
106
fetch_repo " $url " " $repo_path " || exit $?
101
107
fi
102
108
103
- echo " nixos profiles:"
104
- exa -Th " $repo_path /profiles" | grep -v " default.nix" | tail -n +2 || echo " no nixos profiles found"
105
- echo " home-manager profiles:"
106
- exa -Th " $repo_path /users/profiles" | grep -v " default.nix" | tail -n +2 || echo " no home-manager profiles found"
109
+ case " $ty " in
110
+ " users" )
111
+ echo " users:"
112
+ show_tree_without_default " $repo_path /users" " no users found" " --level=1"
113
+ ;;
114
+ " hosts" )
115
+ echo " hosts:"
116
+ show_tree_without_default " $repo_path /hosts" " no hosts found" " --level=1"
117
+ ;;
118
+ " modules" )
119
+ echo " nixos modules:"
120
+ show_tree_without_default " $repo_path /modules" " no nixos profiles found"
121
+ echo " home-manager modules:"
122
+ show_tree_without_default " $repo_path /users/modules" " no home-manager profiles found"
123
+ ;;
124
+ * )
125
+ echo " nixos profiles:"
126
+ show_tree_without_default " $repo_path /profiles" " no nixos profiles found"
127
+ echo " home-manager profiles:"
128
+ show_tree_without_default " $repo_path /users/profiles" " no home-manager profiles found"
129
+ ;;
130
+ esac
107
131
;;
108
132
" remove" )
109
133
shift 1
110
134
111
135
attr_origpath=$1
112
136
113
137
if [[ -z " $attr_origpath " ]]; then
114
- echo " Remove a profile from your config\n"
115
- echo " Usage: remove ( nixos|hm). profiles.[PROFILE ]"
138
+ echo " Remove a profile / user / host / module from your config\n"
139
+ echo " Usage: remove nixos.(profiles|users|hosts|modules).[NAME] / add source hm.( profiles|modules).[NAME ]"
116
140
exit 1
117
141
fi
118
142
@@ -133,8 +157,8 @@ case "$1" in
133
157
attr_origpath=$2
134
158
135
159
if [[ -z " $url " || -z " $attr_origpath " ]]; then
136
- echo " Add a profile from the specified source\n"
137
- echo " Usage: add source ( nixos|hm). profiles.[PROFILE ]\n"
160
+ echo " Add a profile / user / host / module from the specified source\n"
161
+ echo " Usage: add source nixos.(profiles|users|hosts|modules).[NAME] / add source hm.( profiles|modules).[NAME ]\n"
138
162
print_source_help
139
163
exit 1
140
164
fi
@@ -157,9 +181,9 @@ case "$1" in
157
181
;;
158
182
* )
159
183
echo " Available subcommands are:"
160
- echo " - 'add': Add a profile from the specified source"
161
- echo " - 'show': Show profiles available in the specified source"
162
- echo " - 'remove': Remove a profile from your config\n"
184
+ echo " - 'add': Add a profile / user / host / module from the specified source"
185
+ echo " - 'show': Show profiles / users / hosts / modules available in the specified source"
186
+ echo " - 'remove': Remove a profile / user / host / module from your config\n"
163
187
echo " run 'bud cfg command' for more info about a command"
164
188
exit 1
165
189
;;
0 commit comments