-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from cdepillabout/support-no-local-pkgs
Make stacklock2nix work even if no local packages are specified
- Loading branch information
Showing
12 changed files
with
571 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Copyright Dennis Gosnell (c) 2022 | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of Dennis Gosnell nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
module Main where | ||
|
||
main :: IO () | ||
main = pure () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
{ stacklock2nix | ||
, haskell | ||
, cabal-install | ||
, fetchFromGitHub | ||
}: | ||
|
||
let | ||
hasklib = haskell.lib.compose; | ||
|
||
stacklock = stacklock2nix { | ||
stackYaml = ./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 = fetchFromGitHub { | ||
owner = "commercialhaskell"; | ||
repo = "all-cabal-hashes"; | ||
rev = "80869091dcb9f932c15fe57e30d4d0730c5f87df"; | ||
sha256 = "sha256-LAD3/5qeJWbzfqkcWccMOq0pHBnSkNnvBjWnlLzWFvQ="; | ||
}; | ||
}; | ||
in | ||
|
||
let | ||
# A list of all the names of the local packages. | ||
localPkgNames = builtins.attrNames (stacklock.stackYamlLocalPkgsOverlay null null); | ||
in | ||
|
||
# The local packages overlay should contain a single local package. | ||
assert builtins.length localPkgNames == 1; | ||
|
||
let | ||
localPkgName = builtins.head localPkgNames; | ||
in | ||
|
||
# The name of the local package should be read correctly from the .cabal file. | ||
assert localPkgName == "my-cool-package-foobar"; | ||
|
||
[ # We should be able to build the local package: | ||
stacklock.pkgSet.my-cool-package-foobar | ||
|
||
# We should also be able to build other packages from stack.yaml. | ||
# Two random packages to check: | ||
stacklock.pkgSet.amazonka-core | ||
stacklock.newPkgSet.lens | ||
|
||
# Also be able to build the devshell: | ||
stacklock.newPkgSetDevShell | ||
] |
29 changes: 29 additions & 0 deletions
29
test/test-default-local-package/my-cool-package-foobar.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
cabal-version: 1.12 | ||
|
||
name: my-cool-package-foobar | ||
version: 0.1.0.0 | ||
description: Please see the README on GitHub at <https://github.com/cdepillabout/stacklock2nix#readme> | ||
homepage: https://github.com/cdepillabout/stacklock2nix#readme | ||
bug-reports: https://github.com/cdepillabout/stacklock2nix/issues | ||
author: Your Name Here | ||
maintainer: you@example.com | ||
copyright: Copyright (c) 2018 You | ||
license: BSD3 | ||
license-file: LICENSE | ||
build-type: Simple | ||
extra-source-files: | ||
README.md | ||
|
||
source-repository head | ||
type: git | ||
location: https://github.com/cdepillabout/stacklock2nix | ||
|
||
executable my-cool-package-foobar | ||
main-is: Main.hs | ||
ghc-options: -threaded -rtsopts -with-rtsopts=-N | ||
build-depends: | ||
base >=4.7 && <5 | ||
, optparse-applicative | ||
, unagi-streams | ||
default-language: Haskell2010 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
resolver: nightly-2022-10-18 | ||
|
||
# This is a test that stacklock2nix works even if the top-level `packages` key | ||
# is not specified. In this case, `stack` defaults to having a single package | ||
# in this same directory. | ||
# packages: ["."] | ||
|
||
extra-deps: | ||
|
||
# example dep from hackage | ||
- "unagi-streams-0.2.7" | ||
|
||
# example git dep | ||
- git: "https://github.com/haskell-servant/servant-cassava" | ||
commit: "f76308b42b9f93a6641c70847cec8ecafbad3abc" | ||
|
||
# example git dep with single subdir | ||
- git: "https://github.com/haskell-servant/servant" | ||
commit: "1fba9dc6048cea6184964032b861b052cd54878c" | ||
subdir: "servant-client" | ||
|
||
# example git dep with multiple subdirs | ||
- git: "https://github.com/haskell-servant/servant" | ||
commit: "1fba9dc6048cea6184964032b861b052cd54878c" | ||
subdirs: | ||
- "servant" | ||
- "servant-server" | ||
|
||
# example of a GitHub dep without subdirs | ||
- github: cdepillabout/pretty-simple | ||
commit: "d8ef1b3c2d913a05515b2d1c4fec0b52d2744434" | ||
|
||
# example of a GitHub dep with multiple subdirs | ||
- github: brendanhay/amazonka | ||
commit: "43e8fb7e6e30e24adef11f66331ae6752642bffd" | ||
subdirs: | ||
- lib/amazonka | ||
- lib/amazonka-core | ||
- lib/services/amazonka-sso | ||
- lib/services/amazonka-sts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# This file was autogenerated by Stack. | ||
# You should not edit this file by hand. | ||
# For more information, please see the documentation at: | ||
# https://docs.haskellstack.org/en/stable/lock_files | ||
|
||
packages: | ||
- completed: | ||
hackage: unagi-streams-0.2.7@sha256:4aa0290e5e92145686ba54ab5a53972c0f9fd22b9e06492d769ae61c8423aa22,1142 | ||
pantry-tree: | ||
sha256: fe3eb224bf3771c039081e6097e9199095354be78770ab1215688f9316f692d6 | ||
size: 329 | ||
original: | ||
hackage: unagi-streams-0.2.7 | ||
- completed: | ||
commit: f76308b42b9f93a6641c70847cec8ecafbad3abc | ||
git: https://github.com/haskell-servant/servant-cassava | ||
name: servant-cassava | ||
pantry-tree: | ||
sha256: 1e040a08512e69847e2c9a9e313927b4a1864408a32ac935819247291d154ea7 | ||
size: 652 | ||
version: 0.10.1 | ||
original: | ||
commit: f76308b42b9f93a6641c70847cec8ecafbad3abc | ||
git: https://github.com/haskell-servant/servant-cassava | ||
- completed: | ||
commit: 1fba9dc6048cea6184964032b861b052cd54878c | ||
git: https://github.com/haskell-servant/servant | ||
name: servant-client | ||
pantry-tree: | ||
sha256: c37445bd27aa2f7234b3c5ef73533b0952b979f005d38ca5ebfc8230e2712f92 | ||
size: 1481 | ||
subdir: servant-client | ||
version: '0.19' | ||
original: | ||
commit: 1fba9dc6048cea6184964032b861b052cd54878c | ||
git: https://github.com/haskell-servant/servant | ||
subdir: servant-client | ||
- completed: | ||
commit: 1fba9dc6048cea6184964032b861b052cd54878c | ||
git: https://github.com/haskell-servant/servant | ||
name: servant | ||
pantry-tree: | ||
sha256: ce0c502681ffbf5cb48f5606e9a9947e4c956b39ed8ce5b1a590dbaeff112dd9 | ||
size: 2949 | ||
subdir: servant | ||
version: '0.19' | ||
original: | ||
commit: 1fba9dc6048cea6184964032b861b052cd54878c | ||
git: https://github.com/haskell-servant/servant | ||
subdir: servant | ||
- completed: | ||
commit: 1fba9dc6048cea6184964032b861b052cd54878c | ||
git: https://github.com/haskell-servant/servant | ||
name: servant-server | ||
pantry-tree: | ||
sha256: 2f0df25ed677c6f08aaf1499eec2c82830aedbbe19564d7356ed77cbd49ceeed | ||
size: 2727 | ||
subdir: servant-server | ||
version: 0.19.1 | ||
original: | ||
commit: 1fba9dc6048cea6184964032b861b052cd54878c | ||
git: https://github.com/haskell-servant/servant | ||
subdir: servant-server | ||
- completed: | ||
name: pretty-simple | ||
pantry-tree: | ||
sha256: da2d314323affae4fa11f523bc2655ed0d5f27fd47f781654396d231673e0a68 | ||
size: 2200 | ||
sha256: aba1659b4c133b00b7a28837bcb413672823d72835bcee0f1594e0ba4e2ea4af | ||
size: 101732 | ||
url: https://github.com/cdepillabout/pretty-simple/archive/d8ef1b3c2d913a05515b2d1c4fec0b52d2744434.tar.gz | ||
version: 4.1.2.0 | ||
original: | ||
url: https://github.com/cdepillabout/pretty-simple/archive/d8ef1b3c2d913a05515b2d1c4fec0b52d2744434.tar.gz | ||
- completed: | ||
name: amazonka | ||
pantry-tree: | ||
sha256: f1ba46f355d47bd1494d01b4eb1002c8efdd666639aa3fd0163581409071b7b8 | ||
size: 1318 | ||
sha256: 3cc2cdb4add25e6ef36c5124301387039b2f71fb7a809732cfce182b830787b1 | ||
size: 30018929 | ||
subdir: lib/amazonka | ||
url: https://github.com/brendanhay/amazonka/archive/43e8fb7e6e30e24adef11f66331ae6752642bffd.tar.gz | ||
version: '2.0' | ||
original: | ||
subdir: lib/amazonka | ||
url: https://github.com/brendanhay/amazonka/archive/43e8fb7e6e30e24adef11f66331ae6752642bffd.tar.gz | ||
- completed: | ||
name: amazonka-core | ||
pantry-tree: | ||
sha256: 8707039e4fb7c575fbcd04906e4f541948ed152534da6d3830b9675badb4c71d | ||
size: 3192 | ||
sha256: 3cc2cdb4add25e6ef36c5124301387039b2f71fb7a809732cfce182b830787b1 | ||
size: 30018929 | ||
subdir: lib/amazonka-core | ||
url: https://github.com/brendanhay/amazonka/archive/43e8fb7e6e30e24adef11f66331ae6752642bffd.tar.gz | ||
version: '2.0' | ||
original: | ||
subdir: lib/amazonka-core | ||
url: https://github.com/brendanhay/amazonka/archive/43e8fb7e6e30e24adef11f66331ae6752642bffd.tar.gz | ||
- completed: | ||
name: amazonka-sso | ||
pantry-tree: | ||
sha256: e9a165eda0567cdf0581d29d8b1e9fe2df543474d7c70590e04ec1047ebe6d48 | ||
size: 1869 | ||
sha256: 3cc2cdb4add25e6ef36c5124301387039b2f71fb7a809732cfce182b830787b1 | ||
size: 30018929 | ||
subdir: lib/services/amazonka-sso | ||
url: https://github.com/brendanhay/amazonka/archive/43e8fb7e6e30e24adef11f66331ae6752642bffd.tar.gz | ||
version: '2.0' | ||
original: | ||
subdir: lib/services/amazonka-sso | ||
url: https://github.com/brendanhay/amazonka/archive/43e8fb7e6e30e24adef11f66331ae6752642bffd.tar.gz | ||
- completed: | ||
name: amazonka-sts | ||
pantry-tree: | ||
sha256: 3a0d4983a363e953e6dc651d1aaa6ca30755a16c01edf63e5104ece7745e3954 | ||
size: 2932 | ||
sha256: 3cc2cdb4add25e6ef36c5124301387039b2f71fb7a809732cfce182b830787b1 | ||
size: 30018929 | ||
subdir: lib/services/amazonka-sts | ||
url: https://github.com/brendanhay/amazonka/archive/43e8fb7e6e30e24adef11f66331ae6752642bffd.tar.gz | ||
version: '2.0' | ||
original: | ||
subdir: lib/services/amazonka-sts | ||
url: https://github.com/brendanhay/amazonka/archive/43e8fb7e6e30e24adef11f66331ae6752642bffd.tar.gz | ||
snapshots: | ||
- completed: | ||
sha256: 895204e9116cba1f32047525ec5bad7423216587706e5df044c4a7c191a5d8cb | ||
size: 644482 | ||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2022/10/18.yaml | ||
original: nightly-2022-10-18 |
Oops, something went wrong.