2024-07-09 00:22:12 +00:00
|
|
|
#!/bin/env fish
|
2024-07-20 12:03:35 +00:00
|
|
|
function isConfigured -S
|
2024-09-08 15:09:01 +00:00
|
|
|
set -q CONFIG_NAME
|
|
|
|
end
|
|
|
|
|
2024-09-30 12:41:02 +00:00
|
|
|
function selectProfile -S -a result
|
|
|
|
source "$(status dirname)/../../../lib/modules/partition/select.fish"
|
|
|
|
set -l file (mktemp)
|
|
|
|
set -l header "NAME"
|
|
|
|
set -l profiles
|
|
|
|
|
|
|
|
getProfiles | jq ".[]" --raw-output0 | string split0 | while read profile
|
|
|
|
set -a profiles "$profile"
|
|
|
|
end
|
|
|
|
|
|
|
|
select "$header" "$file" \
|
|
|
|
"Please choose a profile" \
|
|
|
|
"No profiles specified" \
|
|
|
|
"$(string collect $profiles)"
|
|
|
|
|
|
|
|
set -g "$result" (cat "$file")
|
|
|
|
rm "$file"
|
|
|
|
end
|
|
|
|
|
2024-09-08 15:09:01 +00:00
|
|
|
function getProfiles -S
|
|
|
|
source "$(status dirname)/eval-flake.fish";
|
|
|
|
evalFlake "" "" --apply "builtins.attrNames" --json
|
2024-07-20 12:03:35 +00:00
|
|
|
end
|
|
|
|
|
2024-07-09 00:22:12 +00:00
|
|
|
function getConfig -S -a property
|
2024-09-08 15:09:01 +00:00
|
|
|
source "$(status dirname)/eval-flake.fish"
|
|
|
|
evalFlake "$CONFIG_NAME" "$property" $argv[2..]
|
2024-07-09 00:22:12 +00:00
|
|
|
end
|
2024-07-15 10:10:06 +00:00
|
|
|
|
2024-09-22 15:50:05 +00:00
|
|
|
function getOSConfigRoot
|
|
|
|
echo "valhalla.linux"
|
|
|
|
end
|
|
|
|
|
|
|
|
function getOSConfig -S -a property
|
|
|
|
getConfig "$(getOSConfigRoot).$property" $argv[2..]
|
|
|
|
end
|
|
|
|
|
2024-08-08 12:45:34 +00:00
|
|
|
function getAttributes -S -a property
|
|
|
|
getConfig "$property" --apply "builtins.attrNames" --json
|
|
|
|
end
|
|
|
|
|
2024-07-20 01:50:38 +00:00
|
|
|
function getUsers -S
|
2024-09-22 15:50:05 +00:00
|
|
|
getAttributes "$(getOSConfigRoot).users"
|
|
|
|
end
|
|
|
|
|
|
|
|
function getUserConfig -S -a name property
|
|
|
|
getOSConfig "users.$name.$property" $argv[3..]
|
2024-07-20 01:50:38 +00:00
|
|
|
end
|
|
|
|
|
2024-07-15 12:14:07 +00:00
|
|
|
function isSet -S -a property
|
|
|
|
not test "$(getConfig "$property" --json)" = "null"
|
|
|
|
end
|
|
|
|
|
2024-09-22 15:50:05 +00:00
|
|
|
function isOSSet -S -a property
|
|
|
|
isSet "$(getOSConfigRoot).$property"
|
|
|
|
end
|
|
|
|
|
|
|
|
function isUserSet -S -a name property
|
|
|
|
isOSSet "users.$name.$property"
|
|
|
|
end
|
|
|
|
|
2024-09-19 23:39:52 +00:00
|
|
|
function isEnabled -S -a property
|
|
|
|
getConfig "$property" --json | jq --exit-status > /dev/null
|
|
|
|
end
|
|
|
|
|
2024-09-22 15:50:05 +00:00
|
|
|
function isOSEnabled -S -a property
|
|
|
|
isEnabled "$(getOSConfigRoot).$property"
|
|
|
|
end
|
|
|
|
|
2024-07-15 10:10:06 +00:00
|
|
|
function collectionActive -S -a name
|
2024-09-23 00:29:18 +00:00
|
|
|
isOSEnabled "software.$name"
|
2024-07-15 10:10:06 +00:00
|
|
|
end
|