Skip to content

Commit

Permalink
Improved b.c. support for nix-build
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Jun 4, 2023
1 parent eeb86b4 commit eebbda8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
22 changes: 9 additions & 13 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
let
ihp = builtins.fetchGit {
url = "https://github.com/digitallyinduced/ihp.git";
ref = "refs/tags/v1.0.1";
};
haskellEnv = import "${ihp}/NixSupport/default.nix" {
ihp = ihp;
haskellDeps = (import ./devenv.nix { pkgs = {}; inputs = {}; config = {}; }).ihp.haskellPackages;
otherDeps = pkgs: (import ./devenv.nix { inherit pkgs; inputs = {}; config = {}; }).packages;
projectPath = ./.;
};
in
haskellEnv
# For backwards compatibility using flake.nix
(import
(
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/12c64ca55c1014cdc1b16ed5a804aa8576601ff2.tar.gz";
sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5";
}
)
{ src = ./.; }).defaultNix
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
};
});
# Binaries for deploying IHP apps. These are used by `nix build --impure`
packages = forEachSystem (system: { default = releaseEnv nixpkgs.legacyPackages.${system}; });
defaultPackage = forEachSystem (system: releaseEnv nixpkgs.legacyPackages.${system});
};

# The following is needed to use the IHP binary cache.
Expand Down

15 comments on commit eebbda8

@CSchank
Copy link

@CSchank CSchank commented on eebbda8 Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpscholten this broke new IHP projects for us on macOS and Codespaces. Is this a mistake? Or is something not configured right on our end to support this?

@mpscholten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share the error message? This change is in preparation for the upcoming IHP v1.1.0 release

@CSchank
Copy link

@CSchank CSchank commented on eebbda8 Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things seem to go wrong, including direnv allow not working:

@CSchank ➜ /workspaces/TestIHPJun5 (main) $ direnv allow
direnv: loading /workspaces/TestIHPJun5/.envrc
direnv: loading https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc (sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=)
direnv: using flake . --impure
error: getting status of '/nix/store/8d5j2q137h82z77gdqhgl1k5fidw69d2-source/flake.nix': No such file or directory
error: getting status of '/workspaces/TestIHPJun5/.direnv/flake-profile.10169': No such file or directory
error: getting status of '/nix/store/8d5j2q137h82z77gdqhgl1k5fidw69d2-source/flake.nix': No such file or directory
direnv: nix-direnv: renewed cache
direnv: export +XDG_DATA_DIRS

And, when trying to run nix-shell:

