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
e7872bcc
Commit
e7872bcc
authored
4 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Improve deploy script
parent
4c8e4d80
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/deploy
+12
-11
12 additions, 11 deletions
bin/deploy
with
12 additions
and
11 deletions
bin/deploy
+
12
−
11
View file @
e7872bcc
...
...
@@ -93,21 +93,21 @@ else
fi
readonly
local_temp_dir
=
$(
mktemp
--tmpdir
--directory
phoenix-deploy.XXXXXXXXXX
)
trap
"rm -rf
$local_temp_dir
"
EXIT INT HUP TERM
if
[[
"
$operation
"
=
"iso"
]]
then
print_info
"Building iso image"
nix build
"path:
$MACHINES_PATH
#nixosConfigurations.
$hostname
.config.system.build.iso"
--out-link
"
$local_temp_dir
/nixos-iso-
$hostname
"
readonly
nixos_iso_path
=
$(
realpath
"
$local_temp_dir
/nixos-iso-
$hostname
"
)
readonly
nixos_iso_path
=
$(
nix build
--no-link
--json
"path:
$MACHINES_PATH
#nixosConfigurations.
$hostname
.config.system.build.iso"
| jq
--raw-output
".[0].outputs.out"
)
print_info
"Iso generated"
print
$nixos_iso_path
exit
0
fi
print_info
"Evaluating target system configuration"
readonly
system_installable
=
"path:
$MACHINES_PATH
#nixosConfigurations.
$hostname
.config.system.build.toplevel"
readonly
nixos_config_path
=
$(
nix path-info
--json
"
$system_installable
"
| jq
--raw-output
".[0].path"
)
print
>
&2
"
$nixos_config_path
"
print_info
"Deploying target system configuration"
if
[[
"
$is_target_host
"
||
"
$operation
"
=
"build"
]]
...
...
@@ -115,8 +115,7 @@ then
# local deploy
print_info
"Building target system configuration"
nix build
"path:
$MACHINES_PATH
#nixosConfigurations.
$hostname
.config.system.build.toplevel"
--out-link
"
$local_temp_dir
/nixos-config-
$hostname
"
readonly
nixos_config_path
=
$(
realpath
"
$local_temp_dir
/nixos-config-
$hostname
"
)
nix build
--no-link
"
$system_installable
"
if
[[
"
$operation
"
=
"build"
]]
then
...
...
@@ -139,16 +138,18 @@ then
else
# remote deploy
nix copy
--substitute-on-destination
--to
"ssh://root@
$via_hostname
"
"path:
$MACHINES_PATH
#nixosConfigurations.
$hostname
.config.system.build.toplevel"
# The manual way to do it (this is in theory also supported by nixos-rebuild by using '-I')
nix copy
--substitute-on-destination
--to
"ssh://root@
$via_hostname
"
"
$system_installable
"
# The manual way to activate a system derivation
if
[[
-n
"
$set_profile
"
]]
then
ssh root@
$via_hostname
"nix-env --profile /nix/var/nix/profiles/system --set
$nixos_config_path
"
fi
ssh root@
$via_hostname
"
$nixos_config_path
/bin/switch-to-configuration
$operation
&& sync"
# This should work instead, but has some bugs at the moment
#nixos-rebuild "$operation" --flake "path:$MACHINES_PATH#$hostname" --target-host "root@$via_hostname"
if
[[
-n
"
$reboot
"
]]
then
ssh root@
$via_hostname
"systemctl reboot"
...
...
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