Skip to content

Commit

Permalink
update readme.org
Browse files Browse the repository at this point in the history
  • Loading branch information
hughjfchen committed Dec 19, 2020
1 parent d1f0656 commit dbefb62
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 6 deletions.
41 changes: 36 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
# quick-cook-haskell-project

This repo is a tool which can quickly cook a haskell project for exploring. It is based on following tools:
** nix
** haskell.nix
** summoner
# Table of Contents

1. [Features](#org87edada)
2. [Usage](#orgc7dd06a)

This is a tool which can help you generate a haskell project which uses the haskell.nix as the build framework.


<a id="org87edada"></a>

# Features

This tool has following features at this moment:

- provision nix if needed
- generate haskell project with the summoner tool
- generate most usable nix files, including:
- **default.nix:** this is the major nix file
- **shell.nix:** to setup a development environment with nix-shell
- **cross-build.nix:** this nix expression can be used to build cross platform targets, including fully static linked binary with musl library
- **docker.nix:** this file can be used to build a docker image for the project


<a id="orgc7dd06a"></a>

# Usage

Following these steps to use this tool:

1. clone the repository
2. run the following command under the clone directory:

<p class="verse">
./cook.sh <the porject directory> <the project name><br />
</p>

27 changes: 27 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#+TITLE: Readme
#+AUTHOR: Hugh JF Chen
#+DATE: 2020-12-18
#+OPTIONS: ^:{} toc:3

This is a tool which can help you generate a haskell project which uses the haskell.nix as the build framework.

* Features

This tool has following features at this moment:
- provision nix if needed
- generate haskell project with the summoner tool
- generate most usable nix files, including:
- default.nix :: this is the major nix file
- shell.nix :: to setup a development environment with nix-shell
- cross-build.nix :: this nix expression can be used to build cross platform targets, including fully static linked binary with musl library
- docker.nix :: this file can be used to build a docker image for the project

* Usage

Following these steps to use this tool:

1. clone the repository
2. run the following command under the clone directory:
#+begin_verse
./cook.sh <the porject directory> <the project name>
#+end_verse
5 changes: 4 additions & 1 deletion build-framework/do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ do
rm -fr ${FILE_TO_SED}.bak.for.sed.inplace.edit
done

MY_INDEX_STATE=$(date +%Y-%m-%dT00:00:00Z)
#update index-state in the cabal.project file
echo "packages : ." > "$1/$2"/cabal.project
echo "index-state : $(date +%Y-%m-%dT00:00:00Z)" >> "$1/$2"/cabal.project
echo "index-state : ${MY_INDEX_STATE}" >> "$1/$2"/cabal.project
# touch a cabal.project.local to make sure emacs dante use new-impure-nix build method
touch "$1/$2"/cabal.project.local
# also for emacs dante target
Expand Down Expand Up @@ -61,10 +62,12 @@ MY_CABAL_VER=$(nix-env -f "${MY_NIXPKGS_URL}" --quiet -qaP cabal-install -A hask
MY_HLINT_VER=$(nix-env -f "${MY_NIXPKGS_URL}" --quiet -qaP hlint -A haskellPackages | sed -n '/hlint\ /p' | awk '{print $NF}' | awk -F"-" '{print $NF}')
sed -i.bak.for.replace.my_nixpkgs "s/MY_NIXPKGS/${MY_NIXPKGS}/g" "$1/$2/default.nix"
sed -i.bak.for.replace.my_ghc_ver "s/MY_GHC_VER/${MY_GHC_VER}/g" "$1/$2/default.nix"
sed -i.bak.for.replace.my_index_state "s/MY_INDEX_STATE/${MY_INDEX_STATE}/g" "$1/$2/default.nix"
sed -i.bak.for.replace.my_cabal_ver "s/MY_CABAL_VER/${MY_CABAL_VER}/g" "$1/$2/shell.nix"
sed -i.bak.for.replace.my_hlint_ver "s/MY_HLINT_VER/${MY_HLINT_VER}/g" "$1/$2/shell.nix"
rm -fr "$1/$2"/default.nix.bak.for.replace.my_nixpkgs
rm -fr "$1/$2"/default.nix.bak.for.replace.my_ghc_ver
rm -fr "$1/$2"/default.nix.bak.for.replace.my_index_state
rm -fr "$1/$2"/shell.nix.bak.for.replace.my_cabal_ver
rm -fr "$1/$2"/shell.nix.bak.for.replace.my_hlint_ver

Expand Down
1 change: 1 addition & 0 deletions build-framework/template/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ rec {
name = "MY_PROJECT_NAME";
src = ./.;
};
index-state: "MY_INDEX_STATE";
compiler-nix-name = haskellCompiler;
# 'ghc' option is deprecated
#ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${haskellCompiler};
Expand Down

0 comments on commit dbefb62

Please sign in to comment.