Skip to content

Commit

Permalink
run gen-cabal after git-adding flake.* in bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
tek committed Sep 24, 2023
1 parent e1c7801 commit 899ed65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/with-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,34 @@ 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
fi
${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
fi
${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 ''
Expand Down
2 changes: 2 additions & 0 deletions local.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions test/bootstrap/test.nix
Original file line number Diff line number Diff line change
@@ -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'
'';
}

0 comments on commit 899ed65

Please sign in to comment.