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

Add documentation on manually specifying packages option when parsing cabal.project fails #187

Open
ParetoOptimalDev opened this issue Jul 26, 2023 · 3 comments

Comments

@ParetoOptimalDev
Copy link

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 packages option manually or change your project configuration (cabal.project).

Perhaps this would belong in https://zero-to-flakes.com/gotchas

@srid
Copy link
Owner

srid commented Jul 26, 2023

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

srid added a commit that referenced this issue Jul 26, 2023
@ParetoOptimalDev
Copy link
Author

ParetoOptimalDev commented Aug 2, 2023

I would follow those instructions and add how to do this but I'm actually not sure 😆

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.

@srid
Copy link
Owner

srid commented Aug 3, 2023

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).

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

No branches or pull requests

2 participants