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

Fix mkFlakeApps and mkFlakePackages after #1993 #2003

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 3 commits into from
Jul 18, 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
13 changes: 6 additions & 7 deletions 13 flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
traceNames = prefix: builtins.mapAttrs (n: v:
if builtins.isAttrs v
then if v ? type && v.type == "derivation"
then __trace (prefix + n) v
then builtins.trace (prefix + n) v
else traceNames (prefix + n + ".") v
else v);

Expand Down Expand Up @@ -103,7 +103,7 @@
# flake outputs so that we can incorporate the args passed
# to the compat layer (e.g. sourcesOverride).
overlays = [ allOverlays.combined ]
++ (if checkMaterialization == true then
++ (if checkMaterialization then
[
(final: prev: {
haskell-nix = prev.haskell-nix // {
Expand Down Expand Up @@ -161,7 +161,7 @@
# Exposed so that buildkite can check that `allow-import-from-derivation=false` works for core of haskell.nix
roots = legacyPackagesUnstable.haskell-nix.roots compiler;

packages = ((self.internal.compat { inherit system; }).hix).apps;
packages = (self.internal.compat { inherit system; }).hix.apps;

allJobs =
let
Expand All @@ -180,15 +180,14 @@
let nixpkgsJobs = allJobs.${nixpkgsVer};
in lib.concatMap (compiler-nix-name:
let ghcJobs = nixpkgsJobs.${compiler-nix-name};
in (
builtins.map (crossPlatform: {
in builtins.map (crossPlatform: {
name = "required-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
value = legacyPackages.releaseTools.aggregate {
name = "haskell.nix-${nixpkgsVer}-${compiler-nix-name}-${crossPlatform}";
meta.description = "All ${nixpkgsVer} ${compiler-nix-name} ${crossPlatform} jobs";
constituents = lib.collect (d: lib.isDerivation d) ghcJobs.${crossPlatform};
constituents = lib.collect lib.isDerivation ghcJobs.${crossPlatform};
};
}) (names ghcJobs))
}) (names ghcJobs)
) (names nixpkgsJobs)
) (names allJobs));

Expand Down
2 changes: 1 addition & 1 deletion 2 hix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ let
echo "Updating $FLAKE/flake.nix and deleting old $FLAKE/flake.lock"
rm $FLAKE/flake.lock
else
echo "Updating $FLAKE/flake.nix"
echo "Updating $FLAKE/flake.nix"
fi
cp $HIX_FLAKE $FLAKE/flake.nix
chmod +w $FLAKE/flake.nix
Expand Down
9 changes: 3 additions & 6 deletions 9 hix/project/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ let
then []
else [{ inherit name; value = commandArgs.${name}; }]
) (builtins.attrNames commandArgs));
defaultArgs = {
nixpkgsPin = "nixpkgs-unstable";
};
importDefaults = src:
if src == null || !(__pathExists src)
if src == null || !(builtins.pathExists src)
then {}
else import src;
userDefaults = importDefaults (commandArgs.userDefaults or null);
Expand Down Expand Up @@ -64,7 +61,7 @@ let
commandArgs'
({config, ...}: {
src =
if __pathExists (toString (src.origSrcSubDir or src) + "/.git")
if builtins.pathExists (toString (src.origSrcSubDir or src) + "/.git")
then config.evalPackages.haskell-nix.haskellLib.cleanGit {
inherit src name;
}
Expand All @@ -73,5 +70,5 @@ let
];
})
];
}).config) project shell;
}).config) project;
in project
76 changes: 44 additions & 32 deletions 76 lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ in {

foldComponents = tys: f: z: conf:
let
comps = conf.components or {};
comps = conf.components or { };
# ensure that comps.library exists and is not null.
libComp = acc: if (comps.library or null) != null then f comps.library acc else acc;
libComp = acc:
if comps ? library then f comps.library acc else acc;
subComps = acc:
lib.foldr
(ty: acc': foldrAttrVals f acc' (comps.${ty} or {}))
(ty: acc': foldrAttrVals f acc' (comps.${ty} or { }))
acc
tys;
in libComp (subComps z);
in
libComp (subComps z);

getAllComponents = foldComponents subComponentTypes (c: acc: [c] ++ acc) [];
getAllComponents = foldComponents subComponentTypes (c: acc: [ c ] ++ acc) [ ];

componentPrefix = {
sublibs = "lib";
Expand Down Expand Up @@ -211,7 +213,7 @@ in {
#
# See docs/user-guide/clean-git.md for details of how to use this
# with `cabalProject`.
cleanGits = { src, gitDirs, name ? null, caller ? "cleanGits" }@args:
cleanGits = { src, gitDirs, name ? null, caller ? "cleanGits" }:
let
# List of filters, one for each git directory.
filters = builtins.map (subDir:
Expand Down Expand Up @@ -424,36 +426,46 @@ in {
}]) (packageNames coverageProject));

# Flake package names that are flat and match the cabal component names.
mkFlakePackages = haskellPackages: builtins.listToAttrs (
lib.concatLists (lib.mapAttrsToList (packageName: package:
builtins.groupBy
(c: c.passthru.identifier.component-id)
((lib.optional (package.components ? library) package.components.library)
++ package.components.sublibs
++ package.components.exes
++ package.components.tests
++ package.components.benchmarks)
) haskellPackages));
mkFlakePackages =
foldrAttrVals
(package: acc:
foldComponents
subComponentTypes
(component: a: a // {
${component.passthru.identifier.component-id} = component;
})
acc
package)
{ };

