all repos — nixfiles @ 7fc398dded782164e47cc201405cf36570e5d8ff

System and user configuration, managed by nix and home-manager

bin/os_update_remote (view raw)

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
#!/usr/bin/env fish

argparse --move-unknown "r/remote&" "l/local&" "b/build-host=&" "e/elevation-strategy=&" -- $argv

set --local target $argv[1]
set --local actions $argv[2] switch

set --local user_regex '(?<user>[[:graph:]]+)'
set --local host_regex '(?<host>[[:alnum:]\-]*)'
set --local fqdn_regex "(?<fqdn>$host_regex(?:\.[[:alnum:]\-.]+)?)"
string match --quiet --regex --groups-only "(?:$user_regex@)?$fqdn_regex" $target

set --local action $actions[1]
set --local build_host $_flag_build_host $target

set --local elevation_strategy $_flag_elevation_strategy (
    if test "$user" = "root"
        echo none
    else
        echo passwordless
    end
)

if set --query _flag_remote
    echo "warn: flag --remote is the default and can be removed" >&2
end

if set --query _flag_build_host; or not set --query _flag_local
    set --function build_host_arg --build-host $build_host[1]
end

nh os $action \
    --file . nixosConfigurations.{$host} \
    $build_host_arg \
    --use-substitutes \
    --target-host {$target} \
    --show-trace \
    --elevation-strategy $elevation_strategy[1] \
    $argv_opts