@CSchank ➜ /workspaces/TestIHPJun5 (main) $ nix-shell
error:
       … while evaluating the attribute 'defaultNix'

         at /nix/store/5y55s6z7hlcy3gl6dmnxi3milkq37hnp-source/default.nix:190:5:

          189|   rec {
          190|     defaultNix =
             |     ^
          191|       result

       … in the left operand of the update (//) operator

         at /nix/store/5y55s6z7hlcy3gl6dmnxi3milkq37hnp-source/default.nix:192:7:

          191|       result
          192|       // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {});
             |       ^
          193|

       (stack trace truncated; use '--show-trace' to show the full trace)

@mpscholten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be caused by a missing flake.lock. Just pushed this via 177a78a Now ihp-new test work again locally

@CSchank
Copy link

@CSchank CSchank commented on eebbda8 Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try it out, thank you!

@CSchank
Copy link

@CSchank CSchank commented on eebbda8 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still getting this when trying to run it in Codespaces (the old default.nix without flake still works perfectly). And this version does appear to work in macOS. Any ideas?

direnv: error /workspaces/IHPTestJune5Again/test/.envrc is blocked. Run `direnv allow` to approve its content
@CSchank ➜ /workspaces/IHPTestJune5Again/test (main) $ direnv allow
direnv: loading /workspaces/IHPTestJune5Again/test/.envrc
direnv: loading https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc (sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=)
direnv: using flake . --impure
error: getting status of '/nix/store/8d5j2q137h82z77gdqhgl1k5fidw69d2-source/test': No such file or directory
error: getting status of '/workspaces/IHPTestJune5Again/test/.direnv/flake-profile.20783': No such file or directory
error: getting status of '/nix/store/8d5j2q137h82z77gdqhgl1k5fidw69d2-source/test': No such file or directory
direnv: nix-direnv: renewed cache
direnv: export +XDG_DATA_DIRS
@CSchank ➜ /workspaces/IHPTestJune5Again/test (main) $ 

@CSchank
Copy link

@CSchank CSchank commented on eebbda8 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I think we have to retool our postCreateCommand script. I'll play with it and get back to you.

@mpscholten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let me know in case I can help in any way

@CSchank
Copy link

@CSchank CSchank commented on eebbda8 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Marc! Still having the issue above in Codespaces. In a plain Ubuntu installation using Nix directly, the server compiles all the way to Main but then we never get "Server started". The Dev server runs, but the actual application server gets stuck on the compiling screen. This repo, which is the boilerplate from 2 weeks ago, works fine.

@CSchank
Copy link

@CSchank CSchank commented on eebbda8 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I know that's not much of a bug report! But it didn't give me much more information. Here's how it gets stuck:

image

@mpscholten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Can you it with the env var DEBUG=1 set? Then the terminal will output lots of debug info. Could you share that debug info here?

@CSchank
Copy link

@CSchank CSchank commented on eebbda8 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~/blog$ DEBUG=1 ./start
direnv: loading ~/blog/.envrc
direnv: export ~PATH
IHP Version: 1.0.1
Gtk-Message: 16:01:05.699: Not loading module "atk-bridge": The functionality is provided by GTK natively. Please try to not load it.
GET /
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
  Status: 302 Found 0.000432141s

GHCI: :set prompt ""
GHCI: import qualified ClassyPrelude
[("ihpVersion","1.0.1"),("os","linux"),("arch","x86_64"),("projectId","f71494f6c921b3aad75350e954b339a90439dce5bd04bb9d711e85ba13b7c0563155fb937acb6129125cc13fbf25e2f0021b33e5e25885b73ceb3484ccdd3c25")]
 ===> AppState {postgresState = NotStarted, appGHCIState = NotStarted, statusServerState = NotStarted, databaseNeedsMigration = (..), lastSchemaCompilerError = (..)}
UpdateStatusServerState Started
 ===> AppState {postgresState = NotStarted, appGHCIState = NotStarted, statusServerState = Started, databaseNeedsMigration = (..), lastSchemaCompilerError = (..)}
UpdateAppGHCIState Loading
 ===> AppState {postgresState = NotStarted, appGHCIState = Loading, statusServerState = Started, databaseNeedsMigration = (..), lastSchemaCompilerError = (..)}
AppModulesLoaded {success = True}
AppModulesLoaded but db not in PostgresStarted state, therefore not starting app yet
 ===> AppState {postgresState = NotStarted, appGHCIState = Loaded, statusServerState = Started, databaseNeedsMigration = (..), lastSchemaCompilerError = (..)}
GET /ShowTable
  Params: [("tableName","posts")]
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
  Status: 200 OK 0.000769501s

GET /IDE/contextmenu.js
  Params: [("v","1.0.1")]
  Accept: */*
  Status: 200 OK 0.00015016s

GET /IDE/ihp-help.js
  Params: [("v","1.0.1")]
  Accept: */*
  Status: 200 OK 0.00011339s

IHP Telemetry is activated. This can be disabled by setting env variable IHP_TELEMETRY_DISABLED=1
GET /EditColumn
  Params: [("tableName","posts"),("columnId","1")]
  Accept: text/html, application/xhtml+xml
  Status: 200 OK 0.000899001s

@mpscholten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppModulesLoaded but db not in PostgresStarted state, therefore not starting app yet

Something is wrong with postgres. Can you run make postgres to start the postgres server manually? This will likely output the error postgres receives on startup

@CSchank
Copy link

@CSchank CSchank commented on eebbda8 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^CStop called
RunDevServer: ExitSuccess
direnv: loading ~/blog/.envrc
direnv: export ~PATH
(base) chris@chris-System-Product-Name:~/blog$ make postgres
Starting postgres
sh: line 1: postgres: command not found
make: *** [build/ihp-lib/Makefile.dist:111: postgres] Error 127

I wondered if it was something about Postgres. Weird... is it not being installed for some reason?

@mpscholten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share what is in .envrc?

Please sign in to comment.