blob: 39ed1639c3b2127b1349300a793f6454f1bc49cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#!/usr/bin/env fish
if not set --query HOME
echo "error: no HOME"
exit 1
end
set --function channel_root $HOME/.nix-defexpr/channels
set --function user_nixpkgs $HOME/.config/nixpkgs
set --function nixfiles (path resolve (status dirname)/..)
if set --query XDG_CONFIG_HOME
set --function hm_config_dir $XDG_CONFIG_HOME/home-manager
else
set --function hm_config_dir $HOME/.config/home-manager
end
for i in 1
if test ! -d $user_nixpkgs
echo "user nixpkgs folder $user_nixpkgs does not exist, creating it"
mkdir -p $user_nixpkgs
end
if test -L $hm_config_dir -a (path resolve $hm_config_dir) = (path resolve (status basename))
if test y = (read --nchars=1 --prompt-str="$hm_config_dir already exists as a symlink to the current directory. Remove it [yN]? ")
unlink $hm_config_dir
end
end
if test ! -d $hm_config_dir
echo "user home-manager configuration folder $hm_config_dir does not exist, creating it"
mkdir -p $hm_config_dir
end
if test -e $channel_root
rm $channel_root/* || exit 1
rmdir $channel_root
end
end
set --function current_script_name (status basename)
switch $current_script_name
case darwin-rebuild
set --local darwin_config_source $nixfiles/system/$hostname.nix
set --local darwin_config_target $user_nixpkgs/darwin-configuration.nix
if test ! -e $darwin_config_target
ln -s $darwin_config_source $darwin_config_target
end
set --append argv -I darwin-config=$darwin_config_source
case nixos-rebuild
set --local nixos_config_source $nixfiles/system/$hostname.nix
set --local nixos_config_target $user_nixpkgs/configuration.nix
if test ! -e $nixos_config_target
ln -s $nixos_config_source $nixos_config_target
end
if ! fish_is_root_user
set --append argv --use-remote-sudo
end
set --append argv -I nixos-config=$nixos_config_source
case home-manager
set --local hm_config_source $nixfiles/user/$hostname.nix
set --local hm_config_target $hm_config_dir/home.nix
if test ! -e $hm_config_target
ln -s $hm_config_source $hm_config_target
end
set --export HOME_MANAGER_CONFIG $hm_config_source
end
function update_link --argument-names new_src target
set --function current_src (path resolve $target)
if test -e $current_src
if test $current_src = $new_src
# no need to re-link it
return
else
unlink $target
end
end
ln -s $new_src $target
end
for np in $NIX_PATH
echo $np | read --function --delimiter "=" channel new_src
if test $channel = nixpkgs-overlays
update_link $new_src $user_nixpkgs/overlays
continue
end
end
set --function i (contains --index (status dirname) $PATH)
if test -n $i
set --erase PATH[$i]
end
set --function cmd $current_script_name $argv
if contains -- -n $argv
set --prepend cmd echo
end
if set --query IN_NIX_SHELL
eval $cmd
else
nix-shell --run "$cmd"
end
|