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

fix: don't rely on string context for package source #170

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `flake.haskellFlakeProjectModules`: Dropped all defaults, except the `output` module, which now exports `packages` and `settings`. Added a `defaults.projectModules.output` option that allows the user to override this module, or directly access the generated module.
- Add `project.config.defaults.settings.default` defining sensible defaults for local packages.
- Add `project.config.defaults.enable` to turn off all default settings en masse.
- Regressions in this PR: #169

## 0.3.0 (May 22, 2023)

Expand Down
3 changes: 1 addition & 2 deletions nix/modules/project/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ in
default = self: _super:
let
inherit (project.config) log;
isPathUnderNixStore = path: builtins.hasContext (builtins.toString path);
build-haskell-package = import ../../../build-haskell-package.nix {
inherit pkgs lib self log;
};
getOrMkPackage = name: cfg:
if isPathUnderNixStore cfg.source
if lib.types.path.check cfg.source
then
log.traceDebug "${name}.callCabal2nix ${cfg.source}"
(build-haskell-package name cfg.source)
Expand Down
8 changes: 3 additions & 5 deletions nix/modules/project/packages/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ let
inherit (lib)
mkOption
types;
# TODO: DRY
isPathUnderNixStore = path: builtins.hasContext (builtins.toString path);

# Whether the 'path' is local to `project.config.projectRoot`
localToProject = path:
path != null &&
isPathUnderNixStore path &&
lib.types.path.check path &&
lib.strings.hasPrefix "${project.config.projectRoot}" "${path}";
in
{ name, config, ... }: {
options = {
source = mkOption {
type = import ../../../types/haskell-source-type.nix { inherit lib; };
type = with types; either path str;
description = ''
Source refers to a Haskell package defined by one of the following:

Expand All @@ -43,7 +41,7 @@ in
'';
};
in
if isPathUnderNixStore config.source
if lib.types.path.check config.source
then haskell-parsers.getCabalExecutables config.source
else null; # cfg.source is Hackage version; nothing to do.
};
Expand Down
15 changes: 0 additions & 15 deletions nix/types/haskell-source-type.nix

This file was deleted.