Add a utility function for creating/registering a simple flake

This commit is contained in:
Eelco Dolstra 2024-11-20 18:51:23 +01:00
parent e1cb905aca
commit 4cafea7c7b
5 changed files with 14 additions and 25 deletions

View File

@ -4,15 +4,9 @@ source ./common.sh
TODO_NixOS TODO_NixOS
requireGit createFlake1
flake1Dir=$TEST_ROOT/flake1
lockfileSummaryFlake=$TEST_ROOT/lockfileSummaryFlake lockfileSummaryFlake=$TEST_ROOT/lockfileSummaryFlake
createGitRepo "$flake1Dir" ""
createSimpleGitFlake "$flake1Dir"
nix registry add --registry "$registry" flake1 "git+file://$flake1Dir"
createGitRepo "$lockfileSummaryFlake" "--initial-branch=main" createGitRepo "$lockfileSummaryFlake" "--initial-branch=main"
# Test that the --commit-lock-file-summary flag and its alias work # Test that the --commit-lock-file-summary flag and its alias work

View File

@ -38,12 +38,21 @@ EOF
} }
createSimpleGitFlake() { createSimpleGitFlake() {
requireGit
local flakeDir="$1" local flakeDir="$1"
writeSimpleFlake "$flakeDir" writeSimpleFlake "$flakeDir"
git -C "$flakeDir" add flake.nix simple.nix shell.nix simple.builder.sh config.nix git -C "$flakeDir" add flake.nix simple.nix shell.nix simple.builder.sh config.nix
git -C "$flakeDir" commit -m 'Initial' git -C "$flakeDir" commit -m 'Initial'
} }
# Create a simple Git flake and add it to the registry as "flake1".
createFlake1() {
flake1Dir="$TEST_ROOT/flake1"
createGitRepo "$flake1Dir" ""
createSimpleGitFlake "$flake1Dir"
nix registry add --registry "$registry" flake1 "git+file://$flake1Dir"
}
writeDependentFlake() { writeDependentFlake() {
local flakeDir="$1" local flakeDir="$1"
cat > "$flakeDir/flake.nix" <<EOF cat > "$flakeDir/flake.nix" <<EOF

View File

@ -2,11 +2,8 @@
source ./common.sh source ./common.sh
requireGit createFlake1
repoDir="$flake1Dir"
repoDir="$TEST_ROOT/repo"
createGitRepo "$repoDir"
createSimpleGitFlake "$repoDir"
# Check that a flakeref without a query is accepted correctly. # Check that a flakeref without a query is accepted correctly.
expectStderr 0 nix --offline build --dry-run "git+file://$repoDir#foo" expectStderr 0 nix --offline build --dry-run "git+file://$repoDir#foo"

View File

@ -2,12 +2,7 @@
source ./common.sh source ./common.sh
requireGit createFlake1
flake1Dir=$TEST_ROOT/flake1
createGitRepo "$flake1Dir"
createSimpleGitFlake "$flake1Dir"
export EDITOR=cat export EDITOR=cat
nix edit "$flake1Dir#" | grepQuiet simple.builder.sh nix edit "$flake1Dir#" | grepQuiet simple.builder.sh

View File

@ -4,15 +4,9 @@ source ./common.sh
TODO_NixOS TODO_NixOS
requireGit createFlake1
flake1Dir=$TEST_ROOT/flake1
scriptDir=$TEST_ROOT/nonFlake scriptDir=$TEST_ROOT/nonFlake
createGitRepo "$flake1Dir" ""
createSimpleGitFlake "$flake1Dir"
nix registry add --registry "$registry" flake1 "git+file://$flake1Dir"
mkdir -p "$scriptDir" mkdir -p "$scriptDir"
cat > "$scriptDir/shebang.sh" <<EOF cat > "$scriptDir/shebang.sh" <<EOF