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

attrsOf -> lazyAttrsOf #271

Merged
merged 1 commit into from
Mar 12, 2024
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 @@ -12,6 +12,7 @@
- Breaking changes
- #221: Switch to `buildFromSdist`, to allow using non-standard package sets (wherein `cabal-install` is otherwise built without using user's overrides)
- #253: Turn off `buildFromSdist` by default. It can now be enabled manually by setting `settings.<name>.buildFromSdist` to `true`.
- #271: Change all `types.attrsOf` to `types.lazyAttrsOf`. If you use `lib.mkIf` for `attrsOf` values (not `submodule` options), use `lib.optionalAttrs` instead. This fixes #270 (`basePackages`) and improves performance.

## 0.4.0 (Aug 22, 2023)

Expand Down
2 changes: 1 addition & 1 deletion nix/modules/project-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ in
will create a flake check automatically.
'';
default = { };
type = types.attrsOf (types.submoduleWith {
type = types.lazyAttrsOf (types.submoduleWith {
specialArgs = { inherit pkgs self; };
modules = [
{
Expand Down
4 changes: 2 additions & 2 deletions nix/modules/project/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ in
else cls;
};
log = mkOption {
type = types.attrsOf (types.functionTo types.raw);
type = types.lazyAttrsOf (types.functionTo types.raw);
default = import ../../logging.nix {
name = config.projectFlakeName + "#haskellProjects." + name;
};
Expand All @@ -52,7 +52,7 @@ in
'';
};
basePackages = mkOption {
type = types.attrsOf raw;
type = types.lazyAttrsOf raw;
description = ''
Which Haskell package set / compiler to use.

Expand Down
4 changes: 2 additions & 2 deletions nix/modules/project/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let
default = hp: { };
};
extraLibraries = mkOption {
type = types.nullOr (functionTo (types.attrsOf (types.nullOr types.package)));
type = types.nullOr (functionTo (types.lazyAttrsOf (types.nullOr types.package)));
description = ''
Extra Haskell libraries available in the shell's environment.
These can be used in the shell's `runghc` and `ghci` for instance.
Expand All @@ -43,7 +43,7 @@ let
};

mkShellArgs = mkOption {
type = types.attrsOf types.raw;
type = types.lazyAttrsOf types.raw;
description = ''
Extra arguments to pass to `pkgs.mkShell`.
'';
Expand Down
8 changes: 4 additions & 4 deletions nix/modules/project/outputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ let
};
finalPackages = mkOption {
# This must be raw because the Haskell package set also contains functions.
type = types.attrsOf types.raw;
type = types.lazyAttrsOf types.raw;
readOnly = true;
description = ''
The final Haskell package set including local packages and any
overrides, on top of `basePackages`.
'';
};
packages = mkOption {
type = types.attrsOf packageInfoSubmodule;
type = types.lazyAttrsOf packageInfoSubmodule;
readOnly = true;
description = ''
Package information for all local packages. Contains the following keys:
Expand All @@ -34,7 +34,7 @@ let
'';
};
apps = mkOption {
type = types.attrsOf appType;
type = types.lazyAttrsOf appType;
readOnly = true;
description = ''
Flake apps for each Cabal executable in the project.
Expand All @@ -52,7 +52,7 @@ let
'';
};
exes = mkOption {
type = types.attrsOf appType;
type = types.lazyAttrsOf appType;
description = ''
Attrset of executables from `.cabal` file.

Expand Down
4 changes: 2 additions & 2 deletions nix/modules/project/settings/all.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ in
if enable then markBroken else unmarkBroken;
};
brokenVersions = {
type = types.attrsOf types.str;
type = types.lazyAttrsOf types.str;
description = ''
List of versions that are known to be broken.
'';
Expand Down Expand Up @@ -200,7 +200,7 @@ in
removeConfigureFlags;
};
cabalFlags = {
type = types.attrsOf types.bool;
type = types.lazyAttrsOf types.bool;
description = ''
Cabal flags to enable or disable explicitly.
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/modules/projects.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ in
options = {
haskellProjects = mkOption {
description = "Haskell projects";
type = types.attrsOf (types.submoduleWith {
type = types.lazyAttrsOf (types.submoduleWith {
specialArgs = { inherit pkgs self; };
modules = [
./project
Expand Down