Open ParetoOptimalDev opened 1 year ago
Perhaps this would belong in https://zero-to-flakes.com/gotchas
It should be in haskell-flake docs itself ... possibly a setup.md
under https://github.com/srid/haskell-flake/tree/master/doc/guide
I would follow those instructions and add how to do this but I'm actually not sure :laughing:
Going by this from the comment in the scaffolded flake.nix:
# Note that local packages are automatically included in `packages`
# (defined by `defaults.packages` option).
leads me to these docs: https://flake.parts/options/haskell-flake.html#opt-perSystem.haskellProjects._name_.defaults.packages
And seeing that packages seems to be "lazy attribute set of module" I should be able to follow the packages exmaple from the scaffolded flake.nix:
# packages = {
# aeson.source = "1.5.0.0"; # Hackage version override
# shower.source = inputs.shower;
# };
My guess I haven't been able to test yet is:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
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', pkgs, ... }: {
haskellProjects.default = {
defaults.packages = {
myproject.source = "0.0.1";
};
};
packages.default = self'.packages.myproject;
};
};
}
I'm assuming though that if the cabal.project file can't be parsed there might still be things broken anyway though.
I think what you want is:
perSystem = { self', pkgs, ... }: {
haskellProjects.default = {
defaults.packages = {}; # Disable default packages
packages = {
myproject.source = "0.0.1";
};
};
packages.default = self'.packages.myproject;
};
(Of course you want to use something like myproject.source = ./myproject
if you are trying to build a local package, rather than something from Hackage).
Ideally I would have been able to search one of the error message texts:
A default value for packages cannot be auto-determined
or
Please specify the
packagesoption manually or change your project configuration (cabal.project).
Perhaps this would belong in https://zero-to-flakes.com/gotchas