Skip to content

Commit

Permalink
always clean the source, no matter what (input-output-hk#1403)
Browse files Browse the repository at this point in the history
* always clean the source, no matter what

* update hydra
  • Loading branch information
DavHau authored Mar 18, 2022
1 parent b944c80 commit 1ca9932
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 13 deletions.
90 changes: 90 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; };
nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
flake-utils = { url = "github:numtide/flake-utils"; };
hydra.url = "hydra";
hackage = {
url = "github:input-output-hk/hackage.nix";
flake = false;
Expand Down
22 changes: 10 additions & 12 deletions lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,13 @@ let
ghc = ghc';
subDir' = src.origSubDir or "";
subDir = pkgs.lib.strings.removePrefix "/" subDir';
maybeCleanedSource =
if haskellLib.canCleanSource src
then (haskellLib.cleanSourceWith {
name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files";
src = src.origSrc or src;
filter = path: type: (!(src ? filter) || src.filter path type) && (
type == "directory" ||
pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); })
else src.origSrc or src;

cleanedSource = haskellLib.cleanSourceWith {
name = if name != null then "${name}-root-cabal-files" else "source-root-cabal-files";
src = src.origSrc or src;
filter = path: type: (!(src ? filter) || src.filter path type) && (
type == "directory" ||
pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); };

# Using origSrcSubDir bypasses any cleanSourceWith so that it will work when
# access to the store is restricted. If origSrc was already in the store
Expand Down Expand Up @@ -473,17 +471,17 @@ let
} ''
tmp=$(mktemp -d)
cd $tmp
# if maybeCleanedSource is empty, this means it's a new
# if cleanedSource is empty, this means it's a new
# project where the files haven't been added to the git
# repo yet. We fail early and provide a useful error
# message to prevent headaches (#290).
if [ -z "$(ls -A ${maybeCleanedSource})" ]; then
if [ -z "$(ls -A ${cleanedSource})" ]; then
echo "cleaned source is empty. Did you forget to 'git add -A'?"
${pkgs.lib.optionalString (__length fixedProject.sourceRepos == 0) ''
exit 1
''}
else
cp -r ${maybeCleanedSource}/* .
cp -r ${cleanedSource}/* .
fi
chmod +w -R .
# Decide what to do for each `package.yaml` file.
Expand Down
2 changes: 2 additions & 0 deletions overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let
bootstrap = import ./bootstrap.nix;
ghc = import ./ghc.nix;
ghc-packages = import ./ghc-packages.nix;
hydra = import ./hydra.nix args;
darwin = import ./darwin.nix;
windows = import ./windows.nix;
armv6l-linux = import ./armv6l-linux.nix;
Expand Down Expand Up @@ -56,6 +57,7 @@ let
gobject-introspection
hix
eval-packages
hydra
# Restore nixpkgs haskell and haskellPackages
(_: prev: { inherit (prev.haskell-nix-prev) haskell haskellPackages; })
];
Expand Down
5 changes: 5 additions & 0 deletions overlays/hydra.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ sources, ...}:

final: prev: {
hydra-unstable = sources.hydra.defaultPackage.${prev.system};
}
3 changes: 2 additions & 1 deletion scripts/check-hydra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ writeScript "check-hydra.sh" ''
set -euo pipefail
export PATH="${makeBinPath [ coreutils time gnutar gzip hydra-unstable jq gitMinimal ]}"
export NIX_PATH=
echo '~~~ Evaluating release.nix with --arg ifdLevel '$1
command time --format '%e' -o eval-time.txt \
hydra-eval-jobs \
--option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \
--arg supportedSystems '[ builtins.currentSystem ]' \
--arg ifdLevel $1 \
-I . release.nix > eval.json
-I $(realpath .) release.nix > eval.json
EVAL_EXIT_CODE="$?"
if [ "$EVAL_EXIT_CODE" != 0 ]
then
Expand Down

0 comments on commit 1ca9932

Please sign in to comment.