Skip to content

Commit

Permalink
Add tests for the newPkgSet feature
Browse files Browse the repository at this point in the history
  • Loading branch information
cdepillabout committed Feb 9, 2023
1 parent 156180d commit 9b0bc86
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

{...}:

(import ./nixpkgs.nix {}).stacklock2nix-tests
30 changes: 30 additions & 0 deletions test/nixpkgs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

{...}:

let
flake-lock = builtins.fromJSON (builtins.readFile ../my-example-haskell-lib-advanced/flake.lock);

# Use the Nixpkgs that the my-example-haskell-lib-advanced is pinned to.
nixpkgs-src = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${flake-lock.nodes.nixpkgs.locked.rev}.tar.gz";
sha256 = flake-lock.nodes.nixpkgs.locked.narHash;
};

overlays = [
# stacklock2nix overlay
(import ../nix/overlay.nix)

# tests
(final: prev: {
stacklock2nix-tests =
(final.callPackage ./test-new-package-set.nix {}) ++ [
# new tests go here
];
})
];

pkgs = import nixpkgs-src { inherit overlays; };

in

pkgs
43 changes: 43 additions & 0 deletions test/test-new-package-set.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

{ stacklock2nix
, haskell
, cabal-install
, fetchurl
}:

let
hasklib = haskell.lib.compose;

stacklock = stacklock2nix {
stackYaml = ../my-example-haskell-lib-advanced/stack.yaml;
baseHaskellPkgSet = haskell.packages.ghc924;
additionalHaskellPkgSetOverrides = hfinal: hprev: {
# The servant-cassava.cabal file is malformed on GitHub:
# https://github.com/haskell-servant/servant-cassava/pull/29
servant-cassava =
hasklib.overrideCabal
{ editedCabalFile = null; revision = null; }
hprev.servant-cassava;

amazonka = hasklib.dontCheck hprev.amazonka;
amazonka-core = hasklib.dontCheck hprev.amazonka-core;
amazonka-sso = hasklib.dontCheck hprev.amazonka-sso;
amazonka-sts = hasklib.dontCheck hprev.amazonka-sts;
};
cabal2nixArgsOverrides = args: args // {
amazonka-sso = ver: { amazonka-test = null; };
amazonka-sts = ver: { amazonka-test = null; };
};
additionalDevShellNativeBuildInputs = stacklockHaskellPkgSet: [
cabal-install
];
all-cabal-hashes = fetchurl {
name = "all-cabal-hashes";
url = "https://github.com/commercialhaskell/all-cabal-hashes/archive/9ab160f48cb535719783bc43c0fbf33e6d52fa99.tar.gz";
sha256 = "sha256-QC07T3MEm9LIMRpxIq3Pnqul60r7FpAdope6S62sEX8=";
};
};
in
[ stacklock.newPkgSet.my-example-haskell-app
stacklock.newPkgSetDevShell
]

0 comments on commit 9b0bc86

Please sign in to comment.