mirror of
https://github.com/nix-community/disko.git
synced 2026-12-03 06:23:28 +01:00
Change --system-option KEY VAL to --system-config JSON
Update install-cli.nix
This commit is contained in:
1 parent
9f5d4e45cd
commit
2ec3549b6f
2 files changed
+14
-27
No files matched your search
+9
-25
@@ -19,10 +19,7 @@ Usage: $0 [OPTIONS]
|
|||||||
--write-efi-boot-entries Write EFI boot entries to the NVRAM of the system for the installed system.
|
--write-efi-boot-entries Write EFI boot entries to the NVRAM of the system for the installed system.
|
||||||
Specify this option if you plan to boot from this disk on the current machine,
|
Specify this option if you plan to boot from this disk on the current machine,
|
||||||
but not if you plan to move the disk to another machine.
|
but not if you plan to move the disk to another machine.
|
||||||
--system-option KEY VALUE Pass the specified system option to the NixOS configuration.
|
--system-config JSON Merges the specified JSON object into the NixOS configuration.
|
||||||
This option can be specified multiple times.
|
|
||||||
For example, to set the authorizedKeys, use
|
|
||||||
--system-option users.users.root.openssh.authorizedKeys.keys '[ "ssh-rsa ..." ]'
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,19 +36,6 @@ serialiaseArrayToNix() {
|
|||||||
echo "$nixExpr"
|
echo "$nixExpr"
|
||||||
}
|
}
|
||||||
|
|
||||||
serialiaseArrayToNixUnquoted() {
|
|
||||||
local -n array=$1
|
|
||||||
nixExpr="{ "
|
|
||||||
# Iterate over the associative array to populate the Nix attrset string
|
|
||||||
for key in "${!array[@]}"; do
|
|
||||||
value=${array[$key]}
|
|
||||||
nixExpr+="${key} = ${value};"
|
|
||||||
done
|
|
||||||
nixExpr+="}"
|
|
||||||
|
|
||||||
echo "$nixExpr"
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly libexec_dir="${0%/*}"
|
readonly libexec_dir="${0%/*}"
|
||||||
|
|
||||||
nix_args=(
|
nix_args=(
|
||||||
@@ -59,11 +43,12 @@ nix_args=(
|
|||||||
"--option" "no-write-lock-file" "true"
|
"--option" "no-write-lock-file" "true"
|
||||||
)
|
)
|
||||||
dry_run=
|
dry_run=
|
||||||
|
extraSystemConfig="{}"
|
||||||
diskoAttr=diskoScript
|
diskoAttr=diskoScript
|
||||||
writeEfiBootEntries=false
|
writeEfiBootEntries=false
|
||||||
declare -A diskMappings
|
declare -A diskMappings
|
||||||
declare -A extraFiles
|
declare -A extraFiles
|
||||||
declare -A extraSystemConfig
|
|
||||||
|
|
||||||
parseArgs() {
|
parseArgs() {
|
||||||
[[ $# -eq 0 ]] && {
|
[[ $# -eq 0 ]] && {
|
||||||
@@ -113,14 +98,13 @@ parseArgs() {
|
|||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--system-option)
|
--system-config)
|
||||||
if [[ $# -lt 3 ]]; then
|
if [[ $# -lt 2 ]]; then
|
||||||
echo "Option $1 requires two arguments: key, value" >&2
|
echo "Option $1 requires one JSON argument." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
extraSystemConfig[$2]=$3
|
extraSystemConfig="$2"
|
||||||
shift
|
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--extra-files)
|
--extra-files)
|
||||||
@@ -134,7 +118,7 @@ parseArgs() {
|
|||||||
;;
|
;;
|
||||||
--option)
|
--option)
|
||||||
if [[ $# -lt 3 ]]; then
|
if [[ $# -lt 3 ]]; then
|
||||||
echo "Option $1 requires an argument" >&2
|
echo "Option $1 requires two arguments: key, value" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
nix_args+=(--option "$2" "$3")
|
nix_args+=(--option "$2" "$3")
|
||||||
@@ -221,7 +205,7 @@ main() {
|
|||||||
--argstr rootMountPoint "$mountPoint" \
|
--argstr rootMountPoint "$mountPoint" \
|
||||||
--arg writeEfiBootEntries "$writeEfiBootEntries" \
|
--arg writeEfiBootEntries "$writeEfiBootEntries" \
|
||||||
--arg diskMappings "$(serialiaseArrayToNix diskMappings)" \
|
--arg diskMappings "$(serialiaseArrayToNix diskMappings)" \
|
||||||
--arg extraSystemConfig "$(serialiaseArrayToNixUnquoted extraSystemConfig)" \
|
--argstr extraSystemConfig "$extraSystemConfig" \
|
||||||
-A installToplevel \
|
-A installToplevel \
|
||||||
-A "$diskoAttr")
|
-A "$diskoAttr")
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -1,7 +1,7 @@
|
|||||||
{ flake
|
{ flake
|
||||||
, flakeAttr
|
, flakeAttr
|
||||||
, diskMappings
|
, diskMappings
|
||||||
, extraSystemConfig ? { }
|
, extraSystemConfig ? "{}"
|
||||||
, writeEfiBootEntries ? false
|
, writeEfiBootEntries ? false
|
||||||
, rootMountPoint ? "/mnt"
|
, rootMountPoint ? "/mnt"
|
||||||
,
|
,
|
||||||
@@ -52,7 +52,10 @@ let
|
|||||||
{
|
{
|
||||||
boot.loader.efi.canTouchEfiVariables = lib.mkVMOverride writeEfiBootEntries;
|
boot.loader.efi.canTouchEfiVariables = lib.mkVMOverride writeEfiBootEntries;
|
||||||
boot.loader.grub.devices = lib.mkVMOverride diskoSystem.config.boot.loader.grub.devices;
|
boot.loader.grub.devices = lib.mkVMOverride diskoSystem.config.boot.loader.grub.devices;
|
||||||
} // extraSystemConfig
|
imports = [
|
||||||
|
({ _file = "disko-install --system-config"; } // (builtins.fromJSON extraSystemConfig))
|
||||||
|
];
|
||||||
|
}
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user