Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Rework modules #1999

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

Merged
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
2 changes: 2 additions & 0 deletions 2 lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -603,4 +603,6 @@ in {
__toJSON (__attrNames (lib.filterAttrs (_: v: __length v > 1) (
builtins.groupBy (x: if __typeOf x == "set" then x.name or "noname" else "notset") x)))
}";

types = import ./types.nix { inherit lib; };
}
47 changes: 47 additions & 0 deletions 47 lib/types.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ lib }:

with lib;

rec {
# This is just like listOf, except that it filters out all null elements.
listOfFilteringNulls = elemType: types.listOf elemType // {
# Mostly copied from nixpkgs/lib/types.nix
merge = loc: defs:
map (x: x.value) (filter (x: x ? value && x.value != null) (concatLists (imap1
(n: def:
if isList def.value then
imap1
(m: def':
(mergeDefinitions
(loc ++ [ "[definition ${toString n}-entry ${toString m}]" ])
elemType
[{ inherit (def) file; value = def'; }]
).optionalValue
)
def.value
else
throw "The option value `${showOption loc}` in `${def.file}` is not a list.")
defs)));
};

# dealing with str is a bit annoying especially with `nullOr str` as that apparently defaults to ""
# instead of null :shrug:. This then messes with our option inheritance logic.
# Hence we have a uniqueStr type that ensures multiple identically defined options are collapsed
# without raising an error. And a way to fetch default options that will retain `null` if the
# option is not defined or "".
getDefaultOrNull = def: key: if def ? ${key} && def.${key} != "" then def.${key} else null;

mergeUniqueOption = locs: defs:
let
mergeOneOption = loc: defs':
# we ignore "" as optionalString, will default to "".
let defs = filter (x: x.value != "") defs'; in
if defs == [ ] then null
else if length defs != 1 then
throw "The unique option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}; with values `${concatStringsSep "', `" (map (x: x.value) defs)}'."
else (head defs).value;
in
mergeOneOption locs (lists.unique defs);

uniqueStr = types.str // { merge = mergeUniqueOption; };
}
166 changes: 166 additions & 0 deletions 166 modules/component-options.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{ lib, haskellLib, ... }:
{
options = {
buildable = lib.mkOption {
type = lib.types.bool;
default = true;
};

configureFlags = lib.mkOption {
type = haskellLib.types.listOfFilteringNulls lib.types.str;
default = [];
};

setupBuildFlags = lib.mkOption {
type = haskellLib.types.listOfFilteringNulls lib.types.str;
default = [];
};

testFlags = lib.mkOption {
type = haskellLib.types.listOfFilteringNulls lib.types.str;
default = [];
};

setupInstallFlags = lib.mkOption {
type = haskellLib.types.listOfFilteringNulls lib.types.str;
default = [];
};

setupHaddockFlags = lib.mkOption {
type = haskellLib.types.listOfFilteringNulls lib.types.str;
default = [];
};

doExactConfig = lib.mkOption {
type = lib.types.bool;
default = false;
};

doCheck = lib.mkOption {
type = lib.types.bool;
default = true;
};

doCrossCheck = lib.mkOption {
description = "Run doCheck also in cross compilation settings. This can be tricky as the test logic must know how to run the tests on the target.";
type = lib.types.bool;
default = false;
};

doHaddock = lib.mkOption {
description = "Enable building of the Haddock documentation from the annotated Haskell source code.";
type = lib.types.bool;
default = true;
};

doHoogle = lib.mkOption {
description = "Also build a hoogle index.";
type = lib.types.bool;
default = true;
};

doHyperlinkSource = lib.mkOption {
description = "Link documentation to the source code.";
type = lib.types.bool;
default = true;
};

doQuickjump = lib.mkOption {
description = "Generate an index for interactive documentation navigation.";
type = lib.types.bool;
default = true;
};

doCoverage = lib.mkOption {
description = "Enable production of test coverage reports.";
type = lib.types.bool;
default = false;
};

dontPatchELF = lib.mkOption {
description = "If set, the patchelf command is not used to remove unnecessary RPATH entries. Only applies to Linux.";
type = lib.types.bool;
default = true;
};

dontStrip = lib.mkOption {
description = "If set, libraries and executables are not stripped.";
type = lib.types.bool;
default = true;
};

enableDeadCodeElimination = lib.mkOption {
description = "If set, enables split sections for link-time dead-code stripping. Only applies to Linux";
type = lib.types.bool;
default = true;
};

enableStatic = lib.mkOption {
description = "If set, enables building static libraries and executables.";
type = lib.types.bool;
default = true;
};

enableShared = lib.mkOption {
description = "If set, enables building shared libraries.";
type = lib.types.bool;
default = true;
};

configureAllComponents = lib.mkOption {
description = "If set all the components in the package are configured (useful for cabal-doctest).";
type = lib.types.bool;
default = false;
};

shellHook = lib.mkOption {
description = "Hook to run when entering a shell";
type = lib.types.unspecified; # Can be either a string or a function
default = "";
};

enableLibraryProfiling = lib.mkOption {
type = lib.types.bool;
default = false;
};

enableSeparateDataOutput = lib.mkOption {
type = lib.types.bool;
default = true;
};

enableProfiling = lib.mkOption {
type = lib.types.bool;
default = false;
};

profilingDetail = lib.mkOption {
type = lib.types.nullOr haskellLib.types.uniqueStr;
default = "default";
};

keepConfigFiles = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Keep component configFiles in the store in a `configFiles` output";
};

keepGhc = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Keep component wrapped ghc in the store in a `ghc` output";
};

keepSource = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Keep component source in the store in a `source` output";
};

writeHieFiles = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Write component `.hie` files in the store in a `hie` output";
};
};
}
121 changes: 121 additions & 0 deletions 121 modules/component.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{ lib, haskellLib, ... }:

let
inherit (lib) types;
inherit (haskellLib.types) listOfFilteringNulls;

in
{
imports = [
./component-options.nix
./package-options.nix
];

options = {
plugins = lib.mkOption {
type = types.listOf (types.submodule {
options = {
library = lib.mkOption {
type = types.unspecified;
};

moduleName = lib.mkOption {
type = types.str;
};

args = lib.mkOption {
type = types.listOf types.str;
default = [ ];
};
};
});

default = [ ];
};

depends = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

libs = lib.mkOption {
type = listOfFilteringNulls (types.either (types.nullOr types.package) (listOfFilteringNulls types.package));
default = [ ];
};

frameworks = lib.mkOption {
type = listOfFilteringNulls types.package;
default = [ ];
};

pkgconfig = lib.mkOption {
type = types.listOf (listOfFilteringNulls types.package);
default = [ ];
};

build-tools = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

modules = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

asmSources = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

cmmSources = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

cSources = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

cxxSources = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

jsSources = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

hsSourceDirs = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ "." ];
};

includeDirs = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

includes = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

mainPath = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

extraSrcFiles = lib.mkOption {
type = listOfFilteringNulls types.unspecified;
default = [ ];
};

platforms = lib.mkOption {
type = types.nullOr (listOfFilteringNulls types.unspecified);
default = null;
};
};
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.