diff --git a/README.md b/README.md index 678b865..13dfd74 100644 --- a/README.md +++ b/README.md @@ -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. + + + + +# 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: + +

+ ./cook.sh
+

+ diff --git a/README.org b/README.org new file mode 100644 index 0000000..fede544 --- /dev/null +++ b/README.org @@ -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 + #+end_verse diff --git a/build-framework/do.sh b/build-framework/do.sh index b4b319b..24726cb 100755 --- a/build-framework/do.sh +++ b/build-framework/do.sh @@ -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 @@ -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 diff --git a/build-framework/template/default.nix b/build-framework/template/default.nix index f9736d1..056411f 100644 --- a/build-framework/template/default.nix +++ b/build-framework/template/default.nix @@ -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};