mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-infect.git
synced 2025-02-16 14:24:42 +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 NL=$'\n'
|
||||||
readonly LOCAL_FLAKE_DIR="/etc/nixos"
|
readonly LOCAL_FLAKE_DIR="/etc/nixos"
|
||||||
readonly SECRETS_FILEPATH="/etc/selfprivacy/secrets.json"
|
readonly SECRETS_FILEPATH="/etc/selfprivacy/secrets.json"
|
||||||
|
readonly NIX="/root/.nix-profile/bin/nix"
|
||||||
|
readonly NIX_OPTS=(--extra-experimental-features "nix-command flakes")
|
||||||
DoNetConf=
|
DoNetConf=
|
||||||
|
|
||||||
genOptionalSsh() {
|
genOptionalSsh() {
|
||||||
|
@ -32,9 +34,15 @@ EOF
|
||||||
|
|
||||||
# Merge original userdata.json with deployment specific fields and print result.
|
# Merge original userdata.json with deployment specific fields and print result.
|
||||||
genUserdata() {
|
genUserdata() {
|
||||||
local HASHED_PASSWORD userdata_infect
|
local HASHED_PASSWORD userdata_infect release
|
||||||
HASHED_PASSWORD="$(mkpasswd -m sha-512 "$USER_PASS")"
|
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
|
userdata_infect=$(cat << EOF
|
||||||
{
|
{
|
||||||
$(genOptionalSsh)
|
$(genOptionalSsh)
|
||||||
|
@ -48,7 +56,8 @@ genUserdata() {
|
||||||
"domain": "$DOMAIN",
|
"domain": "$DOMAIN",
|
||||||
"hashedMasterPassword": "$HASHED_PASSWORD",
|
"hashedMasterPassword": "$HASHED_PASSWORD",
|
||||||
"hostname": "$HOSTNAME",
|
"hostname": "$HOSTNAME",
|
||||||
"username": "$LUSER"
|
"username": "$LUSER",
|
||||||
|
"stateVersion": "$release"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
@ -97,8 +106,6 @@ EOF
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local NIX="/root/.nix-profile/bin/nix"
|
|
||||||
local NIX_OPTS=(--extra-experimental-features nix-command)
|
|
||||||
local currentSystem
|
local currentSystem
|
||||||
if ! currentSystem="$($NIX "${NIX_OPTS[@]}" eval --impure --raw --expr builtins.currentSystem)"
|
if ! currentSystem="$($NIX "${NIX_OPTS[@]}" eval --impure --raw --expr builtins.currentSystem)"
|
||||||
then
|
then
|
||||||
|
@ -132,8 +139,6 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
genDeploymentConfiguration() {
|
genDeploymentConfiguration() {
|
||||||
local NIX="/root/.nix-profile/bin/nix"
|
|
||||||
local NIX_OPTS=(--extra-experimental-features "nix-command flakes")
|
|
||||||
local release
|
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")"
|
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!
|
# The content below is static and belongs to this deployment only!
|
||||||
# Do not copy this configuration file to another NixOS installation!
|
# 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)
|
`$(if [ "$DoNetConf" == "y" ]; then echo -e "$NL"; genNetworkingConf; fi)
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue