diff --git a/.gitignore b/.gitignore index 750baeb..c372372 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ result result-* + +dist/ +dist-newstyle/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..405dedc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for arion-compose + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/arion-compose.cabal b/arion-compose.cabal new file mode 100644 index 0000000..825b04c --- /dev/null +++ b/arion-compose.cabal @@ -0,0 +1,54 @@ +cabal-version: 2.2 + +name: arion-compose +version: 0.1.0.0 +synopsis: Run docker-compose with help from Nix/NixOS +-- description: +homepage: https://github.com/hercules-ci/arion#readme +-- bug-reports: +license: Apache-2.0 +license-file: LICENSE +author: Robert Hensing +maintainer: robert@hercules-ci.com +-- copyright: +-- category: +extra-source-files: CHANGELOG.md, README.asciidoc +write-ghc-enviroment-files: + never + +common deps + build-depends: base ^>=4.12.0.0 + , aeson + , protolude + + +library + import: deps + -- exposed-modules: + -- other-modules: + -- other-extensions: + build-depends: process + hs-source-dirs: src/haskell/lib + default-language: Haskell2010 + +executable arion + import: deps + main-is: Main.hs + -- other-modules: + -- other-extensions: + build-depends: optparse-applicative + , process + hs-source-dirs: src/haskell/exe + default-language: Haskell2010 + +test-suite arion-unit-tests + import: deps + type: exitcode-stdio-1.0 + main-is: Main.hs + -- other-modules: + -- other-extensions: + build-depends: arion-compose + , hspec + , QuickCheck + hs-source-dirs: src/haskell/test + default-language: Haskell2010 diff --git a/live-unit-tests b/live-unit-tests new file mode 100755 index 0000000..4a2cc6c --- /dev/null +++ b/live-unit-tests @@ -0,0 +1,13 @@ +#!/usr/bin/env nix-shell +#!nix-shell ./shell.nix +#!nix-shell -i bash +set -eux -o pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")" + +ghcid \ + --command 'ghci -isrc/haskell/exe -isrc/haskell/lib -isrc/haskell/test src/haskell/test/TestMain.hs' \ + --test=Main.main \ + --restart=hercules-ci-api.cabal \ + --restart=../stack.yaml \ + ; diff --git a/nix/haskell-overlay.nix b/nix/haskell-overlay.nix new file mode 100644 index 0000000..9de9363 --- /dev/null +++ b/nix/haskell-overlay.nix @@ -0,0 +1,3 @@ +self: super: hself: hsuper: { + arion-compose = hself.callCabal2nix "arion-compose" ./.. {}; +} \ No newline at end of file diff --git a/nix/overlay.nix b/nix/overlay.nix index 13ad5dc..30a6b7a 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -1,5 +1,20 @@ -self: super: { +self: super: +let + inherit (self.arion-project) haskellPkgs; +in +{ arion = super.callPackage ../arion.nix {}; tests = super.callPackage ../tests {}; doc = super.callPackage ../doc {}; + + arion-project = super.recurseIntoAttrs { + haskellPkgs = super.haskellPackages.extend (import ./haskell-overlay.nix self super); + shell = haskellPkgs.shellFor { + packages = p: [p.arion-compose]; + buildInputs = [ + haskellPkgs.cabal-install + haskellPkgs.ghcid + ]; + }; + }; } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..14e3ffe --- /dev/null +++ b/shell.nix @@ -0,0 +1 @@ +(import ./nix {}).arion-project.shell diff --git a/src/haskell/exe/Main.hs b/src/haskell/exe/Main.hs new file mode 100644 index 0000000..65ae4a0 --- /dev/null +++ b/src/haskell/exe/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = putStrLn "Hello, Haskell!" diff --git a/src/haskell/test/Arion/FooSpec.hs b/src/haskell/test/Arion/FooSpec.hs new file mode 100644 index 0000000..d4ea5fd --- /dev/null +++ b/src/haskell/test/Arion/FooSpec.hs @@ -0,0 +1,11 @@ +module Arion.FooSpec + ( spec + ) +where + +import Test.Hspec +import Test.QuickCheck + +spec :: Spec +spec = do + it "foo" $ property True diff --git a/src/haskell/test/Spec.hs b/src/haskell/test/Spec.hs new file mode 100644 index 0000000..73ab5ab --- /dev/null +++ b/src/haskell/test/Spec.hs @@ -0,0 +1,11 @@ +module Spec + ( spec + ) +where + +import Test.Hspec +import qualified Arion.FooSpec + +spec :: Spec +spec = do + describe "Arion.Foo" Arion.FooSpec.spec diff --git a/src/haskell/test/TestMain.hs b/src/haskell/test/TestMain.hs new file mode 100644 index 0000000..746b8d7 --- /dev/null +++ b/src/haskell/test/TestMain.hs @@ -0,0 +1,9 @@ +module Main where + +import Protolude +import Test.Hspec.Runner +import qualified Spec + +main :: IO () +main = hspecWith config Spec.spec + where config = defaultConfig { configColorMode = ColorAlways }