git.fiddlerwoaroof.com
Browse code

feat(scripts): add utilities for managing home-manager

Edward Langley authored on 22/10/2022 21:16:09
Showing 2 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,18 @@
1
+#!/usr/bin/env zsh
2
+
3
+set -eu -o pipefail
4
+set -x
5
+
6
+source "$(which hm-util)"
7
+
8
+profile_path="$(hm-profile-path)"
9
+
10
+new_path="$(home-manager build)"
11
+
12
+new_profile="$(readlink "$new_path"/home-path)"
13
+
14
+if [[ "$new_profile" != "$profile_path" ]] && [[ -n "$new_path" ]]; then
15
+  nix profile remove "$profile_path"
16
+  "$new_path"/home-path/bin/home-manager switch
17
+fi
18
+
0 19
new file mode 100755
... ...
@@ -0,0 +1,19 @@
1
+#!/usr/bin/env zsh
2
+
3
+hm-profile() {
4
+  nix profile list | grep home-manager-path | head -n1 
5
+}
6
+
7
+hm-profile-number() {
8
+  hm-profile | read -r a b
9
+  echo "$a"
10
+}
11
+
12
+hm-profile-path() {
13
+  hm-profile | read -r a b c d 
14
+  echo "$d"
15
+}
16
+
17
+if ! [[ $ZSH_EVAL_CONTEXT =~ :file$ ]]; then
18
+  "$@"
19
+fi