diff --git a/test/default.nix b/test/default.nix new file mode 100644 index 0000000..e3ea774 --- /dev/null +++ b/test/default.nix @@ -0,0 +1,4 @@ + +{...}: + +(import ./nixpkgs.nix {}).stacklock2nix-tests diff --git a/test/nixpkgs.nix b/test/nixpkgs.nix new file mode 100644 index 0000000..8ef4b6a --- /dev/null +++ b/test/nixpkgs.nix @@ -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 diff --git a/test/test-new-package-set.nix b/test/test-new-package-set.nix new file mode 100644 index 0000000..be9ffb2 --- /dev/null +++ b/test/test-new-package-set.nix @@ -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 +]