mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect.git
synced 2024-11-22 03:51:27 +00:00
add stateVersion to userdata.json
This commit is contained in:
parent
2d54653924
commit
9cd6207238
19
nixos-infect
19
nixos-infect
|
@ -22,6 +22,8 @@
|
|||
readonly NL=$'\n'
|
||||
readonly LOCAL_FLAKE_DIR="/etc/nixos"
|
||||
readonly SECRETS_FILEPATH="/etc/selfprivacy/secrets.json"
|
||||
readonly NIX="/root/.nix-profile/bin/nix"
|
||||
readonly NIX_OPTS=(--extra-experimental-features "nix-command flakes")
|
||||
DoNetConf=
|
||||
|
||||
genOptionalSsh() {
|
||||
|
@ -32,9 +34,15 @@ EOF
|
|||
|
||||
# Merge original userdata.json with deployment specific fields and print result.
|
||||
genUserdata() {
|
||||
local HASHED_PASSWORD userdata_infect
|
||||
local HASHED_PASSWORD userdata_infect release
|
||||
HASHED_PASSWORD="$(mkpasswd -m sha-512 "$USER_PASS")"
|
||||
|
||||
if ! release="$($NIX "${NIX_OPTS[@]}" eval --impure --raw --expr "(builtins.getFlake (builtins.toString ${LOCAL_FLAKE_DIR})).inputs.selfprivacy-nixos-config.inputs.nixpkgs.lib.trivial.release")"
|
||||
then
|
||||
echo "cannot determine NixOS release version"
|
||||
return 1
|
||||
fi
|
||||
|
||||
userdata_infect=$(cat << EOF
|
||||
{
|
||||
$(genOptionalSsh)
|
||||
|
@ -48,7 +56,8 @@ genUserdata() {
|
|||
"domain": "$DOMAIN",
|
||||
"hashedMasterPassword": "$HASHED_PASSWORD",
|
||||
"hostname": "$HOSTNAME",
|
||||
"username": "$LUSER"
|
||||
"username": "$LUSER",
|
||||
"stateVersion": "$release"
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
@ -97,8 +106,6 @@ EOF
|
|||
)
|
||||
fi
|
||||
|
||||
local NIX="/root/.nix-profile/bin/nix"
|
||||
local NIX_OPTS=(--extra-experimental-features nix-command)
|
||||
local currentSystem
|
||||
if ! currentSystem="$($NIX "${NIX_OPTS[@]}" eval --impure --raw --expr builtins.currentSystem)"
|
||||
then
|
||||
|
@ -132,8 +139,6 @@ EOF
|
|||
}
|
||||
|
||||
genDeploymentConfiguration() {
|
||||
local NIX="/root/.nix-profile/bin/nix"
|
||||
local NIX_OPTS=(--extra-experimental-features "nix-command flakes")
|
||||
local release
|
||||
|
||||
if ! release="$($NIX "${NIX_OPTS[@]}" eval --impure --raw --expr "(builtins.getFlake (builtins.toString ${LOCAL_FLAKE_DIR})).inputs.selfprivacy-nixos-config.inputs.nixpkgs.lib.trivial.release")"
|
||||
|
@ -147,7 +152,7 @@ ${DoNetConf:+"{ lib, ... }: "}{
|
|||
# The content below is static and belongs to this deployment only!
|
||||
# Do not copy this configuration file to another NixOS installation!
|
||||
|
||||
system.stateVersion = "$release";`
|
||||
# system.stateVersion = "$release";`
|
||||
`$(if [ "$DoNetConf" == "y" ]; then echo -e "$NL"; genNetworkingConf; fi)
|
||||
}
|
||||
EOF
|
||||
|
|
Loading…
Reference in a new issue