added project with nix
This commit is contained in:
parent
c65b820e0a
commit
0d1e4ff2a3
14 changed files with 202 additions and 0 deletions
1
src/posts/0010-Haskell-Now/project/.envrc
Normal file
1
src/posts/0010-Haskell-Now/project/.envrc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
use nix
|
2
src/posts/0010-Haskell-Now/project/.gitignore
vendored
Normal file
2
src/posts/0010-Haskell-Now/project/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
dist-newstyle/
|
||||||
|
result
|
5
src/posts/0010-Haskell-Now/project/CHANGELOG.md
Normal file
5
src/posts/0010-Haskell-Now/project/CHANGELOG.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Revision history for project
|
||||||
|
|
||||||
|
## 0.1.0.0 -- YYYY-mm-dd
|
||||||
|
|
||||||
|
* First version. Released on an unsuspecting world.
|
30
src/posts/0010-Haskell-Now/project/LICENSE
Normal file
30
src/posts/0010-Haskell-Now/project/LICENSE
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
Copyright (c) 2019, Yann Esposito (Yogsototh)
|
||||||
|
|
||||||
|
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 Yann Esposito (Yogsototh) 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.
|
2
src/posts/0010-Haskell-Now/project/Setup.hs
Normal file
2
src/posts/0010-Haskell-Now/project/Setup.hs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
import Distribution.Simple
|
||||||
|
main = defaultMain
|
8
src/posts/0010-Haskell-Now/project/app/Main.hs
Normal file
8
src/posts/0010-Haskell-Now/project/app/Main.hs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
module Main where
|
||||||
|
|
||||||
|
import qualified MyLib (someFunc)
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
putStrLn "Hello, Haskell!"
|
||||||
|
MyLib.someFunc
|
0
src/posts/0010-Haskell-Now/project/cabal.project.local
Normal file
0
src/posts/0010-Haskell-Now/project/cabal.project.local
Normal file
32
src/posts/0010-Haskell-Now/project/default.nix
Normal file
32
src/posts/0010-Haskell-Now/project/default.nix
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{ nixpkgs ? import ./nixpkgs.nix
|
||||||
|
, compiler ? "default"
|
||||||
|
, doBenchmark ? false }:
|
||||||
|
let
|
||||||
|
inherit (nixpkgs) pkgs;
|
||||||
|
name = "project";
|
||||||
|
haskellPackages = pkgs.haskellPackages;
|
||||||
|
variant = if doBenchmark
|
||||||
|
then pkgs.haskell.lib.doBenchmark
|
||||||
|
else pkgs.lib.id;
|
||||||
|
drv = haskellPackages.callCabal2nix name ./. {};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
my_project = drv;
|
||||||
|
shell = haskellPackages.shellFor {
|
||||||
|
# generate hoogle doc
|
||||||
|
withHoogle = true;
|
||||||
|
packages = p: [drv];
|
||||||
|
# packages dependencies (by default haskellPackages)
|
||||||
|
buildInputs = with haskellPackages;
|
||||||
|
[ hlint
|
||||||
|
ghcid
|
||||||
|
cabal-install
|
||||||
|
cabal2nix
|
||||||
|
hindent
|
||||||
|
];
|
||||||
|
# nice prompt for the nix-shell
|
||||||
|
shellHook = ''
|
||||||
|
export PS1="\n[${name}:\033[1;32m\]\W\[\033[0m\]]> "
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
1
src/posts/0010-Haskell-Now/project/nixpkgs.nix
Normal file
1
src/posts/0010-Haskell-Now/project/nixpkgs.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {}
|
105
src/posts/0010-Haskell-Now/project/project.cabal
Normal file
105
src/posts/0010-Haskell-Now/project/project.cabal
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
cabal-version: 2.4
|
||||||
|
|
||||||
|
-- Initial package description 'project.cabal' generated by 'cabal init'.
|
||||||
|
-- For further documentation, see http://haskell.org/cabal/users-guide/
|
||||||
|
|
||||||
|
-- The name of the package.
|
||||||
|
name: project
|
||||||
|
|
||||||
|
-- The package version. See the Haskell package versioning policy (PVP)
|
||||||
|
-- for standards guiding when and how versions should be incremented.
|
||||||
|
-- https://pvp.haskell.org
|
||||||
|
-- PVP summary: +-+------- breaking API changes
|
||||||
|
-- | | +----- non-breaking API additions
|
||||||
|
-- | | | +--- code changes with no API change
|
||||||
|
version: 0.1.0.0
|
||||||
|
|
||||||
|
-- A short (one-line) description of the package.
|
||||||
|
-- synopsis:
|
||||||
|
|
||||||
|
-- A longer description of the package.
|
||||||
|
-- description:
|
||||||
|
|
||||||
|
-- A URL where users can report bugs.
|
||||||
|
-- bug-reports:
|
||||||
|
|
||||||
|
-- The license under which the package is released.
|
||||||
|
license: BSD-3-Clause
|
||||||
|
|
||||||
|
-- The file containing the license text.
|
||||||
|
license-file: LICENSE
|
||||||
|
|
||||||
|
-- The package author(s).
|
||||||
|
author: Yann Esposito (Yogsototh)
|
||||||
|
|
||||||
|
-- An email address to which users can send suggestions, bug reports, and
|
||||||
|
-- patches.
|
||||||
|
maintainer: yann.esposito@gmail.com
|
||||||
|
|
||||||
|
-- A copyright notice.
|
||||||
|
-- copyright:
|
||||||
|
|
||||||
|
-- category:
|
||||||
|
|
||||||
|
-- Extra files to be distributed with the package, such as examples or a
|
||||||
|
-- README.
|
||||||
|
extra-source-files: CHANGELOG.md
|
||||||
|
|
||||||
|
|
||||||
|
library
|
||||||
|
-- Modules exported by the library.
|
||||||
|
exposed-modules: MyLib
|
||||||
|
|
||||||
|
-- Modules included in this library but not exported.
|
||||||
|
-- other-modules:
|
||||||
|
|
||||||
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
|
other-extensions: NoImplicitPrelude
|
||||||
|
|
||||||
|
-- Other library packages from which modules are imported.
|
||||||
|
build-depends: base ^>=4.12.0.0,
|
||||||
|
protolude
|
||||||
|
|
||||||
|
-- Directories containing source files.
|
||||||
|
hs-source-dirs: src
|
||||||
|
|
||||||
|
-- Base language which the package is written in.
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
|
||||||
|
executable project
|
||||||
|
-- .hs or .lhs file containing the Main module.
|
||||||
|
main-is: Main.hs
|
||||||
|
|
||||||
|
-- Modules included in this executable, other than Main.
|
||||||
|
-- other-modules:
|
||||||
|
|
||||||
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
|
other-extensions: NoImplicitPrelude
|
||||||
|
|
||||||
|
-- Other library packages from which modules are imported.
|
||||||
|
build-depends: base ^>=4.12.0.0, project
|
||||||
|
|
||||||
|
-- Directories containing source files.
|
||||||
|
hs-source-dirs: app
|
||||||
|
|
||||||
|
-- Base language which the package is written in.
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
|
||||||
|
test-suite project-test
|
||||||
|
-- Base language which the package is written in.
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
-- The interface type and version of the test suite.
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
|
||||||
|
-- The directory where the test specifications are found.
|
||||||
|
hs-source-dirs: test
|
||||||
|
|
||||||
|
-- The entrypoint to the test suite.
|
||||||
|
main-is: MyLibTest.hs
|
||||||
|
|
||||||
|
-- Test dependencies.
|
||||||
|
build-depends: base ^>=4.12.0.0
|
||||||
|
|
4
src/posts/0010-Haskell-Now/project/release.nix
Normal file
4
src/posts/0010-Haskell-Now/project/release.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
let
|
||||||
|
def = import ./. {};
|
||||||
|
in
|
||||||
|
{ my_project = def.my_project; }
|
1
src/posts/0010-Haskell-Now/project/shell.nix
Normal file
1
src/posts/0010-Haskell-Now/project/shell.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(import ./. {}).shell
|
7
src/posts/0010-Haskell-Now/project/src/MyLib.hs
Normal file
7
src/posts/0010-Haskell-Now/project/src/MyLib.hs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{-# LANGUAGE NoImplicitPrelude #-}
|
||||||
|
module MyLib (someFunc) where
|
||||||
|
|
||||||
|
import Protolude
|
||||||
|
|
||||||
|
someFunc :: IO ()
|
||||||
|
someFunc = putStrLn "someFunc"
|
4
src/posts/0010-Haskell-Now/project/test/MyLibTest.hs
Normal file
4
src/posts/0010-Haskell-Now/project/test/MyLibTest.hs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
module Main (main) where
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = putStrLn "Test suite not yet implemented."
|
Loading…
Reference in a new issue