Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dotfiles
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
dotfiles
Commits
3255704a
Commit
3255704a
authored
5 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Move non-callable files of installation and cosmetic changes
parent
02245df3
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
bin/deploy
+1
-1
1 addition, 1 deletion
bin/deploy
bin/install
+10
-6
10 additions, 6 deletions
bin/install
bin/lib/format.nix
+12
-13
12 additions, 13 deletions
bin/lib/format.nix
bin/lib/util.zsh
+0
-0
0 additions, 0 deletions
bin/lib/util.zsh
bin/message
+3
-2
3 additions, 2 deletions
bin/message
with
26 additions
and
22 deletions
bin/deploy
+
1
−
1
View file @
3255704a
...
@@ -18,7 +18,7 @@ then
...
@@ -18,7 +18,7 @@ then
fi
fi
source
$DOTFILES_PATH
/bin/util.zsh
source
$DOTFILES_PATH
/bin/
lib/
util.zsh
usage
()
{
usage
()
{
print
"Usage:
$cmdname
[--via via_hostname] <hostname> [switch|boot|reboot|test|dry-activate|build]"
>
&2
print
"Usage:
$cmdname
[--via via_hostname] <hostname> [switch|boot|reboot|test|dry-activate|build]"
>
&2
...
...
This diff is collapsed.
Click to expand it.
bin/install
+
10
−
6
View file @
3255704a
...
@@ -5,7 +5,7 @@ set -e
...
@@ -5,7 +5,7 @@ set -e
set -u
set -u
set -o pipefail
set -o pipefail
source $DOTFILES_PATH/bin/util.zsh
source $DOTFILES_PATH/bin/
lib/
util.zsh
cmdname=$(basename $0)
cmdname=$(basename $0)
usage() {
usage() {
...
@@ -46,7 +46,7 @@ local_temp_dir=$(mktemp --tmpdir --directory install-via.XXXXXXXXXX)
...
@@ -46,7 +46,7 @@ local_temp_dir=$(mktemp --tmpdir --directory install-via.XXXXXXXXXX)
trap "rm -rf $local_temp_dir" EXIT INT HUP TERM
trap "rm -rf $local_temp_dir" EXIT INT HUP TERM
# Pre-build installation helper
# Pre-build installation helper
nix build --file $DOTFILES_PATH/bin/format.nix --argstr hostname "$hostname" --arg template "(import $MACHINES_PATH).machineTemplates.$hostname" --out-link "$local_temp_dir/format_$hostname"
nix build --file $DOTFILES_PATH/bin/
lib/
format.nix --argstr hostname "$hostname" --arg template "(import $MACHINES_PATH).machineTemplates.$hostname" --out-link "$local_temp_dir/format_$hostname"
if ! ssh -o VisualHostKey=yes root@$via_host true
if ! ssh -o VisualHostKey=yes root@$via_host true
then
then
...
@@ -73,15 +73,17 @@ luks_key=""
...
@@ -73,15 +73,17 @@ luks_key=""
EOF
EOF
luks_key=""
luks_key=""
nix copy --file $DOTFILES_PATH/bin/format.nix --argstr hostname "$hostname" --arg template "(import $MACHINES_PATH).machineTemplates.$hostname" --to ssh://root@$via_host
nix copy --file $DOTFILES_PATH/bin/
lib/
format.nix --argstr hostname "$hostname" --arg template "(import $MACHINES_PATH).machineTemplates.$hostname" --to ssh://root@$via_host
remote_temp_dir=$(ssh root@$via_host mktemp --tmpdir --directory install-via.XXXXXXXXXX)
remote_temp_dir=$(ssh root@$via_host mktemp --tmpdir --directory install-via.XXXXXXXXXX)
# copy install-helper and config
# copy install-helper and config
scp -r $local_temp_dir/* root@$via_host:$remote_temp_dir/
scp -r $local_temp_dir/* root@$via_host:$remote_temp_dir/
scp $DOTFILES_PATH/bin/message root@$via_host:$remote_temp_dir/
scp $DOTFILES_PATH/bin/message root@$via_host:$remote_temp_dir/
ssh root@$via_host "$remote_temp_dir/message" &
# -t: Force pseudo-terminal allocation
# -t: Force pseudo-terminal allocation
ssh -t root@$via_host "$remote_temp_dir/format_$hostname/bin/format_$hostname" "$remote_temp_dir/config" "$remote_temp_dir/output.json"
"$remote_temp_dir/message"
ssh -t root@$via_host "$remote_temp_dir/format_$hostname/bin/format_$hostname" "$remote_temp_dir/config" "$remote_temp_dir/output.json"
scp "root@$via_host:$remote_temp_dir/output.json" "$MACHINES_PATH/machines/$hostname/install-result.json"
scp "root@$via_host:$remote_temp_dir/output.json" "$MACHINES_PATH/machines/$hostname/install-result.json"
# TODO: ensure the working directory is set correctly
# TODO: ensure the working directory is set correctly
...
@@ -100,7 +102,9 @@ ssh root@$via_host "nixos-install --system $nixos_config_path && sync"
...
@@ -100,7 +102,9 @@ ssh root@$via_host "nixos-install --system $nixos_config_path && sync"
ssh root@$via_host mkdir --mode u=rwx,g=,o= --parents /mnt/secrets/passwords
ssh root@$via_host mkdir --mode u=rwx,g=,o= --parents /mnt/secrets/passwords
# TODO: get host-specific password
# TODO: get host-specific password
scp -r notThePassword root@$via_host:/mnt/secrets/passwords/root
#scp -r notThePassword root@$via_host:/mnt/secrets/passwords/root
scp -r notThePassword root@$via_host:/mnt/secrets/passwords/jens
#scp -r notThePassword root@$via_host:/mnt/secrets/passwords/jens
ssh root@$via_host sync
print_info "Installation completed"
print_info "Installation completed"
This diff is collapsed.
Click to expand it.
bin/format.nix
→
bin/
lib/
format.nix
+
12
−
13
View file @
3255704a
...
@@ -39,13 +39,12 @@ assert (typeOf swap) == "string";
...
@@ -39,13 +39,12 @@ assert (typeOf swap) == "string";
set -e
set -e
set -u
set -u
set -o pipefail
set -o pipefail
set -x
source
${
./util.zsh
}
source
${
./util.zsh
}
cmdname=$0
cmdname=$0
usage() {
usage() {
print "Usage: $cmdname <CONFIG_FILE> <OUTPUT_FILE>
[<MESSAGE_PROGRAM>]
" >&2
print "Usage: $cmdname <CONFIG_FILE> <OUTPUT_FILE>" >&2
}
}
print_info() {
print_info() {
...
@@ -80,7 +79,6 @@ assert (typeOf swap) == "string";
...
@@ -80,7 +79,6 @@ assert (typeOf swap) == "string";
config_file="$1"
config_file="$1"
output_file="$2"
output_file="$2"
message_program="$3"
# Before doing anything that could fail:
# Before doing anything that could fail:
# Set up tmpdir controlled by this script (and trap to remove it) and move the
# Set up tmpdir controlled by this script (and trap to remove it) and move the
...
@@ -130,12 +128,7 @@ assert (typeOf swap) == "string";
...
@@ -130,12 +128,7 @@ assert (typeOf swap) == "string";
exit 3
exit 3
fi
fi
if [ -x $message_program ]
print_info "Discarding disk contents"
then
$message_program &
fi
print_info "Discarding disk contents..."
if
${
blkdiscard-bin
}
$block_device
if
${
blkdiscard-bin
}
$block_device
then
then
ssd=true
ssd=true
...
@@ -165,7 +158,7 @@ assert (typeOf swap) == "string";
...
@@ -165,7 +158,7 @@ assert (typeOf swap) == "string";
system_partition="$block_device"3
system_partition="$block_device"3
''
else
abort
"Invalid bootloader configured in template:
${
template
.
bootloader
}
"
}
''
else
abort
"Invalid bootloader configured in template:
${
template
.
bootloader
}
"
}
print_info "Creating partitions
...
"
print_info "Creating partitions"
${
mkfs-fat-bin
}
-F32 -n ESP "$esp_partition"
${
mkfs-fat-bin
}
-F32 -n ESP "$esp_partition"
...
@@ -222,10 +215,16 @@ assert (typeOf swap) == "string";
...
@@ -222,10 +215,16 @@ assert (typeOf swap) == "string";
mkdir -p $mount_point/boot
mkdir -p $mount_point/boot
${
mount-bin
}
-o noatime $esp_partition $mount_point/boot
${
mount-bin
}
-o noatime $esp_partition $mount_point/boot
print_info "Generating NixOS hardware config..."
if [[ -d /nix/.rw-store ]]
then
print_info "Nix store tmpfs-rw-overlay detected, increasing tmpfs size"
mount -o remount,size=8G /nix/.rw-store
fi
print_info "Generating NixOS hardware config"
nixos-generate-config --root $mount_point
nixos-generate-config --root $mount_point
print_info "Writing output
...
"
print_info "Writing output"
> "$output_file" <<EOF
> "$output_file" <<EOF
{
{
"installedBlockDevice": "$stable_block_device",
"installedBlockDevice": "$stable_block_device",
...
@@ -240,4 +239,4 @@ assert (typeOf swap) == "string";
...
@@ -240,4 +239,4 @@ assert (typeOf swap) == "string";
print_info "Installation stage 1 completed"
print_info "Installation stage 1 completed"
''
;
''
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bin/util.zsh
→
bin/
lib/
util.zsh
+
0
−
0
View file @
3255704a
File moved
This diff is collapsed.
Click to expand it.
bin/message
+
3
−
2
View file @
3255704a
...
@@ -18,7 +18,8 @@ reset() {
...
@@ -18,7 +18,8 @@ reset() {
}
}
reset
reset
sleep
1
sleep
1s
reset
# print character char by char
# print character char by char
for
((
i
=
0
;
i<
${#
message
}
;
i++
))
for
((
i
=
0
;
i<
${#
message
}
;
i++
))
...
@@ -30,7 +31,7 @@ done
...
@@ -30,7 +31,7 @@ done
# keep screen clear of error messages
# keep screen clear of error messages
while
true
while
true
do
do
sleep
10
sleep
10
s
reset
reset
print
-n
"
${
message
}
"
>
$tty
print
-n
"
${
message
}
"
>
$tty
done
done
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment