Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy-to-nixos ihp-app for a project without Migration #1862

Open
AronNovak opened this issue Nov 17, 2023 · 9 comments
Open

deploy-to-nixos ihp-app for a project without Migration #1862

AronNovak opened this issue Nov 17, 2023 · 9 comments
Labels

Comments

@AronNovak
Copy link
Contributor

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?

@mpscholten
Copy link
Member

Does your app have a migration? If not, can you run mkdir -p Application/Migration?

@mpscholten
Copy link
Member

You could also try to create an empty migration file as a workaround btw

@mpscholten mpscholten added the bug label Nov 17, 2023
@AronNovak
Copy link
Contributor Author

@mpscholten

 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.

@mpscholten
Copy link
Member

Did you run git add Application/Migration? If the files are not tracked by git, nix flake will not see them

@AronNovak
Copy link
Contributor Author

@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!

@AronNovak
Copy link
Contributor Author

AronNovak commented Nov 21, 2023

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.

@AronNovak
Copy link
Contributor Author

AronNovak commented Nov 24, 2023

https://github.com/amitaibu/ihp-landing-page/pull/33/files - equivalent on an OSS repo, same error.

@AronNovak
Copy link
Contributor Author

Likely I should provide a proper dummy Migration that can be initialized as a service.

@mpscholten
Copy link
Member

@AronNovak i think this is fix, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants