From 86632edbd65a0532891d2d084e717ee356403f30 Mon Sep 17 00:00:00 2001 From: Ingun Date: Tue, 18 Apr 2023 15:45:39 +0900 Subject: [PATCH] Cabal (#3) --- .github/workflows/main.yml | 56 ------------ .gitignore | 86 +++++++++++++++++- ChangeLog.md | 6 +- LICENSE | 30 ------- README.md | 43 ++++++++- Setup.hs | 2 - answers-script.cabal | 180 +++++++++++++++---------------------- default.nix | 55 ++++++------ nix/sources.json | 38 -------- nix/sources.nix | 174 ----------------------------------- package.yaml | 78 ---------------- shell.nix | 43 +++++++++ stack.yaml | 66 -------------- stack.yaml.lock | 12 --- 14 files changed, 271 insertions(+), 598 deletions(-) delete mode 100644 .github/workflows/main.yml delete mode 100644 LICENSE delete mode 100644 Setup.hs delete mode 100644 nix/sources.json delete mode 100644 nix/sources.nix delete mode 100644 package.yaml create mode 100644 shell.nix delete mode 100644 stack.yaml delete mode 100644 stack.yaml.lock diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 9d795b4..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,56 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [ main ] - pull_request: - branches: [ main ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - name: Install Nix - # You may pin to the exact commit or the version. - # uses: cachix/install-nix-action@29bd9290ef037a3ecbdafe83cbd2185e9dd0fa0a - uses: cachix/install-nix-action@v20 - with: - # Gets appended to `/etc/nix/nix.conf` if passed. - extra_nix_config: | - trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= - substituters = https://cache.iog.io https://cache.nixos.org/ - - - - - name: Cachix - # You may pin to the exact commit or the version. - # uses: cachix/cachix-action@6a9a34cdd93d0ae4b4b59fd678660efb08109f2f - uses: cachix/cachix-action@v12 - with: - # Name of a cachix cache to push and pull/substitute - name: inguncache - # Authentication token for Cachix, needed only for private cache access - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: nix build - # run: nix-build | cachix push inguncache - run: nix-build -A answers-script.components.exes.answers-script-exe | cachix push inguncache - - # Runs a set of commands using the runners shell - # - name: Run a multi-line script - # run: | - # echo Add other actions to build, - # echo test, and deploy your project. diff --git a/.gitignore b/.gitignore index 75191fd..df50a24 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,85 @@ -.stack-work/ +.cabal-sandbox/ +cabal.sandbox.config +cabal.project.local +.ghc.environment.* +cabal-dev/ +.hpc/ +*.hi +*.o +*.p_hi +*.prof +*.tix +dist +dist-* +register.sh +./cabal.config +cabal-tests.log +bootstrap/*.plan.json + +/Cabal/dist/ +/Cabal/tests/Setup +/Cabal/Setup +/Cabal/source-file-list + +/cabal-install/dist/ +/cabal-install/Setup +/cabal-install/source-file-list + +.stylish-haskell.yaml +.stylish-haskell.yml +.ghci +.ghcid + +# Output of release and bootstrap +_build + +# editor temp files + +*# +.#* *~ +.*.swp +*.bak + +# GHC build + +Cabal/GNUmakefile +Cabal/dist-boot/ +Cabal/dist-install/ +Cabal/ghc.mk + + +# TAGS files +TAGS +tags +ctags + +# stack artifacts +/.stack-work/ +stack.yaml.lock + +# Shake artifacts +.shake* +progress.txt + +# test files +register.sh + +# windows test artifacts +cabal-testsuite/**/*.exe +cabal-testsuite/**/*.bat + +# python artifacts from documentation builds +*.pyc +.python-sphinx-virtualenv/ +/doc/.skjold_cache/ + +# macOS folder metadata .DS_Store -result -test/dst/ \ No newline at end of file + +# benchmarks +bench.html + +# Emacs +.projectile +/test/dst/ \ No newline at end of file diff --git a/ChangeLog.md b/ChangeLog.md index 2fa4a04..14619d5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,5 @@ -# Changelog for answers-script +# Revision history for answers-script -## Unreleased changes +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 7caa388..0000000 --- a/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright Author name here (c) 2021 - -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 Author name here 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. diff --git a/README.md b/README.md index 690bc5c..3bc4ab4 100644 --- a/README.md +++ b/README.md @@ -1 +1,42 @@ -# answers-script +# Answers Script + +## Generate default.nix + +```shell +nix-shell -p cabal2nix +cabal2nix --no-check ./. > default.nix +``` + +## Generate shell.nix + +```shell +nix-shell -p cabal2nix +cabal2nix --shell --no-check ./. > shell.nix +``` + +## Build + +**Don't just build using Cabal!!** it will take forever because of Pandoc. + +Build in Nix environment + +```shell +# Enter Nix environment defined in shell.nix +nix-shell +# Use executable +answers-script ... +``` + +## Test + +```shell +nix-shell +cabal --enable-nix test +``` + +## Install from other machines + +```shell +TAR="https://github.com/ingun37/answers-script/archive/refs/tags/test2.tar.gz" +nix-shell -p "with import {}; let f = import (fetchTarball $TAR); in haskellPackages.callPackage f {}" +``` \ No newline at end of file diff --git a/Setup.hs b/Setup.hs deleted file mode 100644 index 9a994af..0000000 --- a/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/answers-script.cabal b/answers-script.cabal index 9cca59d..2817267 100644 --- a/answers-script.cabal +++ b/answers-script.cabal @@ -1,113 +1,81 @@ -cabal-version: 1.12 +cabal-version: 3.0 +name: answers-script +version: 0.1.0.0 --- This file has been generated from package.yaml by hpack version 0.35.1. --- --- see: https://github.com/sol/hpack +-- A short (one-line) description of the package. +-- synopsis: -name: answers-script -version: 0.1.0.0 -description: Please see the README on GitHub at -homepage: https://github.com/githubuser/answers-script#readme -bug-reports: https://github.com/githubuser/answers-script/issues -author: Author name here -maintainer: example@example.com -copyright: 2022 Author name here -license: BSD3 -license-file: LICENSE -build-type: Simple -extra-source-files: - README.md - CHANGELOG.md +-- A longer description of the package. +-- description: -source-repository head - type: git - location: https://github.com/githubuser/answers-script +-- A URL where users can report bugs. +-- bug-reports: + +-- The license under which the package is released. +-- license: +author: Ingun Jon +maintainer: ingun37@gmail.com + +-- A copyright notice. +-- copyright: +-- category: +extra-source-files: CHANGELOG.md library - exposed-modules: - Lib - MyGit - other-modules: - Paths_answers_script - hs-source-dirs: - src - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints - build-depends: - aeson - , aeson-pretty - , base >=4.7 && <5 - , base16-bytestring - , bytestring - , containers - , cryptohash-sha1 - , directory - , directory-tree - , filepath - , hlibgit2 - , lens - , pandoc - , pcre-heavy - , pcre-light - , text - , utf8-string - default-language: Haskell2010 + exposed-modules: Lib, MyGit + + -- Modules included in this library but not exported. + -- other-modules: + + -- LANGUAGE extensions used by modules in this package. + -- other-extensions: + build-depends: + base ^>=4.16.4.0, + aeson, + hlibgit2, + containers, + lens, + cryptohash-sha1, + directory, + directory-tree, + pandoc, + pcre-heavy, + pcre-light, + filepath, + text, + bytestring, + base16-bytestring, + aeson-pretty + hs-source-dirs: src + default-language: Haskell2010 + +executable answers-script + main-is: Main.hs + + -- Modules included in this executable, other than Main. + -- other-modules: + + -- LANGUAGE extensions used by modules in this package. + -- other-extensions: + build-depends: + base ^>=4.16.4.0, + answers-script, + optparse-applicative -executable answers-script-exe - main-is: Main.hs - other-modules: - Paths_answers_script - hs-source-dirs: - app - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson - , aeson-pretty - , answers-script - , base >=4.7 && <5 - , base16-bytestring - , bytestring - , containers - , cryptohash-sha1 - , directory - , directory-tree - , filepath - , hlibgit2 - , lens - , optparse-applicative - , pandoc - , pcre-heavy - , pcre-light - , text - , utf8-string - default-language: Haskell2010 + hs-source-dirs: app + default-language: Haskell2010 -test-suite answers-script-test - type: exitcode-stdio-1.0 - main-is: Spec.hs - other-modules: - Paths_answers_script - hs-source-dirs: - test - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N - build-depends: - QuickCheck - , aeson - , aeson-pretty - , answers-script - , base >=4.7 && <5 - , base16-bytestring - , bytestring - , containers - , cryptohash-sha1 - , directory - , directory-tree - , filepath - , hlibgit2 - , hspec - , lens - , pandoc - , pcre-heavy - , pcre-light - , text - , utf8-string - default-language: Haskell2010 +Test-Suite test + type: exitcode-stdio-1.0 + main-is: Spec.hs + hs-source-dirs: test + default-language: Haskell2010 + build-depends: + base ^>=4.16.4.0, + answers-script, + hspec, + QuickCheck, + directory, + filepath, + bytestring, + directory-tree \ No newline at end of file diff --git a/default.nix b/default.nix index 8837879..b248047 100644 --- a/default.nix +++ b/default.nix @@ -1,30 +1,25 @@ -let - # Read in the Niv sources - sources = import ./nix/sources.nix {}; - # If ./nix/sources.nix file is not found run: - # niv init - # niv add input-output-hk/haskell.nix -n haskellNix - - # Fetch the haskell.nix commit we have pinned with Niv - haskellNix = import sources.haskellNix {}; - # If haskellNix is not found run: - # niv add input-output-hk/haskell.nix -n haskellNix - - # Import nixpkgs and pass the haskell.nix provided nixpkgsArgs - pkgs = import - # haskell.nix provides access to the nixpkgs pins which are used by our CI, - # hence you will be more likely to get cache hits when using these. - # But you can also just use your own, e.g. ''. - haskellNix.sources.nixpkgs-unstable - # These arguments passed to nixpkgs, include some patches and also - # the haskell.nix functionality itself as an overlay. - haskellNix.nixpkgsArgs; -in pkgs.haskell-nix.project { - # 'cleanGit' cleans a source directory based on the files known by git - src = pkgs.haskell-nix.haskellLib.cleanGit { - name = "answers-script"; - src = ./.; - }; - # Specify the GHC version to use. -# compiler-nix-name = "ghc924"; # Not required for `stack.yaml` based projects. -} \ No newline at end of file +{ mkDerivation, aeson, aeson-pretty, base, base16-bytestring +, bytestring, containers, cryptohash-sha1, directory +, directory-tree, filepath, hlibgit2, hspec, lens, lib +, optparse-applicative, pandoc, pcre-heavy, pcre-light, QuickCheck +, text +}: +mkDerivation { + pname = "answers-script"; + version = "0.1.0.0"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson aeson-pretty base base16-bytestring bytestring containers + cryptohash-sha1 directory directory-tree filepath hlibgit2 lens + pandoc pcre-heavy pcre-light text + ]; + executableHaskellDepends = [ base optparse-applicative ]; + testHaskellDepends = [ + base bytestring directory directory-tree filepath hspec QuickCheck + ]; + doCheck = false; + license = "unknown"; + mainProgram = "answers-script"; +} diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index cfab824..0000000 --- a/nix/sources.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "haskellNix": { - "branch": "master", - "description": "Alternative Haskell Infrastructure for Nixpkgs", - "homepage": "https://input-output-hk.github.io/haskell.nix", - "owner": "input-output-hk", - "repo": "haskell.nix", - "rev": "3473e3c9955954a548f28c97d5d47115c5b17b53", - "sha256": "11pqi8qr77v1rbphqh429rgki5anzis2svax2y15h2y8lk7k6fyv", - "type": "tarball", - "url": "https://github.com/input-output-hk/haskell.nix/archive/3473e3c9955954a548f28c97d5d47115c5b17b53.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "niv": { - "branch": "master", - "description": "Easy dependency management for Nix projects", - "homepage": "https://github.com/nmattia/niv", - "owner": "nmattia", - "repo": "niv", - "rev": "351d8bc316bf901a81885bab5f52687ec8ccab6e", - "sha256": "1yzhz7ihkh6p2sxhp3amqfbmm2yqzaadqqii1xijymvl8alw5rrr", - "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/351d8bc316bf901a81885bab5f52687ec8ccab6e.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "release-20.03", - "description": "Nix Packages collection", - "homepage": "", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "345ff18c99af958afdbd57f077aae9af4000e864", - "sha256": "1igwp71cyd8s6j1r80xh895jjfsdry4y67mhr7kmjxc3hbc3axly", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/345ff18c99af958afdbd57f077aae9af4000e864.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index 1938409..0000000 --- a/nix/sources.nix +++ /dev/null @@ -1,174 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } - else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - - fetch_tarball = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - - fetch_git = name: spec: - let - ref = - if spec ? ref then spec.ref else - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; - in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; - - fetch_local = spec: spec.path; - - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; - - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; - - # - # Various helpers - # - - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # If the environment variable NIV_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - replace = name: drv: - let - saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; - ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; - in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); - concatStrings = builtins.concatStringsSep ""; - - # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 - optionalAttrs = cond: as: if cond then as else {}; - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; - -in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/package.yaml b/package.yaml deleted file mode 100644 index d988467..0000000 --- a/package.yaml +++ /dev/null @@ -1,78 +0,0 @@ -name: answers-script -version: 0.1.0.0 -github: "githubuser/answers-script" -license: BSD3 -author: "Author name here" -maintainer: "example@example.com" -copyright: "2022 Author name here" - -extra-source-files: -- README.md -- CHANGELOG.md - -# Metadata used when publishing your package -# synopsis: Short description of your package -# category: Web - -# To avoid duplicated efforts in documentation and dealing with the -# complications of embedding Haddock markup inside cabal files, it is -# common to point users to the README.md file. -description: Please see the README on GitHub at - -dependencies: -- base >= 4.7 && < 5 -- directory-tree -- lens -- text -- pandoc -- filepath -- bytestring -- pcre-heavy -- pcre-light -- containers -- cryptohash-sha1 -- base16-bytestring -- directory -- aeson -- utf8-string -- aeson-pretty -- hlibgit2 - -ghc-options: -- -Wall -- -Wcompat -- -Widentities -- -Wincomplete-record-updates -- -Wincomplete-uni-patterns -- -Wmissing-export-lists -- -Wmissing-home-modules -- -Wpartial-fields -- -Wredundant-constraints - -library: - source-dirs: src - -executables: - answers-script-exe: - main: Main.hs - source-dirs: app - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - dependencies: - - answers-script - - optparse-applicative - -tests: - answers-script-test: - main: Spec.hs - source-dirs: test - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - dependencies: - - answers-script - - hspec - - QuickCheck diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..0ee0bd5 --- /dev/null +++ b/shell.nix @@ -0,0 +1,43 @@ +{ nixpkgs ? import {}, compiler ? "default", doBenchmark ? false }: + +let + + inherit (nixpkgs) pkgs; + + f = { mkDerivation, aeson, aeson-pretty, base, base16-bytestring + , bytestring, containers, cryptohash-sha1, directory + , directory-tree, filepath, hlibgit2, hspec, lens, lib + , optparse-applicative, pandoc, pcre-heavy, pcre-light, QuickCheck + , text + }: + mkDerivation { + pname = "answers-script"; + version = "0.1.0.0"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson aeson-pretty base base16-bytestring bytestring containers + cryptohash-sha1 directory directory-tree filepath hlibgit2 lens + pandoc pcre-heavy pcre-light text + ]; + executableHaskellDepends = [ base optparse-applicative ]; + testHaskellDepends = [ + base bytestring directory directory-tree filepath hspec QuickCheck + ]; + doCheck = false; + license = "unknown"; + mainProgram = "answers-script"; + }; + + haskellPackages = if compiler == "default" + then pkgs.haskellPackages + else pkgs.haskell.packages.${compiler}; + + variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; + + drv = variant (haskellPackages.callPackage f {}); + +in + + if pkgs.lib.inNixShell then drv.env else drv diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index 38822f9..0000000 --- a/stack.yaml +++ /dev/null @@ -1,66 +0,0 @@ -# This file was automatically generated by 'stack init' -# -# Some commonly used options have been documented as comments in this file. -# For advanced use and comprehensive documentation of the format, please see: -# https://docs.haskellstack.org/en/stable/yaml_configuration/ - -# Resolver to choose a 'specific' stackage snapshot or a compiler version. -# A snapshot resolver dictates the compiler version and the set of packages -# to be used for project dependencies. For example: -# -# resolver: lts-3.5 -# resolver: nightly-2015-09-21 -# resolver: ghc-7.10.2 -# -# The location of a snapshot can be provided as a file or url. Stack assumes -# a snapshot provided as a file might change, whereas a url resource does not. -# -# resolver: ./custom-snapshot.yaml -# resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-20.18 - -# User packages to be built. -# Various formats can be used as shown in the example below. -# -# packages: -# - some-directory -# - https://example.com/foo/bar/baz-0.0.2.tar.gz -# subdirs: -# - auto-update -# - wai -packages: -- . -# Dependency packages to be pulled from upstream that are not in the resolver. -# These entries can reference officially published versions as well as -# forks / in-progress versions pinned to a git hash. For example: -# -# extra-deps: -# - acme-missiles-0.3 -# - git: https://github.com/commercialhaskell/stack.git -# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# -# extra-deps: [] - -# Override default flag values for local packages and extra-deps -# flags: {} - -# Extra package databases containing global packages -# extra-package-dbs: [] - -# Control whether we use the GHC we find on the path -# system-ghc: true -# -# Require a specific version of stack, using version ranges -# require-stack-version: -any # Default -# require-stack-version: ">=2.7" -# -# Override the architecture used by stack, especially useful on Windows -# arch: i386 -# arch: x86_64 -# -# Extra directories used by stack for building -# extra-include-dirs: [/path/to/dir] -# extra-lib-dirs: [/path/to/dir] -# -# Allow a newer minor version of GHC than the snapshot specifies -# compiler-check: newer-minor diff --git a/stack.yaml.lock b/stack.yaml.lock deleted file mode 100644 index d4302c7..0000000 --- a/stack.yaml.lock +++ /dev/null @@ -1,12 +0,0 @@ -# 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: [] -snapshots: -- completed: - sha256: 9fa4bece7acfac1fc7930c5d6e24606004b09e80aa0e52e9f68b148201008db9 - size: 649606 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/18.yaml - original: lts-20.18