Hi, first off, thanks for creating haskell-flake
! It got me up and running with Haskell quickly.
I'm trying to deploy a Haskell project to a NixOS server and compilation fails when trying to embed files using template Haskell:
src/Settings.hs:139:23: error: [GHC-87897]
• Exception when trying to run compile-time code:
config/settings.yml: withBinaryFile: does not exist (No such file or directory)
Code: (embedFile configSettingsYml)
• In the untyped splice: $(embedFile configSettingsYml)
|
139 | configSettingsYmlBS = $(embedFile configSettingsYml)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[12 of 54] Compiling TodoBundleName ( src/TodoBundleName.hs, dist/build/TodoBundleName.o, dist/build/TodoBundleName.dyn_o )
[13 of 54] Compiling TodoName ( src/TodoName.hs, dist/build/TodoName.o, dist/build/TodoName.dyn_o )
[14 of 54] Compiling TodoStatus ( src/TodoStatus.hs, dist/build/TodoStatus.o, dist/build/TodoStatus.dyn_o )
[15 of 54] Compiling TransferFeePaidBy ( src/TransferFeePaidBy.hs, dist/build/TransferFeePaidBy.o, dist/build/TransferFeePaidBy.dyn_o )
[16 of 54] Compiling Model ( src/Model.hs, dist/build/Model.o, dist/build/Model.dyn_o )
src/Model.hs:64:3: error: [GHC-87897]
• Exception when trying to run compile-time code:
config/models.persistentmodels: withBinaryFile: does not exist (No such file or directory)
Code: (persistFileWith
lowerCaseSettings "config/models.persistentmodels")
• In the untyped splice:
$(persistFileWith
lowerCaseSettings "config/models.persistentmodels")
|
64 | $(persistFileWith lowerCaseSettings "config/models.persistentmodels")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The project compiles on my NixOS development machine using the devShell but the error occurs when deploying to a server running NixOS.
The files exist in the project, are checked in to the repo, and our old deployment pipeline using Docker works so I think I've made some mistake when setting it up using haskell-flake
.
Do I have to whitelist these files to be part of the build or so? I tried reading up on it but am too new to Nix to understand.
Here's the flake.nix
:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/f373ad52f1fa4187abeb7d1ce1056314bcbc9980";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.haskell-flake.flakeModule ];
perSystem = { self', system, lib, config, pkgs, ... }: {
haskellProjects.default = {
basePackages = pkgs.haskell.packages.ghc982;
# Want to override dependencies?
# See https://haskell.flake.page/dependency
settings = {
slugify.check = false;
sendgrid-v3.check = false;
fast-logger.check = false;
};
devShell = {
hlsCheck.enable = false;
};
autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
};
packages.default = self'.packages.internal-hs;
# apps.default = self'.apps.internal-hs;
devShells.default = pkgs.mkShell {
name = "Haskell devShell";
inputsFrom = [
config.haskellProjects.default.outputs.devShell
];
nativeBuildInputs = with pkgs; [
watchexec
pcre
zlib
];
};
};
};
}
Welcome, @Jkru
Did you include config/models.persistentmodels
in Cabal's data-files
?
Thank you, that solved the issue!
Last updated: Jan 18 2025 at 04:45 UTC