From 899ed6576d954080ffa4bc81746c21474736e9ff Mon Sep 17 00:00:00 2001 From: Torsten Schmits Date: Sun, 24 Sep 2023 15:14:11 +0200 Subject: [PATCH] run gen-cabal after git-adding flake.* in bootstrap --- lib/with-config.nix | 10 ++++++---- local.nix | 2 ++ test/bootstrap/test.nix | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/with-config.nix b/lib/with-config.nix index 6cc5e70a..ac39fe91 100644 --- a/lib/with-config.nix +++ b/lib/with-config.nix @@ -94,11 +94,11 @@ let chmod +x $exe ''; - bootstrapWithStaticCli = name: script: pkgs.writeScript name '' + bootstrapWithStaticCli = name: pre: post: pkgs.writeScript name '' #!${pkgs.bashInteractive}/bin/bash set -e ${downloadStaticCli} - ${script} + ${pre} if ! git status &>/dev/null then ${pkgs.git}/bin/git init @@ -106,13 +106,14 @@ let ${pkgs.git}/bin/git add . ${pkgs.nix}/bin/nix flake update ${pkgs.git}/bin/git add flake.lock + ${post} ''; - bootstrapWithDynamicCli = name: script: pkgs.writeScript name '' + bootstrapWithDynamicCli = name: pre: post: pkgs.writeScript name '' #!${pkgs.bashInteractive}/bin/bash set -e exe="${config.outputs.packages.hix}/bin/hix" - ${script} + ${pre} if ! git status &>/dev/null then ${pkgs.git}/bin/git init @@ -120,6 +121,7 @@ let ${pkgs.git}/bin/git add . ${pkgs.nix}/bin/nix flake update ${pkgs.git}/bin/git add flake.lock + ${post} ''; cacheWrapper = self: name: app: pkgs.writeScript name '' diff --git a/local.nix b/local.nix index 7a614dfe..40154025 100644 --- a/local.nix +++ b/local.nix @@ -109,6 +109,7 @@ hix.pro [({config, lib, ...}: { new-nocache = let prog = util.bootstrapWithDynamicCli "hix-new-nocache" '' $exe new --hix-url '${config.internal.hixUrl}' "$@" + '' '' nix run .#gen-cabal ''; in { @@ -126,6 +127,7 @@ hix.pro [({config, lib, ...}: { bootstrap-nocache = let prog = util.bootstrapWithDynamicCli "hix-bootstrap-nocache" '' $exe bootstrap --hix-url '${config.internal.hixUrl}' "$@" + '' '' nix run .#gen-cabal ''; in { diff --git a/test/bootstrap/test.nix b/test/bootstrap/test.nix index 41ad2a9d..63b3b3d5 100644 --- a/test/bootstrap/test.nix +++ b/test/bootstrap/test.nix @@ -1,8 +1,9 @@ -{ pkgs }: +{...}: { test = builtins.toFile "bootstrap-test" '' cd ./root - check_match 'nix run path:$hix_dir#bootstrap' 'Initialized' "Bootstrap command didn't initialize git repo" + git init + check_match 'nix run path:$hix_dir#bootstrap' 'generated red-panda-core' "Bootstrap command didn't generate cabal files" check_match 'nix run .#ghci -- -p red-panda -t main <<< :quit' 'success' 'Running tests in generated project failed' ''; }