Skip to content

Fix hix support for github #1627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ steps:
- nix-instantiate release.nix -A required-unstable-ghc8107-x86_64-darwin-native --show-trace --builders ''
agents:
system: x86_64-linux

- label: 'Check hix -- run github:haskell/cabal/3.8#cabal-install:exe:cabal -- --version'
command:
- "HIX_DIR=$(mktemp -d) nix run .#hix --accept-flake-config -- run github:haskell/cabal/3.8#cabal-install:exe:cabal --accept-flake-config --override-input haskellNix . -- --version"
agents:
system: x86_64-linux
57 changes: 30 additions & 27 deletions hix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ let
dump-path|eval|log|path-info|search|show-derivation|sign-paths|verify|why-depends)
nix $cmd -f ${hixProject} ${args} "$@"
;;
flake|build|develop|run)
flake|build|develop|run|profile)
# Put the flake files for remote URLs in $HOME/.hix by default
HIX_DIR="''${HIX_DIR:-$HOME/.hix}"
while(($#)); do
arg=$1
case $arg in
Expand All @@ -45,22 +47,26 @@ let
;;
github:*#*)
SRC="''${arg%%#*}"
args+=("path:${hixProject}#''${arg#*#}" --override-input src "$SRC")
is_github=true
FLAKE=$HIX_DIR/$SRC
args+=("path:$FLAKE#''${arg#*#}" --override-input src "$SRC")
has_input_src=true
;;
github:*)
SRC="$arg"
args+=("path:${hixProject}" --override-input src "$SRC")
is_github=true
FLAKE=$HIX_DIR/$SRC
args+=("path:$FLAKE" --override-input src "$SRC")
has_input_src=true
;;
*#*)
SRC="''${arg%%#*}"
args+=("path:$SRC/.hix-flake#''${arg#*#}" --override-input src "$SRC")
FLAKE=$SRC/.hix-flake
args+=("path:$FLAKE#''${arg#*#}" --override-input src "$SRC")
has_input_src=true
;;
.*)
SRC="$arg"
args+=("path:$SRC/.hix-flake" --override-input src "$SRC")
FLAKE=$SRC/.hix-flake
args+=("path:$FLAKE" --override-input src "$SRC")
has_input_src=true
;;
*)
Expand All @@ -69,27 +75,24 @@ let
esac
shift
done
if [ "$is_github" != true ]; then
if [ "$has_input_src" != true ]; then
SRC=.
args+=("path:$SRC/.hix-flake" --override-input src "$SRC")
fi
# Make a temporary flake if we have not already
if [ ! -d $SRC/.hix-flake ]; then
mkdir $SRC/.hix-flake
fi
HIX_FLAKE="$(mktemp -d)/flake.nix"
sed 's|EVAL_SYSTEM|${pkgs.stdenv.hostPlatform.system}|' < ${hixProject}/flake.nix > $HIX_FLAKE
if ! cmp $HIX_FLAKE $SRC/.hix-flake/flake.nix &>/dev/null; then
if [ -e $SRC/.hix-flake/flake.lock ]; then
echo "Updating $SRC/.hix-flake/flake.nix and deleting old $SRC/.hix-flake/flake.lock"
rm $SRC/.hix-flake/flake.lock
else
echo "Updating $SRC/.hix-flake/flake.nix"
fi
cp $HIX_FLAKE $SRC/.hix-flake/flake.nix
chmod +w $SRC/.hix-flake/flake.nix
if [ "$has_input_src" != true ]; then
SRC=.
FLAKE=$SRC/.hix-flake
args+=("path:$FLAKE" --override-input src "$SRC")
fi
# Make a temporary flake if we have not already
mkdir -p $FLAKE
HIX_FLAKE="$(mktemp -d)/flake.nix"
sed 's|EVAL_SYSTEM|${pkgs.stdenv.hostPlatform.system}|' < ${hixProject}/flake.nix > $HIX_FLAKE
if ! cmp $HIX_FLAKE $FLAKE/flake.nix &>/dev/null; then
if [ -e $FLAKE/flake.lock ]; then
echo "Updating $FLAKE/flake.nix and deleting old $FLAKE/flake.lock"
rm $FLAKE/flake.lock
else
echo "Updating $FLAKE/flake.nix"
fi
cp $HIX_FLAKE $FLAKE/flake.nix
chmod +w $FLAKE/flake.nix
fi
nix $cmd "''${args[@]}"
;;
Expand Down
11 changes: 5 additions & 6 deletions overlays/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,10 @@ final: prev: {

# `project'` and `project` automatically select between `cabalProject`
# and `stackProject` (when possible) by looking for `stack.yaml` or
# `cabal.project` files. If both exist we can pass in one of:
# `cabal.project` files. If both exist it uses the `cabal.project` file.
# To override this pass in:
# `projectFileName = "stack.yaml;"`
# `projectFileName = "cabal.project";`
# to let it know which to choose (or pick another name). If the
# selected file ends in a `.yaml` it is assumed to be for `stackProject`.
# If the selected file ends in a `.yaml` it is assumed to be for `stackProject`.
# If neither `stack.yaml` nor `cabal.project` exist `cabalProject` is
# used (as it will use a default `cabal.project`).
project' = projectModule:
Expand All @@ -829,8 +828,8 @@ final: prev: {
then projectFileName # Prefer the user selected project file name
else
if stackYamlExists && cabalProjectExists
then throw ("haskell-nix.project : both `stack.yaml` and `cabal.project` files exist "
+ "set `projectFileName = \"stack.yaml\";` or `projectFileName = \"cabal.project\";`")
then __trace ("haskell-nix.project : both `stack.yaml` and `cabal.project` files exist. Using `cabal.project`. "
+ "set `projectFileName = \"stack.yaml\";` to override this.`") "cabal.project"
else
if stackYamlExists
then "stack.yaml" # stack needs a stack.yaml
Expand Down