# Flake package names that are flat and match the cabal component names.
mkFlakeApps = haskellPackages: builtins.listToAttrs (
lib.concatLists (lib.mapAttrsToList (packageName: package:
builtins.groupBy
(c: c.passthru.identifier.component-id)
(package.components.exes
++ package.components.tests
++ package.components.benchmarks)
) haskellPackages));
mkFlakeApps =
foldrAttrVals
(package: acc:
foldComponents
[ "exes" "tests" "benchmarks" ]
(component: a: a // {
${component.passthru.identifier.component-id} = {
type = "app";
program = component.exePath;
};
})
acc
package)
{ };

# Flatten the result of collectChecks or collectChecks' for use in flake `checks`
mkFlakeChecks = allChecks: builtins.listToAttrs (
lib.concatLists (lib.mapAttrsToList (packageName: checks:
# Avoid `recurseForDerivations` issues
lib.optionals (lib.isAttrs checks) (
lib.mapAttrsToList (n: v:
{ name = "${packageName}:test:${n}"; value = v; })
(lib.filterAttrs (_: lib.isDerivation) checks))
) allChecks));
mkFlakeChecks = allChecks:
foldrAttrVals
(package: acc:
foldrAttrVals
(check: a: a // {
${check.passthru.identifier.component-id} = check;
})
acc
package)
{ }
(removeRecurseForDerivations allChecks);

removeRecurseForDerivations = x:
let clean = builtins.removeAttrs x ["recurseForDerivations"];
Expand Down
5 changes: 2 additions & 3 deletions 5 overlays/hix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ final: prev: { haskell-nix = prev.haskell-nix // { hix = {
, ...}@commandArgs:
let
inherit (final) lib;
hixDefaults = { compiler-nix-name = lib.mkDefault "ghc8107"; };
inherit ((lib.evalModules {
modules = [
(import ../modules/project-common.nix)
Expand All @@ -31,7 +30,7 @@ final: prev: { haskell-nix = prev.haskell-nix // { hix = {
else [{ inherit name; value = commandArgs.${name}; }]
) (builtins.attrNames commandArgs));
importDefaults = src:
if src == null || !(__pathExists src)
if src == null || !(builtins.pathExists src)
then {}
else import src;
projectDefaults = importDefaults (toString (src.origSrcSubDir or src) + "/nix/hix.nix");
Expand All @@ -41,7 +40,7 @@ final: prev: { haskell-nix = prev.haskell-nix // { hix = {
commandArgs'
({config, ...}: {
src =
if __pathExists (toString (src.origSrcSubDir or src) + "/.git")
if builtins.pathExists (toString (src.origSrcSubDir or src) + "/.git")
then config.evalPackages.haskell-nix.haskellLib.cleanGit {
inherit src name;
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.