`deploy-to-nixos ihp-app` for a project without `Migration`
AronNovak opened this issue · comments
I am experimenting with https://github.com/digitallyinduced/ihp/blob/master/Guide/deployment.markdown?rgh-link-date=2023-11-06T20%3A07%3A52Z#deploying-with-deploy-to-nixos
After #1861 , I could configure my flake.nix
correctly, but then, there's this error:
aaron 105-deployment ~ gizra project-app deploy-to-nixos ihp-app
building the system configuration...
error:
… while calling the 'head' builtin
at /nix/store/3qq9i5znbx951wqpn7rs0jjw5zq3mxlj-source/lib/attrsets.nix:820:11:
819| || pred here (elemAt values 1) (head values) then
820| head values
| ^
821| else
… while evaluating the attribute 'value'
at /nix/store/3qq9i5znbx951wqpn7rs0jjw5zq3mxlj-source/lib/modules.nix:807:9:
806| in warnDeprecation opt //
807| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
808| inherit (res.defsFinal') highestPrio;
(stack trace truncated; use '--show-trace' to show the full trace)
error: getting status of '/nix/store/z3xi86j58l6igblyv56pk1bbsnag2ffd-source/Application/Migration': No such file or directory
Failed to start migrate.service: Unit migrate.service not found.
Is it trivially possible to get rid of migrate.service
for deploy-to-nixos ihp-app
?
Does your app have a migration? If not, can you run mkdir -p Application/Migration
?
You could also try to create an empty migration file as a workaround btw
aaron 105-deployment ~ gizra example-app cat Application/Migration/
20231120_DummyMigration.hs Migration.hs
aaron 105-deployment ~ gizra example-app cat Application/Migration/20231120_DummyMigration.hs
-- This is a dummy migration file.
aaron 105-deployment ~ gizra example-app cat Application/Migration/Migration.hs
aaron 105-deployment ~ gizra example-app deploy-to-nixos ihp-app
building the system configuration...
error:
… while calling the 'head' builtin
at /nix/store/3qq9i5znbx951wqpn7rs0jjw5zq3mxlj-source/lib/attrsets.nix:820:11:
819| || pred here (elemAt values 1) (head values) then
820| head values
| ^
821| else
… while evaluating the attribute 'value'
at /nix/store/3qq9i5znbx951wqpn7rs0jjw5zq3mxlj-source/lib/modules.nix:807:9:
806| in warnDeprecation opt //
807| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
808| inherit (res.defsFinal') highestPrio;
(stack trace truncated; use '--show-trace' to show the full trace)
error: getting status of '/nix/store/z3xi86j58l6igblyv56pk1bbsnag2ffd-source/Application/Migration': No such file or directory
I made a few attempts to create a dummy migration, but it gives the same error.
I am a bit unsure how error handling is done, so if the errors related to head
and value
can cause the last error, or the other way around. Normally this project does compile and has some test coverage as well.
Did you run git add Application/Migration
? If the files are not tracked by git, nix flake will not see them
@mpscholten Success, with the dummy migration file, I am able to proceed further, now I can tackle the SSH connectivity, but that's a different topic. Thanks!
After allowing the SSH connection, the same, well similar error returns back at a different phase.
aaron 105-deployment ~ gizra example-app deploy-to-nixos ihp-app
building the system configuration...
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/rxgrjbnbcwnbxhsz2c7cpia8sngimqfm-nixos-system-unnamed-23.11.20231003.ea0284a.drv^*'
ssh: connect to host ec2-54-155-151-14.eu-west-1.compute.amazonaws.com port 22: Connection timed out
error: failed to start SSH connection to 'ihp-app'
^C
< -- opening SSH port at the security group config -- >
aaron 105-deployment ~ gizra example-app SIGINT deploy-to-nixos ihp-app
building the system configuration...
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/rxgrjbnbcwnbxhsz2c7cpia8sngimqfm-nixos-system-unnamed-23.11.20231003.ea0284a.drv^*'
these 3943 derivations will be built:
/nix/store/b7irlwi2wjlx5aj1dghx4c8k3ax6m56q-busybox.drv
< -- all the packages here -- >
/nix/store/zw01jza1ms2asxhyvicqlnk0jwd7dymy-bitvec-1.1.5.0-doc
error: invalid character in Base64 string: ''
Failed to start migrate.service: Unit migrate.service not found.
Application/Migration/20231120_DummyMigration.hs
contains:
module Application.Migration20231120 where
import IHP.Migration
import IHP.ModelSupport
import Database.PostgreSQL.Simple
instance Migration where
up = pure () -- No operation on up migration
down = pure () -- No operation on down migration
With a blank Migration file, I have exactly the same error.
https://github.com/amitaibu/ihp-landing-page/pull/33/files - equivalent on an OSS repo, same error.
Likely I should provide a proper dummy Migration that can be initialized as a service.
@AronNovak i think this is fix, right?