Skip to content

Commit

Permalink
change the niv and summon tool to nix-shell package
Browse files Browse the repository at this point in the history
  • Loading branch information
hughjfchen committed Jul 23, 2021
1 parent 6d3db50 commit 13e772b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
29 changes: 15 additions & 14 deletions build-framework/do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,21 @@ set -u
#MY_CHANNEL=$(nix-channel --list | awk -F"/" '{print $NF}')
MY_CHANNEL=$(get_last_stable_nix_channel)
MY_CHANNEL_NUM=$(echo "${MY_CHANNEL}" | awk -F"-" '{print $2}')
case ${THE_DISTRIBUTION_ID} in
debian|ubuntu|rhel|centos)
cd $1/$2
"${SCRIPT_ABS_PATH}"/niv init --no-nixpkgs
# following is for Linux
"${SCRIPT_ABS_PATH}"/niv add NixOS/nixpkgs -n nixpkgs -b "nixos-${MY_CHANNEL_NUM}"
# following is for OSX
"${SCRIPT_ABS_PATH}"/niv add NixOS/nixpkgs -n nixpkgs-darwin -b "nixpkgs-${MY_CHANNEL_NUM}-darwin"
"${SCRIPT_ABS_PATH}"/niv add input-output-hk/haskell.nix
;;
*)
nix-shell '<nixpkgs>' -p haskellPackages.niv --run "cd $1/$2; niv init --no-nixpkgs; niv add NixOS/nixpkgs -n nixpkgs -b nixos-${MY_CHANNEL}; niv add NixOS/nixpkgs -n nixpkgs-darwin -b nixpkgs-${MY_CHANNEL_NUM}-darwin; niv add input-output-hk/haskell.nix"
;;
esac
nix-shell '<nixpkgs>' -p haskellPackages.niv --run "cd $1/$2; niv init --no-nixpkgs; niv add NixOS/nixpkgs -n nixpkgs -b nixos-${MY_CHANNEL}; niv add NixOS/nixpkgs -n nixpkgs-darwin -b nixpkgs-${MY_CHANNEL_NUM}-darwin; niv add input-output-hk/haskell.nix"
#case ${THE_DISTRIBUTION_ID} in
# debian|ubuntu|rhel|centos)
# cd $1/$2
# "${SCRIPT_ABS_PATH}"/niv init --no-nixpkgs
# # following is for Linux
# "${SCRIPT_ABS_PATH}"/niv add NixOS/nixpkgs -n nixpkgs -b "nixos-${MY_CHANNEL_NUM}"
# # following is for OSX
# "${SCRIPT_ABS_PATH}"/niv add NixOS/nixpkgs -n nixpkgs-darwin -b "nixpkgs-${MY_CHANNEL_NUM}-darwin"
# "${SCRIPT_ABS_PATH}"/niv add input-output-hk/haskell.nix
# ;;
# *)
# nix-shell '<nixpkgs>' -p haskellPackages.niv --run "cd $1/$2; niv init --no-nixpkgs; niv add NixOS/nixpkgs -n nixpkgs -b nixos-${MY_CHANNEL}; niv add NixOS/nixpkgs -n nixpkgs-darwin -b nixpkgs-${MY_CHANNEL_NUM}-darwin; niv add input-output-hk/haskell.nix"
# ;;
#esac

# set the nixpkgs to the latest stable channel in the nix file
# also set the ghc version and cabal version accordingly.
Expand Down
26 changes: 14 additions & 12 deletions project-scaffold/do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ set +u
[[ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]] && . $HOME/.nix-profile/etc/profile.d/nix.sh
set -u

case ${THE_DISTRIBUTION_ID} in
debian|ubuntu|rhel|centos)
SCRIPT_ABS_PATH=$(turn_to_absolute_path "$0")
mkdir -p "$1"
cd "$1"
"${SCRIPT_ABS_PATH}"/summon new "$2"
;;
*)
#nix-shell '<nixpkgs>' -p haskellPackages.summoner --run "mkdir -p $1; cd $1; summon new $2"
nix-shell '<nixpkgs>' -p hello --run "mkdir -p $1/$2; hello"
;;
esac
#case ${THE_DISTRIBUTION_ID} in
# debian|ubuntu|rhel|centos)
# SCRIPT_ABS_PATH=$(turn_to_absolute_path "$0")
# mkdir -p "$1"
# cd "$1"
# "${SCRIPT_ABS_PATH}"/summon new "$2"
# ;;
# *)
# #nix-shell '<nixpkgs>' -p haskellPackages.summoner --run "mkdir -p $1; cd $1; summon new $2"
# nix-shell '<nixpkgs>' -p hello --run "mkdir -p $1/$2; hello"
# ;;
#esac

nix-shell '<nixpkgs>' -p haskellPackages.summoner --run "mkdir -p $1; cd $1; summon new $2"

done_banner "Top level" "project scaffold"

0 comments on commit 13e772b

Please sign in to comment.