diff --git a/.circleci/config.yml b/.circleci/config.yml index 06704f9..fbf3d05 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,8 +12,8 @@ aliases: &build - checkout - run: - name: create a fake /nix - command: sudo mkdir -m 0755 /nix && sudo chown circleci /nix + name: create a fake /nix, enable single-user install of nix as user circleci + command: sudo mkdir -m 0777 /nix && sudo chown -R circleci /nix # Restore the nix installation to its state after the previous test run. # This should prevent unnecessary rebuilds of dependencies without impacting @@ -31,17 +31,17 @@ aliases: &build name: install nix command: | [[ -d ~/.nix-defexpr ]] || - curl https://nixos.org/nix/install | sh + curl https://nixos.org/releases/nix/nix-2.2.1/install | sh - run: name: install nix dependencies used in the test script itself command: | nix-env -i cabal2nix - nix-env -i nix-prefetch-git + nix-env -i nix-prefetch-scripts - run: - name: run the tests (temporarily - just build to reset the cache) - command: nix-build --show-trace build.nix + name: run the tests + command: nix-shell --run 'cabal new-test haskell-overridez-tests' # Save /nix and the nix user folders to the cache. diff --git a/.gitignore b/.gitignore index 69e79fe..05aae81 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # haskell development -result +result* .ghc* dist dist-newstyle diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e795787 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: nix +nix: 2.2.1 +script: nix-shell --run 'cabal new-test haskell-overridez-tests' diff --git a/build.nix b/build.nix index 9455420..4271abc 100644 --- a/build.nix +++ b/build.nix @@ -28,4 +28,5 @@ in pkgsMake pkgsMakeArgs ({ call, lib, ... }: rec { haskell-overridez-exe = call.haskell.cabal2nix.app ./.; haskell-overridez = call.package ./nix/wrapper; + haskell-overridez-tests = call.haskell.cabal2nix.lib ./haskell-overridez-tests; }) diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..38e4736 --- /dev/null +++ b/cabal.project @@ -0,0 +1,3 @@ +packages: + ./ + ./haskell-overridez-tests diff --git a/fixtures/gobanme-no-yagai-purojekuto/.gitignore b/fixtures/gobanme-no-yagai-purojekuto/.gitignore deleted file mode 100644 index 81259c4..0000000 --- a/fixtures/gobanme-no-yagai-purojekuto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nix diff --git a/fixtures/gobanme-no-yagai-purojekuto/DESC b/fixtures/gobanme-no-yagai-purojekuto/DESC deleted file mode 100644 index 81b768f..0000000 --- a/fixtures/gobanme-no-yagai-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -create an overlay from config fetched from a subpath of a github repository diff --git a/fixtures/gobanme-no-yagai-purojekuto/Main.hs b/fixtures/gobanme-no-yagai-purojekuto/Main.hs deleted file mode 100644 index e335da6..0000000 --- a/fixtures/gobanme-no-yagai-purojekuto/Main.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Main where - -import Turtle - -main :: IO () -main = echo "Hello, world!" diff --git a/fixtures/gobanme-no-yagai-purojekuto/default.nix b/fixtures/gobanme-no-yagai-purojekuto/default.nix deleted file mode 100644 index 00dcfa5..0000000 --- a/fixtures/gobanme-no-yagai-purojekuto/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -let - overridez = import ./nix/haskell-overridez.nix; - githubKara = overridez.allIn ./nix/github.com/adetokunbo/example-fetched-haskell-overridez/subdir-root/a-subdir; - overlays = - let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { - foldl = null; - managed = null; - optparse-applicative = null; - turtle = null; - gobanme-no-yagai-purojekuto = haskellPackagesNew.callPackage ./nix/gobanme-no-yagai-purojekuto.nix {}; - }; - in [ - (newPkgs: oldPkgs: - let - inherit (oldPkgs.lib) composeExtensions fold; - composeExtensionsList = fold composeExtensions (_: _: {}); - in { - haskellPackages = oldPkgs.haskellPackages.override { - overrides = composeExtensionsList [dropTestPkgs (overridez.combineAllIn ./nix [githubKara])]; - }; - }) - ]; - pkgs = import { inherit overlays; }; -in - { gobanme-no-yagai-purojekuto = pkgs.haskellPackages.gobanme-no-yagai-purojekuto; - } diff --git a/fixtures/gobanme-no-yagai-purojekuto/gobanme-no-yagai-purojekuto.cabal b/fixtures/gobanme-no-yagai-purojekuto/gobanme-no-yagai-purojekuto.cabal deleted file mode 100644 index 86fb3bc..0000000 --- a/fixtures/gobanme-no-yagai-purojekuto/gobanme-no-yagai-purojekuto.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: gobanme-no-yagai-purojekuto -version: 1.0.0 -license: BSD3 -license-file: LICENSE -cabal-version: >= 1.18 -build-type: Simple - -executable gobanme-no-yagai-purojekuto - build-depends: base < 5, foldl, text, turtle - main-is: Main.hs - default-language: Haskell2010 diff --git a/fixtures/gobanme-no-yagai-purojekuto/setup_test.sh b/fixtures/gobanme-no-yagai-purojekuto/setup_test.sh deleted file mode 100755 index 9a4f0e4..0000000 --- a/fixtures/gobanme-no-yagai-purojekuto/setup_test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -euo pipefail - -setup_test() { - local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") - pushd $this_dir > /dev/null - - $HOZ_TEST_CMD fetch --subpath subdir-root/a-subdir https://github.com/adetokunbo/example-fetched-haskell-overridez - - popd > /dev/null -} - -setup_test diff --git a/fixtures/hachibanme-no-purojekuto/.gitignore b/fixtures/hachibanme-no-purojekuto/.gitignore deleted file mode 100644 index 81259c4..0000000 --- a/fixtures/hachibanme-no-purojekuto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nix diff --git a/fixtures/hachibanme-no-purojekuto/DESC b/fixtures/hachibanme-no-purojekuto/DESC deleted file mode 100644 index 09cd83a..0000000 --- a/fixtures/hachibanme-no-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -create an overlay from nix-exprs created by cabal2nix with github https uris saved in a specific directory diff --git a/fixtures/hachibanme-no-purojekuto/Main.hs b/fixtures/hachibanme-no-purojekuto/Main.hs deleted file mode 100644 index e335da6..0000000 --- a/fixtures/hachibanme-no-purojekuto/Main.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Main where - -import Turtle - -main :: IO () -main = echo "Hello, world!" diff --git a/fixtures/hachibanme-no-purojekuto/hachibanme-no-purojekuto.cabal b/fixtures/hachibanme-no-purojekuto/hachibanme-no-purojekuto.cabal deleted file mode 100644 index 2c23845..0000000 --- a/fixtures/hachibanme-no-purojekuto/hachibanme-no-purojekuto.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: hachibanme-no-purojekuto -version: 1.0.0 -license: BSD3 -license-file: LICENSE -cabal-version: >= 1.18 -build-type: Simple - -executable hachibanme-no-purojekuto - build-depends: base < 5, foldl, text, turtle - main-is: Main.hs - default-language: Haskell2010 diff --git a/fixtures/hachibanme-no-purojekuto/setup_test.sh b/fixtures/hachibanme-no-purojekuto/setup_test.sh deleted file mode 100755 index f4939d5..0000000 --- a/fixtures/hachibanme-no-purojekuto/setup_test.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -set -euo pipefail - -setup_test() { - local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") - pushd $this_dir > /dev/null - local cwd=$(pwd) - local test_name="${cwd##*/}" - - # Make a directory under the tmp root in which to save the output - local dst_dir="${HOZ_TMP_DIR}/dst/${test_name}" - mkdir -p $dst_dir - - # Set up the configuration - $HOZ_TEST_CMD --flag-override DontCheck -o $dst_dir https://github.com/pcapriotti/optparse-applicative - $HOZ_TEST_CMD --flag-override DoJailbreak -o $dst_dir https://github.com/Gabriel439/Haskell-Turtle-Library - $HOZ_TEST_CMD --flag-override DoJailbreak -o $dst_dir https://github.com/Gabriel439/Haskell-Foldl-Library - $HOZ_TEST_CMD --flag-override DoJailbreak -o $dst_dir https://github.com/Gabriel439/Haskell-Managed-Library - - (cat < ./nix/indirect_import.nix - - popd > /dev/null -} - -setup_test diff --git a/fixtures/ichibanme-no-yagai-purojekuto/.gitignore b/fixtures/ichibanme-no-yagai-purojekuto/.gitignore deleted file mode 100644 index 81259c4..0000000 --- a/fixtures/ichibanme-no-yagai-purojekuto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nix diff --git a/fixtures/ichibanme-no-yagai-purojekuto/DESC b/fixtures/ichibanme-no-yagai-purojekuto/DESC deleted file mode 100644 index 2f9a765..0000000 --- a/fixtures/ichibanme-no-yagai-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -create an overlay from config fetched from a github repository diff --git a/fixtures/ichibanme-no-yagai-purojekuto/LICENSE b/fixtures/ichibanme-no-yagai-purojekuto/LICENSE deleted file mode 100644 index f1036a4..0000000 --- a/fixtures/ichibanme-no-yagai-purojekuto/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) 2018, Timothy Emiola - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. 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. - -3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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. diff --git a/fixtures/ichibanme-no-yagai-purojekuto/Main.hs b/fixtures/ichibanme-no-yagai-purojekuto/Main.hs deleted file mode 100644 index e335da6..0000000 --- a/fixtures/ichibanme-no-yagai-purojekuto/Main.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Main where - -import Turtle - -main :: IO () -main = echo "Hello, world!" diff --git a/fixtures/ichibanme-no-yagai-purojekuto/default.nix b/fixtures/ichibanme-no-yagai-purojekuto/default.nix deleted file mode 100644 index f51147d..0000000 --- a/fixtures/ichibanme-no-yagai-purojekuto/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -let - overridez = import ./nix/haskell-overridez.nix; - githubKara = overridez.allIn ./nix/github.com/adetokunbo/example-fetched-haskell-overridez; - overlays = - let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { - foldl = null; - managed = null; - optparse-applicative = null; - turtle = null; - ichibanme-no-yagai-purojekuto = haskellPackagesNew.callPackage ./nix/ichibanme-no-yagai-purojekuto.nix {}; - }; - in [ - (newPkgs: oldPkgs: - let - inherit (oldPkgs.lib) composeExtensions fold; - composeExtensionsList = fold composeExtensions (_: _: {}); - in { - haskellPackages = oldPkgs.haskellPackages.override { - overrides = composeExtensionsList [dropTestPkgs (overridez.combineAllIn ./nix [githubKara])]; - }; - }) - ]; - pkgs = import { inherit overlays; }; -in - { ichibanme-no-yagai-purojekuto = pkgs.haskellPackages.ichibanme-no-yagai-purojekuto; - } diff --git a/fixtures/ichibanme-no-yagai-purojekuto/ichibanme-no-yagai-purojekuto.cabal b/fixtures/ichibanme-no-yagai-purojekuto/ichibanme-no-yagai-purojekuto.cabal deleted file mode 100644 index b6cc8e8..0000000 --- a/fixtures/ichibanme-no-yagai-purojekuto/ichibanme-no-yagai-purojekuto.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: ichibanme-no-yagai-purojekuto -version: 1.0.0 -license: BSD3 -license-file: LICENSE -cabal-version: >= 1.18 -build-type: Simple - -executable ichibanme-no-yagai-purojekuto - build-depends: base < 5, foldl, text, turtle - main-is: Main.hs - default-language: Haskell2010 diff --git a/fixtures/ichibanme-no-yagai-purojekuto/setup_test.sh b/fixtures/ichibanme-no-yagai-purojekuto/setup_test.sh deleted file mode 100755 index 42fec57..0000000 --- a/fixtures/ichibanme-no-yagai-purojekuto/setup_test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -euo pipefail - -setup_test() { - local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") - pushd $this_dir > /dev/null - - $HOZ_TEST_CMD fetch https://github.com/adetokunbo/example-fetched-haskell-overridez - - popd > /dev/null -} - -setup_test diff --git a/fixtures/kyuubanme-no-purojekuto/.gitignore b/fixtures/kyuubanme-no-purojekuto/.gitignore deleted file mode 100644 index 81259c4..0000000 --- a/fixtures/kyuubanme-no-purojekuto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nix diff --git a/fixtures/kyuubanme-no-purojekuto/DESC b/fixtures/kyuubanme-no-purojekuto/DESC deleted file mode 100644 index bd7ac54..0000000 --- a/fixtures/kyuubanme-no-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -create an overlay from nix-exprs created by cabal2nix on a subdirectory of a github https repository diff --git a/fixtures/kyuubanme-no-purojekuto/LICENSE b/fixtures/kyuubanme-no-purojekuto/LICENSE deleted file mode 100644 index f1036a4..0000000 --- a/fixtures/kyuubanme-no-purojekuto/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) 2018, Timothy Emiola - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. 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. - -3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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. diff --git a/fixtures/kyuubanme-no-purojekuto/Main.hs b/fixtures/kyuubanme-no-purojekuto/Main.hs deleted file mode 100644 index 9efa0f2..0000000 --- a/fixtures/kyuubanme-no-purojekuto/Main.hs +++ /dev/null @@ -1,22 +0,0 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE StandaloneDeriving #-} - -module Main where - -import Control.Monad.Log -import Data.Text.Prettyprint.Doc (Doc) -import System.IO (stdout) - -main :: IO () -main = - withFDHandler defaultBatchingOptions stdout 0.4 80 $ \logToStdout -> - runLoggingT testApp (logToStdout . renderWithSeverity id) - - -testApp :: MonadLog (WithSeverity (Doc ann)) m => m () -testApp = do - logMessage (WithSeverity Informational "Don't mind me") - logMessage (WithSeverity Error "But do mind me!") diff --git a/fixtures/kyuubanme-no-purojekuto/setup_test.sh b/fixtures/kyuubanme-no-purojekuto/setup_test.sh deleted file mode 100755 index e99580a..0000000 --- a/fixtures/kyuubanme-no-purojekuto/setup_test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -euo pipefail - -setup_test() { - local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") - pushd $this_dir > /dev/null - - $HOZ_TEST_CMD https://github.com/jship/logging-effect-extra -- --subpath logging-effect-extra-file - - popd > /dev/null -} - -setup_test diff --git a/fixtures/nanabanme-no-purojekuto/.gitignore b/fixtures/nanabanme-no-purojekuto/.gitignore deleted file mode 100644 index 81259c4..0000000 --- a/fixtures/nanabanme-no-purojekuto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nix diff --git a/fixtures/nanabanme-no-purojekuto/DESC b/fixtures/nanabanme-no-purojekuto/DESC deleted file mode 100644 index ca7ee0b..0000000 --- a/fixtures/nanabanme-no-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -cannot create an overlay when dependencies are removed as a control diff --git a/fixtures/nanabanme-no-purojekuto/LICENSE b/fixtures/nanabanme-no-purojekuto/LICENSE deleted file mode 100644 index f1036a4..0000000 --- a/fixtures/nanabanme-no-purojekuto/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) 2018, Timothy Emiola - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. 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. - -3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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. diff --git a/fixtures/nanabanme-no-purojekuto/Main.hs b/fixtures/nanabanme-no-purojekuto/Main.hs deleted file mode 100644 index e335da6..0000000 --- a/fixtures/nanabanme-no-purojekuto/Main.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Main where - -import Turtle - -main :: IO () -main = echo "Hello, world!" diff --git a/fixtures/nanabanme-no-purojekuto/nanabanme-no-purojekuto.cabal b/fixtures/nanabanme-no-purojekuto/nanabanme-no-purojekuto.cabal deleted file mode 100644 index e51ce0b..0000000 --- a/fixtures/nanabanme-no-purojekuto/nanabanme-no-purojekuto.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: nanabanme-no-purojekuto -version: 1.0.0 -license: BSD3 -license-file: LICENSE -cabal-version: >= 1.18 -build-type: Simple - -executable nanabanme-no-purojekuto - build-depends: base < 5, foldl, text, turtle - main-is: Main.hs - default-language: Haskell2010 diff --git a/fixtures/nanabanme-no-purojekuto/setup_test.sh b/fixtures/nanabanme-no-purojekuto/setup_test.sh deleted file mode 100755 index eb5ccf2..0000000 --- a/fixtures/nanabanme-no-purojekuto/setup_test.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -euo pipefail - -setup_test() { - local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") - pushd $this_dir > /dev/null - - $HOZ_TEST_CMD --flag-override DontCheck cabal://optparse-applicative-0.14.2.0 - $HOZ_TEST_CMD --flag-override DoJailbreak cabal://turtle-1.5.12 - $HOZ_TEST_CMD --flag-override DoJailbreak cabal://foldl-1.4.5 - $HOZ_TEST_CMD --flag-override DoJailbreak cabal://managed-1.0.6 - - popd > /dev/null -} - -setup_test diff --git a/fixtures/nanabanme-no-purojekuto/test.sh b/fixtures/nanabanme-no-purojekuto/test.sh deleted file mode 100644 index 4922603..0000000 --- a/fixtures/nanabanme-no-purojekuto/test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -test() { - nix-build --no-out-link || return 0 - test_desc="$(cat DESC)" - echo - echo "FAILED: '$test_desc' in $(pwd)" - echo - return 1 -} - -test diff --git a/fixtures/nibanme-no-yagai-purojekuto/DESC b/fixtures/nibanme-no-yagai-purojekuto/DESC deleted file mode 100644 index d1bbccd..0000000 --- a/fixtures/nibanme-no-yagai-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -cannot fetch config files from an invalid repository diff --git a/fixtures/nibanme-no-yagai-purojekuto/nibanme-no-yagi-purojekuto.cabal b/fixtures/nibanme-no-yagai-purojekuto/nibanme-no-yagi-purojekuto.cabal deleted file mode 100644 index 3d2c29d..0000000 --- a/fixtures/nibanme-no-yagai-purojekuto/nibanme-no-yagi-purojekuto.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: nibanme-no-yagai-purojekuto -version: 1.0.0 -license: BSD3 -license-file: LICENSE -cabal-version: >= 1.18 -build-type: Simple - -executable nibanme-no-yagai-purojekuto - build-depends: base < 5, foldl, text, turtle - main-is: Main.hs - default-language: Haskell2010 diff --git a/fixtures/nibanme-no-yagai-purojekuto/setup_test.sh b/fixtures/nibanme-no-yagai-purojekuto/setup_test.sh deleted file mode 100755 index 9588f56..0000000 --- a/fixtures/nibanme-no-yagai-purojekuto/setup_test.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -euo pipefail - -setup_test() { - echo "skipped setup" -} - -setup_test diff --git a/fixtures/nibanme-no-yagai-purojekuto/test.sh b/fixtures/nibanme-no-yagai-purojekuto/test.sh deleted file mode 100755 index 66fe451..0000000 --- a/fixtures/nibanme-no-yagai-purojekuto/test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -test() { - local invalid_fetch=https://github.com/adetokunbo/automine - $HOZ_TEST_CMD fetch $invalid_fetch || return 0 - test_desc="$(cat DESC)" - echo - echo "FAILED: '$test_desc'" - echo - return 1 -} - -test diff --git a/fixtures/rokubanme-no-purojekuto/.gitignore b/fixtures/rokubanme-no-purojekuto/.gitignore deleted file mode 100644 index 81259c4..0000000 --- a/fixtures/rokubanme-no-purojekuto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nix diff --git a/fixtures/rokubanme-no-purojekuto/DESC b/fixtures/rokubanme-no-purojekuto/DESC deleted file mode 100644 index 8a1f29d..0000000 --- a/fixtures/rokubanme-no-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -create an overlay from git json created by nix-prefetch-git diff --git a/fixtures/rokubanme-no-purojekuto/LICENSE b/fixtures/rokubanme-no-purojekuto/LICENSE deleted file mode 100644 index f1036a4..0000000 --- a/fixtures/rokubanme-no-purojekuto/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) 2018, Timothy Emiola - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. 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. - -3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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. diff --git a/fixtures/rokubanme-no-purojekuto/Main.hs b/fixtures/rokubanme-no-purojekuto/Main.hs deleted file mode 100644 index e335da6..0000000 --- a/fixtures/rokubanme-no-purojekuto/Main.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Main where - -import Turtle - -main :: IO () -main = echo "Hello, world!" diff --git a/fixtures/rokubanme-no-purojekuto/default.nix b/fixtures/rokubanme-no-purojekuto/default.nix deleted file mode 100644 index a4e9d37..0000000 --- a/fixtures/rokubanme-no-purojekuto/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -let - overridez = import ./nix/haskell-overridez.nix; - overlays = - let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { - foldl = null; - managed = null; - optparse-applicative = null; - turtle = null; - rokubanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/rokubanme-no-purojekuto.nix {}; - }; - in [ - (newPkgs: oldPkgs: - let - inherit (oldPkgs.lib) composeExtensions fold; - composeExtensionsList = fold composeExtensions (_: _: {}); - in { - haskellPackages = oldPkgs.haskellPackages.override { - overrides = composeExtensionsList [dropTestPkgs (overridez.allIn ./nix)]; - }; - }) - ]; - pkgs = import { inherit overlays; }; -in - { rokubanme-no-purojekuto = pkgs.haskellPackages.rokubanme-no-purojekuto; - } diff --git a/fixtures/rokubanme-no-purojekuto/rokubanme-no-purojekuto.cabal b/fixtures/rokubanme-no-purojekuto/rokubanme-no-purojekuto.cabal deleted file mode 100644 index 59fc516..0000000 --- a/fixtures/rokubanme-no-purojekuto/rokubanme-no-purojekuto.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: rokubanme-no-purojekuto -version: 1.0.0 -license: BSD3 -license-file: LICENSE -cabal-version: >= 1.18 -build-type: Simple - -executable rokubanme-no-purojekuto - build-depends: base < 5, foldl, text, turtle - main-is: Main.hs - default-language: Haskell2010 diff --git a/fixtures/rokubanme-no-purojekuto/setup_test.sh b/fixtures/rokubanme-no-purojekuto/setup_test.sh deleted file mode 100755 index ebff6d7..0000000 --- a/fixtures/rokubanme-no-purojekuto/setup_test.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -set -euo pipefail - -setup_test() { - local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") - pushd $this_dir > /dev/null - - # Using -g with foldl or optparse-applicative makes cabal2nix infinitely - # recurse when converting the json to nix-expr - $HOZ_TEST_CMD --flag-override DontCheck https://github.com/pcapriotti/optparse-applicative - $HOZ_TEST_CMD --flag-override DontCheck https://github.com/Gabriel439/Haskell-Foldl-Library - - $HOZ_TEST_CMD --flag-override DoJailbreak -g Gabriel439/Haskell-Turtle-Library - $HOZ_TEST_CMD --flag-override DoJailbreak -g Gabriel439/Haskell-Managed-Library - - popd > /dev/null -} - -setup_test diff --git a/fixtures/sanbanme-no-yagai-purojekuto/.gitignore b/fixtures/sanbanme-no-yagai-purojekuto/.gitignore deleted file mode 100644 index 81259c4..0000000 --- a/fixtures/sanbanme-no-yagai-purojekuto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nix diff --git a/fixtures/sanbanme-no-yagai-purojekuto/DESC b/fixtures/sanbanme-no-yagai-purojekuto/DESC deleted file mode 100644 index 78ce7ad..0000000 --- a/fixtures/sanbanme-no-yagai-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -create an overlay from config fetched from a local git repository diff --git a/fixtures/sanbanme-no-yagai-purojekuto/LICENSE b/fixtures/sanbanme-no-yagai-purojekuto/LICENSE deleted file mode 100644 index f1036a4..0000000 --- a/fixtures/sanbanme-no-yagai-purojekuto/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) 2018, Timothy Emiola - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. 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. - -3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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. diff --git a/fixtures/sanbanme-no-yagai-purojekuto/Main.hs b/fixtures/sanbanme-no-yagai-purojekuto/Main.hs deleted file mode 100644 index e335da6..0000000 --- a/fixtures/sanbanme-no-yagai-purojekuto/Main.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Main where - -import Turtle - -main :: IO () -main = echo "Hello, world!" diff --git a/fixtures/sanbanme-no-yagai-purojekuto/default.nix b/fixtures/sanbanme-no-yagai-purojekuto/default.nix deleted file mode 100644 index 6c21a5c..0000000 --- a/fixtures/sanbanme-no-yagai-purojekuto/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -let - overridez = import ./nix/haskell-overridez.nix; - localhostKara = overridez.allIn ./nix/localhost/sanbanme-no-yagai-purojekuto; - overlays = - let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { - foldl = null; - managed = null; - optparse-applicative = null; - turtle = null; - sanbanme-no-yagai-purojekuto = haskellPackagesNew.callPackage ./nix/sanbanme-no-yagai-purojekuto.nix {}; - }; - in [ - (newPkgs: oldPkgs: - let - inherit (oldPkgs.lib) composeExtensions fold; - composeExtensionsList = fold composeExtensions (_: _: {}); - in { - haskellPackages = oldPkgs.haskellPackages.override { - overrides = composeExtensionsList [dropTestPkgs (overridez.combineAllIn ./nix [localhostKara])]; - }; - }) - ]; - pkgs = import { inherit overlays; }; -in - { sanbanme-no-yagai-purojekuto = pkgs.haskellPackages.sanbanme-no-yagai-purojekuto; - } diff --git a/fixtures/sanbanme-no-yagai-purojekuto/sanbanme-no-yagai-purojekuto.cabal b/fixtures/sanbanme-no-yagai-purojekuto/sanbanme-no-yagai-purojekuto.cabal deleted file mode 100644 index 4e03d3c..0000000 --- a/fixtures/sanbanme-no-yagai-purojekuto/sanbanme-no-yagai-purojekuto.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: sanbanme-no-yagai-purojekuto -version: 1.0.0 -license: BSD3 -license-file: LICENSE -cabal-version: >= 1.18 -build-type: Simple - -executable sanbanme-no-yagai-purojekuto - build-depends: base < 5, foldl, text, turtle - main-is: Main.hs - default-language: Haskell2010 diff --git a/fixtures/sanbanme-no-yagai-purojekuto/setup_test.sh b/fixtures/sanbanme-no-yagai-purojekuto/setup_test.sh deleted file mode 100755 index 5ad6003..0000000 --- a/fixtures/sanbanme-no-yagai-purojekuto/setup_test.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -euo pipefail -setup_test() { - local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") - pushd $this_dir > /dev/null - local cwd=$(pwd) - local out_dir="${HOZ_TMP_DIR}/${cwd##*/}" - mkdir -p $out_dir - - # fetch a recent version of the github example, save it locally, and use - # that as a local git repo (needs all the flags belows; plus the revision and hash) - nix-prefetch-git --quiet \ - --out $out_dir \ - --builder \ - --leave-dotGit \ - https://github.com/adetokunbo/example-fetched-haskell-overridez \ - e1dc13ae7dcb3a4c4b7f426a94ecf523532ea574 \ - 0sapkc9mpk95dlq6n87z8xa8w4r0cnxxpnyp971m5phjpbn83c7q - ls -l $out_dir - - $HOZ_TEST_CMD fetch "file://${out_dir}" - popd > /dev/null -} - -setup_test diff --git a/fixtures/yonbanme-no-purojekuto/.gitignore b/fixtures/yonbanme-no-purojekuto/.gitignore deleted file mode 100644 index 81259c4..0000000 --- a/fixtures/yonbanme-no-purojekuto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nix diff --git a/fixtures/yonbanme-no-purojekuto/DESC b/fixtures/yonbanme-no-purojekuto/DESC deleted file mode 100644 index a9a3966..0000000 --- a/fixtures/yonbanme-no-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -create an overlay from nix-exprs created by cabal2nix with cabal:// uris diff --git a/fixtures/yonbanme-no-purojekuto/LICENSE b/fixtures/yonbanme-no-purojekuto/LICENSE deleted file mode 100644 index f1036a4..0000000 --- a/fixtures/yonbanme-no-purojekuto/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) 2018, Timothy Emiola - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. 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. - -3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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. diff --git a/fixtures/yonbanme-no-purojekuto/Main.hs b/fixtures/yonbanme-no-purojekuto/Main.hs deleted file mode 100644 index e335da6..0000000 --- a/fixtures/yonbanme-no-purojekuto/Main.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Main where - -import Turtle - -main :: IO () -main = echo "Hello, world!" diff --git a/fixtures/yonbanme-no-purojekuto/default.nix b/fixtures/yonbanme-no-purojekuto/default.nix deleted file mode 100644 index c675692..0000000 --- a/fixtures/yonbanme-no-purojekuto/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -let - overridez = import ./nix/haskell-overridez.nix; - overlays = - let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { - foldl = null; - managed = null; - optparse-applicative = null; - turtle = null; - yonbanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/yonbanme-no-purojekuto.nix {}; - }; - in [ - (newPkgs: oldPkgs: - let - inherit (oldPkgs.lib) composeExtensions fold; - composeExtensionsList = fold composeExtensions (_: _: {}); - in { - haskellPackages = oldPkgs.haskellPackages.override { - overrides = composeExtensionsList [dropTestPkgs (overridez.allIn ./nix)]; - }; - }) - ]; - pkgs = import { inherit overlays; }; -in - { yonbanme-no-purojekuto = pkgs.haskellPackages.yonbanme-no-purojekuto; - } diff --git a/fixtures/yonbanme-no-purojekuto/setup_test.sh b/fixtures/yonbanme-no-purojekuto/setup_test.sh deleted file mode 100755 index eb5ccf2..0000000 --- a/fixtures/yonbanme-no-purojekuto/setup_test.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -euo pipefail - -setup_test() { - local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") - pushd $this_dir > /dev/null - - $HOZ_TEST_CMD --flag-override DontCheck cabal://optparse-applicative-0.14.2.0 - $HOZ_TEST_CMD --flag-override DoJailbreak cabal://turtle-1.5.12 - $HOZ_TEST_CMD --flag-override DoJailbreak cabal://foldl-1.4.5 - $HOZ_TEST_CMD --flag-override DoJailbreak cabal://managed-1.0.6 - - popd > /dev/null -} - -setup_test diff --git a/fixtures/yonbanme-no-purojekuto/yonbanme-no-purojekuto.cabal b/fixtures/yonbanme-no-purojekuto/yonbanme-no-purojekuto.cabal deleted file mode 100644 index 5f53ab7..0000000 --- a/fixtures/yonbanme-no-purojekuto/yonbanme-no-purojekuto.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: yonbanme-no-purojekuto -version: 1.0.0 -license: BSD3 -license-file: LICENSE -cabal-version: >= 1.18 -build-type: Simple - -executable yonbanme-no-purojekuto - build-depends: base < 5, foldl, text, turtle - main-is: Main.hs - default-language: Haskell2010 diff --git a/fixtures/yonbanme-no-yagai-purojekuto/.gitignore b/fixtures/yonbanme-no-yagai-purojekuto/.gitignore deleted file mode 100644 index 81259c4..0000000 --- a/fixtures/yonbanme-no-yagai-purojekuto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nix diff --git a/fixtures/yonbanme-no-yagai-purojekuto/DESC b/fixtures/yonbanme-no-yagai-purojekuto/DESC deleted file mode 100644 index 5de79a4..0000000 --- a/fixtures/yonbanme-no-yagai-purojekuto/DESC +++ /dev/null @@ -1 +0,0 @@ -create an overlay from config fetched from a local git repository in a specific directory diff --git a/fixtures/yonbanme-no-yagai-purojekuto/LICENSE b/fixtures/yonbanme-no-yagai-purojekuto/LICENSE deleted file mode 100644 index f1036a4..0000000 --- a/fixtures/yonbanme-no-yagai-purojekuto/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) 2018, Timothy Emiola - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. 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. - -3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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. diff --git a/fixtures/yonbanme-no-yagai-purojekuto/Main.hs b/fixtures/yonbanme-no-yagai-purojekuto/Main.hs deleted file mode 100644 index e335da6..0000000 --- a/fixtures/yonbanme-no-yagai-purojekuto/Main.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Main where - -import Turtle - -main :: IO () -main = echo "Hello, world!" diff --git a/fixtures/yonbanme-no-yagai-purojekuto/default.nix b/fixtures/yonbanme-no-yagai-purojekuto/default.nix deleted file mode 100644 index 52947a5..0000000 --- a/fixtures/yonbanme-no-yagai-purojekuto/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -let - overridez = import ./nix/haskell-overridez.nix; - localhostKara = import ./nix/indirect_import.nix; - overlays = - let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { - foldl = null; - managed = null; - optparse-applicative = null; - turtle = null; - yonbanme-no-yagai-purojekuto = haskellPackagesNew.callPackage ./nix/yonbanme-no-yagai-purojekuto.nix {}; - }; - in [ - (newPkgs: oldPkgs: - let - inherit (oldPkgs.lib) composeExtensions fold; - composeExtensionsList = fold composeExtensions (_: _: {}); - in { - haskellPackages = oldPkgs.haskellPackages.override { - overrides = composeExtensionsList [dropTestPkgs (overridez.combineAllIn ./nix [localhostKara])]; - }; - }) - ]; - pkgs = import { inherit overlays; }; -in - { yonbanme-no-yagai-purojekuto = pkgs.haskellPackages.yonbanme-no-yagai-purojekuto; - } diff --git a/fixtures/yonbanme-no-yagai-purojekuto/setup_test.sh b/fixtures/yonbanme-no-yagai-purojekuto/setup_test.sh deleted file mode 100755 index 705cbb6..0000000 --- a/fixtures/yonbanme-no-yagai-purojekuto/setup_test.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -set -euo pipefail - -setup_test() { - local this_dir=$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}") - pushd $this_dir > /dev/null - local cwd=$(pwd) - local test_name="${cwd##*/}" - local out_dir="${HOZ_TMP_DIR}/${test_name}" - mkdir -p $out_dir - - # fetch the recent version of the github example, save it locally, and use - # that as a local git repo (needs all the flags belows; plus the revision and hash) - nix-prefetch-git --quiet \ - --out $out_dir \ - --builder \ - --leave-dotGit \ - https://github.com/adetokunbo/example-fetched-haskell-overridez \ - e1dc13ae7dcb3a4c4b7f426a94ecf523532ea574 \ - 0sapkc9mpk95dlq6n87z8xa8w4r0cnxxpnyp971m5phjpbn83c7q - ls -l $out_dir - - # Make a directory under the tmp root in which to save the output - local dst_dir="${HOZ_TMP_DIR}/dst/${test_name}" - mkdir -p $dst_dir - (cat < ./nix/indirect_import.nix - $HOZ_TEST_CMD -o $dst_dir fetch "file://${out_dir}" - [[ -d $dst_dir ]] && ls -l $dst_dir - popd > /dev/null -} - -setup_test diff --git a/fixtures/yonbanme-no-yagai-purojekuto/yonbanme-no-yagai-purojekuto.cabal b/fixtures/yonbanme-no-yagai-purojekuto/yonbanme-no-yagai-purojekuto.cabal deleted file mode 100644 index a54d40a..0000000 --- a/fixtures/yonbanme-no-yagai-purojekuto/yonbanme-no-yagai-purojekuto.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: yonbanme-no-yagai-purojekuto -version: 1.0.0 -license: BSD3 -license-file: LICENSE -cabal-version: >= 1.18 -build-type: Simple - -executable yonbanme-no-yagai-purojekuto - build-depends: base < 5, foldl, text, turtle - main-is: Main.hs - default-language: Haskell2010 diff --git a/fixtures/gobanme-no-yagai-purojekuto/LICENSE b/haskell-overridez-tests/LICENSE similarity index 100% rename from fixtures/gobanme-no-yagai-purojekuto/LICENSE rename to haskell-overridez-tests/LICENSE diff --git a/fixtures/kyuubanme-no-purojekuto/default.nix b/haskell-overridez-tests/fixtures/kyuubanme-no-purojekuto/default.nix similarity index 70% rename from fixtures/kyuubanme-no-purojekuto/default.nix rename to haskell-overridez-tests/fixtures/kyuubanme-no-purojekuto/default.nix index 5597b9a..35cc070 100644 --- a/fixtures/kyuubanme-no-purojekuto/default.nix +++ b/haskell-overridez-tests/fixtures/kyuubanme-no-purojekuto/default.nix @@ -1,9 +1,10 @@ let - overridez = import ./nix/haskell-overridez.nix; + overridez = import ./lib.nix {}; + theOverrides = overridez.allIn ./nix; overlays = let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { - beam-core = null; - kyuubanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/kyuubanme-no-purojekuto.nix {}; + logging-effect-extra-handler = null; + kyuubanme-no-purojekuto = haskellPackagesNew.callPackage ./kyuubanme-no-purojekuto.nix {}; }; in [ (newPkgs: oldPkgs: @@ -12,7 +13,7 @@ let composeExtensionsList = fold composeExtensions (_: _: {}); in { haskellPackages = oldPkgs.haskellPackages.override { - overrides = composeExtensionsList [dropTestPkgs (overridez.allIn ./nix)]; + overrides = composeExtensionsList [dropTestPkgs theOverrides]; }; }) ]; diff --git a/fixtures/kyuubanme-no-purojekuto/kyuubanme-no-purojekuto.cabal b/haskell-overridez-tests/fixtures/kyuubanme-no-purojekuto/kyuubanme-no-purojekuto.cabal similarity index 89% rename from fixtures/kyuubanme-no-purojekuto/kyuubanme-no-purojekuto.cabal rename to haskell-overridez-tests/fixtures/kyuubanme-no-purojekuto/kyuubanme-no-purojekuto.cabal index 90eab9c..6448de0 100644 --- a/fixtures/kyuubanme-no-purojekuto/kyuubanme-no-purojekuto.cabal +++ b/haskell-overridez-tests/fixtures/kyuubanme-no-purojekuto/kyuubanme-no-purojekuto.cabal @@ -6,6 +6,6 @@ cabal-version: >= 1.18 build-type: Simple executable kyuubanme-no-purojekuto - build-depends: base < 5, logging-effect, prettyprinter, text + build-depends: base < 5, logging-effect, prettyprinter, text, logging-effect-extra-handler main-is: Main.hs default-language: Haskell2010 diff --git a/fixtures/nanabanme-no-purojekuto/default.nix b/haskell-overridez-tests/fixtures/nanabanme-no-purojekuto/default.nix similarity index 81% rename from fixtures/nanabanme-no-purojekuto/default.nix rename to haskell-overridez-tests/fixtures/nanabanme-no-purojekuto/default.nix index 15458b6..97ca77c 100644 --- a/fixtures/nanabanme-no-purojekuto/default.nix +++ b/haskell-overridez-tests/fixtures/nanabanme-no-purojekuto/default.nix @@ -1,15 +1,15 @@ let - overridez = import ./nix/haskell-overridez.nix; + overridez = import ./lib.nix {}; overlays = let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { foldl = null; managed = null; optparse-applicative = null; turtle = null; - nanabanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/nanabanme-no-purojekuto.nix {}; + nanabanme-no-purojekuto = haskellPackagesNew.callPackage ./nanabanme-no-purojekuto.nix {}; }; in [ - (newPkgs: oldPkgs: = { + (newPkgs: oldPkgs: { haskellPackages = oldPkgs.haskellPackages.override { overrides = dropTestPkgs; }; diff --git a/fixtures/hachibanme-no-purojekuto/LICENSE b/haskell-overridez-tests/fixtures/template/LICENSE similarity index 100% rename from fixtures/hachibanme-no-purojekuto/LICENSE rename to haskell-overridez-tests/fixtures/template/LICENSE diff --git a/fixtures/hachibanme-no-purojekuto/default.nix b/haskell-overridez-tests/fixtures/template/default.nix similarity index 52% rename from fixtures/hachibanme-no-purojekuto/default.nix rename to haskell-overridez-tests/fixtures/template/default.nix index 9d8f1b7..5c91507 100644 --- a/fixtures/hachibanme-no-purojekuto/default.nix +++ b/haskell-overridez-tests/fixtures/template/default.nix @@ -1,13 +1,13 @@ let - overridez = import ./nix/haskell-overridez.nix; - jibunNo = import ./nix/indirect_import.nix; + overridez = import ./lib.nix {}; + theOverrides = overridez.allIn ./nix; overlays = let dropTestPkgs = haskellPackagesNew: haskellPackagesOld: { foldl = null; managed = null; optparse-applicative = null; turtle = null; - hachibanme-no-purojekuto = haskellPackagesNew.callPackage ./nix/hachibanme-no-purojekuto.nix {}; + purojekuto-no-namae = haskellPackagesNew.callPackage ./purojekuto-no-namae.nix {}; }; in [ (newPkgs: oldPkgs: @@ -16,11 +16,13 @@ let composeExtensionsList = fold composeExtensions (_: _: {}); in { haskellPackages = oldPkgs.haskellPackages.override { - overrides = composeExtensionsList [dropTestPkgs jibunNo]; + overrides = composeExtensionsList [dropTestPkgs theOverrides]; }; }) ]; - pkgs = import { inherit overlays; }; + nixVersion = import (./. + "/nix/18.09.nix"); + nixpkgs = import ./nix/fetchNixPkgs.nix nixVersion; + pkgs = import nixpkgs { inherit overlays; }; in - { hachibanme-no-purojekuto = pkgs.haskellPackages.hachibanme-no-purojekuto; + { purojekuto-no-namae = pkgs.haskellPackages.purojekuto-no-namae; } diff --git a/haskell-overridez-tests/fixtures/template/nix/18.09.nix b/haskell-overridez-tests/fixtures/template/nix/18.09.nix new file mode 100644 index 0000000..a85f620 --- /dev/null +++ b/haskell-overridez-tests/fixtures/template/nix/18.09.nix @@ -0,0 +1,4 @@ +{ + rev = "a4c4cbb613cc3e15186de0fdb04082fa7e38f6a0"; + sha256 = "1lagfycy2lvfc8cdxk98dz2rxjlrbmv9hj42x0x40sy66bck1w0y"; +} \ No newline at end of file diff --git a/haskell-overridez-tests/fixtures/template/nix/fetchNixPkgs.nix b/haskell-overridez-tests/fixtures/template/nix/fetchNixPkgs.nix new file mode 100644 index 0000000..e04db8f --- /dev/null +++ b/haskell-overridez-tests/fixtures/template/nix/fetchNixPkgs.nix @@ -0,0 +1,7 @@ +{ rev # The Git revision of nixpkgs to fetch +, sha256 # The SHA256 of the downloaded data +}: +builtins.fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; + inherit sha256; +} diff --git a/haskell-overridez-tests/fixtures/template/project.cabal b/haskell-overridez-tests/fixtures/template/project.cabal new file mode 100644 index 0000000..0441a3f --- /dev/null +++ b/haskell-overridez-tests/fixtures/template/project.cabal @@ -0,0 +1,11 @@ +name: purojekuto-no-namae +version: 1.0.0 +license: BSD3 +license-file: LICENSE +cabal-version: >= 1.18 +build-type: Simple + +executable purojekuto-no-namae + build-depends: base < 5, foldl, text, turtle + main-is: Main.hs + default-language: Haskell2010 diff --git a/haskell-overridez-tests/fixtures/template/project.nix b/haskell-overridez-tests/fixtures/template/project.nix new file mode 100644 index 0000000..f737fc1 --- /dev/null +++ b/haskell-overridez-tests/fixtures/template/project.nix @@ -0,0 +1,7 @@ +{ pkgs ? (import {}) }: + +let + haskellPackages = pkgs.haskellPackages; +in rec { + purojekuto-no-namae = haskellPackages.callCabal2nix "purojekuto-no-namae" ./. {}; +} \ No newline at end of file diff --git a/haskell-overridez-tests/haskell-overridez-tests.cabal b/haskell-overridez-tests/haskell-overridez-tests.cabal new file mode 100644 index 0000000..6ef3329 --- /dev/null +++ b/haskell-overridez-tests/haskell-overridez-tests.cabal @@ -0,0 +1,57 @@ +name: haskell-overridez-tests +version: 0.10.3.1 +synopsis: Tests haskell-overridez +description: A separate package for testing the haskell-overridez executable +license: BSD3 +license-file: LICENSE +author: Tim Emiola +maintainer: tim.emiola@gmail.com +category: Distribution,nix +homepage: https://github.com/adetokunbo/haskell-overridez +bug-reports: https://github.com/adetokunbo/haskell-overridez/issues +build-type: Simple +data-files: fixtures/template/*.hs + fixtures/template/LICENSE + fixtures/template/*.nix + fixtures/template/*.cabal + fixtures/template/nix/*.nix + lib.nix +extra-source-files: README.md + ChangeLog.md +cabal-version: 2.0 + +library + hs-source-dirs: src + build-tool-depends: haskell-overridez:haskell-overridez + exposed-modules: Test.Derivation + Test.MkProjectDir + other-modules: Paths_haskell_overridez_tests + build-depends: base >= 4.2 && < 5 + , attoparsec + , containers + , foldl + , hspec + , managed + , nix-derivation + , nix-paths + , system-filepath + , text + , turtle + default-language: Haskell2010 + ghc-options: -Wall -fwarn-tabs + + +test-suite integration-tests + type: exitcode-stdio-1.0 + main-is: Spec.hs + hs-source-dirs: test + other-modules: Paths_haskell_overridez_tests + build-depends: base >= 4.2 && < 5 + , foldl + , nix-paths + , hspec + , haskell-overridez-tests + , text + , turtle + default-language: Haskell2010 + ghc-options: -Wall -fwarn-tabs diff --git a/haskell-overridez-tests/lib.nix b/haskell-overridez-tests/lib.nix new file mode 100644 index 0000000..39694b7 --- /dev/null +++ b/haskell-overridez-tests/lib.nix @@ -0,0 +1,98 @@ +{ debug ? false, pkgs ? import {} }: +let inherit (pkgs.lib) composeExtensions fold foldr listToAttrs mapAttrs'; + inherit (builtins) fromJSON match pathExists readFile readDir replaceStrings toPath trace; + + composeExtensionsList = fold composeExtensions (_: _: {}); + isDir = path: pathExists (toPath (toString (path + "/."))); + _trace = msg: result: if debug then (trace msg result) else result; +in +rec { + combineAllIn = rootDir: otherOverrides: + let + extDir = d: (toString rootDir) + "/" + d; + allExtensions = [ + (nixExprIn (extDir "nix-expr")) + (gitJsonIn (extDir "git-json")) + (optionsIn (extDir "options")) + ] ++ otherOverrides; + in + composeExtensionsList allExtensions; + + allIn = rootDir: combineAllIn rootDir []; + + nixExprIn = aDir: self: super: + let + mkOverride = f: self.callPackage (aDir + "/${f}") { }; + toPackage = f: _: _trace "found override (nix-expr): ${f}" rec { + name = builtins.replaceStrings [ ".nix" ] [ "" ] f; + value = _trace ("using override (nix-expr): ${name}") (mkOverride f); + }; + in + if isDir aDir + then mapAttrs' toPackage (readDir (toPath aDir)) + else _trace ("no overrides (nix-expr): directory not found ${aDir}") {}; + + gitJsonIn = aDir: self: super: + let + inherit (pkgs) fetchFromGitHub; + inherit (pkgs.lib) zipListsWith; + + toGithubAttrs = src: + let ownerRepo = match "https://github.com/(.*)/(.*)\.git" src.url; + zipNV = zipListsWith (fst: snd: {name = fst; value = snd; }); + ownerRepoAttrs = listToAttrs (zipNV ["owner" "repo"] ownerRepo); + in { inherit (src) rev sha256; } // ownerRepoAttrs; + + applyFuncs = funcs: pkgName: foldr (g: a: g a) pkgName funcs; + + readDirOverrides = fetcher: toFetchAttrs: d: + let filePath = n: d + "/${n}.json"; + loadFuncs = [fetcher toFetchAttrs fromJSON readFile filePath]; + mkOverride = n: self.callCabal2nix n (applyFuncs loadFuncs n) { }; + toPackage = file: _: _trace "found override (git-json): ${file}" rec { + name = replaceStrings [ ".json" ] [ "" ] file; + value = _trace ("using override (git-json): ${name}") (mkOverride name); + }; + in mapAttrs' toPackage (readDir d); + + in + if isDir aDir + then readDirOverrides fetchFromGitHub toGithubAttrs aDir + else _trace ("no overrides (git-json): was not a dir ${aDir}") {}; + + optionsIn = aDir: self: super: + let + inherit (builtins) attrValues filter intersectAttrs isList split; + inherit (pkgs.lib) mapAttrs; + + supportedOptions = { + doJailbreak = pkgs.haskell.lib.doJailbreak; + dontCheck = pkgs.haskell.lib.dontCheck; + dontHaddock = pkgs.haskell.lib.dontHaddock; + }; + + mkOverrides = option: names: _: super: + let + f = supportedOptions.${option}; + toPackage = name: _trace "found override (options): ${toString name}" { + inherit name; + value = _trace ("using override (options): ${toString name}") (f super.${name}); + }; + in + _trace "found option ${option} on pkgs ${toString names}" + listToAttrs (map toPackage names); + + readOptionsOverrides = d: + let + nonEmptyNonList = x: (!(isList x)) && x != ""; + availableOptions = intersectAttrs (readDir d) supportedOptions; + lines = f: filter nonEmptyNonList (split "\n" (readFile (d + "/${f}"))); + namesPerOption = mapAttrs (opt: _: lines opt) availableOptions; + optionsOverrides = attrValues (mapAttrs mkOverrides namesPerOption); + in + (composeExtensionsList optionsOverrides) self super; + in + if isDir aDir + then readOptionsOverrides aDir + else _trace ("no overrides (options): was not a dir ${aDir}") {}; +} \ No newline at end of file diff --git a/haskell-overridez-tests/src/Test/Derivation.hs b/haskell-overridez-tests/src/Test/Derivation.hs new file mode 100644 index 0000000..7ecb8e6 --- /dev/null +++ b/haskell-overridez-tests/src/Test/Derivation.hs @@ -0,0 +1,79 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_HADDOCK prune not-home #-} +module Test.Derivation + ( -- * data types + Dependency + + -- * functions + , asCabalUri + , hasDeps + , mkNameOnly + , mkDep + + -- * re-exports + , module Nix.Derivation + ) + +where + +import qualified Data.Map.Strict as Map +import Data.Text (Text) +import qualified Data.Text as Text +import Filesystem.Path.CurrentOS (FilePath, toText) +import GHC.Generics (Generic) +import Prelude hiding (FilePath) + +import Nix.Derivation (Derivation (..)) + + +-- | @Dependency@ is a package that may be a key in 'Derivation' 'inputDrvs'. +data Dependency = Dependency + { depName :: !Text + , depVersion :: !(Maybe Text) + } deriving (Show, Eq, Generic) + + +-- | construct a dependency with name only +mkNameOnly :: Text -> Dependency +mkNameOnly n = Dependency n Nothing + + +-- | construct a dependency with name and version +mkDep :: Text -> Text -> Dependency +mkDep n v = Dependency n $ Just v + + +-- | Given a 'Derivation' determine if all of the given dependencies are present. +hasDeps :: [Dependency] -> Derivation -> Bool +hasDeps ds drv = all hasMatch ds + where + hasMatch d = any (depMatches d) drvDeps + drvDeps = asInputDeps drv + + +depMatches :: Dependency -> Dependency -> Bool +depMatches d1@(Dependency _ (Just _)) d2@(Dependency _ (Just _)) = d1 == d2 +depMatches (Dependency n1 _) (Dependency n2 _) = n1 == n2 + + +asInputDeps :: Derivation -> [Dependency] +asInputDeps = map (drvToDep . fst) . Map.toAscList . inputDrvs + + +drvToDep :: FilePath -> Dependency +drvToDep = toDep . devName + where + -- N.B. this assumes that the path name is: + -- /nix/store/${32_CHARACTER_HASH}-${NAME}.drv + devName = Text.dropEnd 4 . Text.drop 44 . pathToText + pathToText = either id id . toText + toDep t = case (Text.breakOnEnd "-" t) of + ("", name) -> Dependency name Nothing + (name, version) -> Dependency (Text.dropWhileEnd (== '-') name) $ Just version + + +-- | Render as dependency as the equivalent cabal uri. +asCabalUri :: Dependency -> Text +asCabalUri d = "cabal://" <> depName d <> "-" <> (maybe "" id $ depVersion d) diff --git a/haskell-overridez-tests/src/Test/MkProjectDir.hs b/haskell-overridez-tests/src/Test/MkProjectDir.hs new file mode 100644 index 0000000..b0a666b --- /dev/null +++ b/haskell-overridez-tests/src/Test/MkProjectDir.hs @@ -0,0 +1,176 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_HADDOCK prune not-home #-} +module Test.MkProjectDir + ( -- * functions + checkDerivation + , checkDerivation' + , mkProjectDir + , simpleCopy + , cpWithAltDir + ) +where + +import qualified Control.Foldl as Foldl +import Control.Monad.Managed (MonadManaged) +import qualified Data.Attoparsec.Text as Text +import qualified Data.Text as Text +import qualified Data.Text.IO as Text +import Nix.Derivation (Derivation, parseDerivation) +import Nix.Paths (nixInstantiate) +import Turtle +import qualified Turtle (FilePath) + +import Paths_haskell_overridez_tests + + +-- | mkDerivation obtains a derivation for the given name from a copy of the +-- template directory after running an action in it. +mkDerivation :: MonadManaged m => HowToCopy -> IO () -> m Derivation +mkDerivation htc action = do + dir <- mkProjectDir' htc + pushd dir + liftIO $ do + action + runNixInstantiate (htcName htc) dir + + +-- | checkDerivation determines if the derivation created from a copy of the +-- template directory matches a filter. +checkDerivation :: MonadManaged m => (Derivation -> Bool) -> Text -> IO () -> m Bool +checkDerivation checkf name action = checkf <$> mkDerivation (simpleCopy name) action + + +-- | checkDerivation determines if the derivation created from a copy of the +-- template directory matches a filter. +checkDerivation' :: MonadManaged m => (Derivation -> Bool) -> HowToCopy -> IO () -> m Bool +checkDerivation' checkf htc action = checkf <$> mkDerivation htc action + + +runNixInstantiate :: Text -> Turtle.FilePath -> IO Derivation +runNixInstantiate name dir = do + let cmd = inproc nixInstantiate' ["-A", name, (format fp dir)] empty + fold (lineToText <$> cmd) Foldl.head >>= \case + Nothing -> error $ "No derivation computed for " ++ (Text.unpack name) + Just drvPath -> loadDerivation $ fromText drvPath + + +loadDerivation :: Turtle.FilePath -> IO Derivation +loadDerivation drvPath = do + let strPath = Text.unpack $ format fp drvPath + drv <- Text.readFile strPath + case (Text.parse parseDerivation drv) of + Text.Done _ z -> pure z + _ -> error $ "failed to load a derivation from " ++ strPath + + +-- | Describes how files should be copied from the template directory. +data HowToCopy = + HowToCopy + { htcName :: Text + , htcAltDir :: Maybe Turtle.FilePath + } + + +-- | Copy files, only replacing the template project name. +simpleCopy :: Text -> HowToCopy +simpleCopy n = HowToCopy n Nothing + + +-- | Copy files, replacing the template project name and overridez import folder. +cpWithAltDir :: Text -> Turtle.FilePath -> HowToCopy +cpWithAltDir n p = HowToCopy n $ Just p + + +-- | Creates a project dir containing a default.nix based on the template test dir. +mkProjectDir :: MonadManaged m => Text -> m Turtle.FilePath +mkProjectDir name = mkProjectDir' $ simpleCopy name + + +-- | Creates a project dir containing a default.nix based on the template test dir. +mkProjectDir' :: MonadManaged m => HowToCopy -> m Turtle.FilePath +mkProjectDir' htc@HowToCopy { htcName = name } = do + let cabal = fromText $ name <> ".cabal" + nix = fromText $ name <> ".nix" + projectDir = fromText name + dir <- mktempdir "/tmp" name + let nixDir = dir "nix" + mkdir nixDir + liftIO $ do + void $ cpTemplateFile dir "LICENSE" + mvPnameTemplate name cabal dir "project.cabal" >>= orUseAlt (projectDir cabal) + mvPnameTemplate name nix dir "project.nix" >>= orUseAlt (projectDir nix) + cpPnameTemplate htc dir "default.nix" >>= orUseAlt (projectDir "default.nix") + void $ cpProjectFile dir "lib.nix" + void $ cpTemplateFile nixDir "nix/fetchNixPkgs.nix" + void $ cpTemplateFile nixDir "nix/18.09.nix" + pure dir + + +orUseAlt :: Turtle.FilePath -> Turtle.FilePath -> IO () +orUseAlt alt dst = do + let altPath = encodeString $ "fixtures" alt + fullAltPath <- decodeString <$> getDataFileName altPath + hasReplacement <- testfile fullAltPath + when (hasReplacement) $ cp fullAltPath dst + + +-- | Copy a fixture template file to a new directory. +cpTemplateFile :: Turtle.FilePath -> Prelude.FilePath -> IO Turtle.FilePath +cpTemplateFile dir name = cpProjectFile dir ("fixtures/template/" ++ name) + + +-- | Copy a fixture template file to a new directory. +cpProjectFile :: Turtle.FilePath -> Prelude.FilePath -> IO Turtle.FilePath +cpProjectFile dir name = do + raw <- decodeString <$> (getDataFileName name) + let p = dir (filename raw) + cp raw p + pure p + + +-- | Copy a template file updating as indicated by HowToCopy. +cpPnameTemplate :: HowToCopy -> Turtle.FilePath -> Prelude.FilePath -> IO Turtle.FilePath +cpPnameTemplate htc = + let + HowToCopy { htcName = name, htcAltDir = mbAlt } = htc + justName = replacePname name + andNixDir = maybe id replaceNixDir mbAlt + in + sedMvTemplateFile filename (andNixDir . justName) + + +-- | Copy a template file replacing the project name. +mvPnameTemplate + :: Text + -> Turtle.FilePath + -> Turtle.FilePath + -> Prelude.FilePath + -> IO Turtle.FilePath +mvPnameTemplate t newName = sedMvTemplateFile (const newName) (replacePname t) + + +-- | Copy a template file, using a renamer function to determine its final name. +sedMvTemplateFile + :: (Turtle.FilePath -> Turtle.FilePath) + -> (Shell Line -> Shell Line) + -> Turtle.FilePath + -> Prelude.FilePath + -> IO Turtle.FilePath +sedMvTemplateFile rename updates dir name = do + raw <- decodeString <$> (getDataFileName $ "fixtures/template/" ++ name) + let p = dir rename raw + output p $ updates $ input raw + pure p + + +replacePname :: Text -> Shell Line -> Shell Line +replacePname t = sed $ (fmap (const t) $ Turtle.text "purojekuto-no-namae") + + +replaceNixDir :: Turtle.FilePath -> Shell Line -> Shell Line +replaceNixDir n = sed $ (fmap (const $ format fp n) $ Turtle.text "./nix") + + +nixInstantiate' :: Text +nixInstantiate' = Text.pack nixInstantiate diff --git a/haskell-overridez-tests/test/Spec.hs b/haskell-overridez-tests/test/Spec.hs new file mode 100644 index 0000000..dad9312 --- /dev/null +++ b/haskell-overridez-tests/test/Spec.hs @@ -0,0 +1,132 @@ +{-# LANGUAGE OverloadedStrings #-} + +import Test.Hspec +import Turtle + +import System.Exit (ExitCode) +import Test.Derivation (Dependency, asCabalUri, hasDeps, mkDep, + mkNameOnly) +import Test.MkProjectDir (checkDerivation, cpWithAltDir, checkDerivation') + + +main :: IO () +main = hspec $ do + describe "haskell-overridez" $ do + context "using nix-exprs generated via cabal2nix" $ do + it "should create an overlay from https urls" $ do + let + setup = do + hoz ["--flag-override", "DontCheck", optParseUri] + hoz ["--flag-override", "DoJailbreak", turtleUri] + hoz ["--flag-override", "DoJailbreak", foldUri] + checkDrv = hasDeps $ map mkNameOnly ["turtle", "foldl"] + theTest = with (checkDerivation checkDrv "gobanme-no-purojekuto" setup) pure + theTest `shouldReturn` True + + it "should create an overlay from cabal:// urls" $ do + let + setup = do + hoz ["--flag-override", "DontCheck", asCabalUri optParseDep] + hoz ["--flag-override", "DoJailbreak", asCabalUri foldlDep] + hoz ["--flag-override", "DoJailbreak", asCabalUri turtleDep] + checkDrv = hasDeps [foldlDep, turtleDep] + theTest = with (checkDerivation checkDrv "yonbanme-no-purojekuto" setup) pure + theTest `shouldReturn` True + + it "should create an overlay from a github subdir repo" $ do + let + name = "kyuubanme-no-purojekuto" + subpath = "logging-effect-extra-handler" + setup = hoz [leExtraUri, "--", "--subpath", subpath] + checkDrv = hasDeps $ map mkNameOnly [subpath] + theTest = with (checkDerivation checkDrv name setup) pure + theTest `shouldReturn` True + + context "using git json generated via nix-prefetch-git" $ do + it "should create an overlay from github repo names" $ do + let + -- can't use -g with optparse-applicative or foldl, this makes + -- cabal2nix infinitely recurse when converting json to nix-expr + setup = do + hoz [ "--flag-override", "DontCheck", optParseUri] + hoz [ "--flag-override", "DoJailbreak", "-g" + , "Gabriel439/Haskell-Turtle-Library" + ] + hoz [ "--flag-override", "DoJailbreak", foldUri] + checkDrv = hasDeps $ map mkNameOnly ["turtle", "foldl"] + theTest = with (checkDerivation checkDrv "rokubanme-no-purojekuto" setup) pure + theTest `shouldReturn` True + + context "using fetched config" $ do + it "should create an overlay from config in a repo main folder" $ do + let + name = "ichibanme-no-yagai-purojekuto" + nixDir = "./nix/github.com/adetokunbo/example-fetched-haskell-overridez" + setup = hoz ["fetch", exGithubUri] + checkDrv = hasDeps $ map mkNameOnly ["turtle", "foldl"] + copyRule = cpWithAltDir name nixDir + theTest = with (checkDerivation' checkDrv copyRule setup) pure + theTest `shouldReturn` True + + it "should create an overlay from config in a repo sub directory" $ do + let + name = "gobanme-no-yagai-purojekuto" + nixDir = "./nix/github.com/adetokunbo/example-fetched-haskell-overridez" + "subdir-root" "a-subdir" + setup = hoz ["fetch", "--subpath", "subdir-root/a-subdir", exGithubUri] + checkDrv = hasDeps $ map mkNameOnly ["turtle", "foldl"] + copyRule = cpWithAltDir name nixDir + theTest = with (checkDerivation' checkDrv copyRule setup) pure + theTest `shouldReturn` True + + context "saving to an alternate output directory" $ do + it "should create an overlay from github https:// urls" $ do + let + name = "hachibanme-no-purojekuto" + setup altDir = do + hoz' altDir ["--flag-override", "DontCheck", optParseUri] + hoz' altDir ["--flag-override", "DoJailbreak", turtleUri] + hoz' altDir ["--flag-override", "DoJailbreak", foldUri] + checkDrv = hasDeps $ map mkNameOnly ["turtle", "foldl"] + theTest = flip with pure $ do + altDir <- mktempdir "/tmp" $ name <> "-alt" + let copyRule = cpWithAltDir name $ altDir "nix" + checkDerivation' checkDrv copyRule $ setup altDir + theTest `shouldReturn` True + + context "when the haskell-overridez functions are not used " $ do + it "should fail to create an overlay" $ do + let + setup = do + hoz ["--flag-override", "DontCheck", asCabalUri optParseDep] + hoz ["--flag-override", "DoJailbreak", asCabalUri foldlDep] + hoz ["--flag-override", "DoJailbreak", asCabalUri turtleDep] + checkDrv = hasDeps [foldlDep, turtleDep] + theTest = with (checkDerivation checkDrv "nanabanme-no-purojekuto" setup) pure + theTest `shouldThrow` anyExitcode + + +hoz :: MonadIO io => [Text] -> io () +hoz args = procs "haskell-overridez" args empty + + +hoz' :: MonadIO io => Turtle.FilePath -> [Text] -> io () +hoz' altDir args = hoz $ args <> ["-o", format fp altDir] + + +turtleUri, foldUri, optParseUri, leExtraUri, exGithubUri :: Text +turtleUri = "https://github.com/Gabriel439/Haskell-Turtle-Library" +foldUri = "https://github.com/Gabriel439/Haskell-Foldl-Library" +optParseUri = "https://github.com/pcapriotti/optparse-applicative" +leExtraUri = "https://github.com/jship/logging-effect-extra" +exGithubUri = "https://github.com/adetokunbo/example-fetched-haskell-overridez" + + +turtleDep, foldlDep, optParseDep :: Dependency +turtleDep = mkDep "turtle" "1.5.12" +foldlDep = mkDep "foldl" "1.4.5" +optParseDep = mkDep "optparse-applicative" "0.14.2.0" + + +anyExitcode :: Selector ExitCode +anyExitcode = const True diff --git a/test.sh b/test.sh index ee4de95..07201b1 100755 --- a/test.sh +++ b/test.sh @@ -99,4 +99,5 @@ _add_current_project_to_nix() { sed -i'.bak' -e 's|src = ./.|src = ../.|' $nix_file } -test "$@" +echo "DEPRECATED: instead of test.sh, use 'nix-shell --run 'cabal new-test haskell-overridez-tests'" +# test "$@"