PortValhalla/scripts/Common/Scripts/config.fish

34 lines
806 B
Fish
Executable file

#!/bin/env fish
function isConfigured -S
set -q CONFIG_NAME
end
function getProfiles -S
source "$(status dirname)/eval-flake.fish";
evalFlake "" "" --apply "builtins.attrNames" --json
end
function getConfig -S -a property
source "$(status dirname)/eval-flake.fish"
evalFlake "$CONFIG_NAME" "$property" $argv[2..]
end
function getAttributes -S -a property
getConfig "$property" --apply "builtins.attrNames" --json
end
function getUsers -S
getAttributes "valhalla.users"
end
function isSet -S -a property
not test "$(getConfig "$property" --json)" = "null"
end
function isEnabled -S -a property
getConfig "$property" --json | jq --exit-status > /dev/null
end
function collectionActive -S -a name
[ "$(getConfig "valhalla.software.$name" --json)" = "true" ]
end