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
requireGit
createFlake1
flake1Dir=$TEST_ROOT/flake1
lockfileSummaryFlake=$TEST_ROOT/lockfileSummaryFlake
createGitRepo "$flake1Dir" ""
createSimpleGitFlake "$flake1Dir"
nix registry add --registry "$registry" flake1 "git+file://$flake1Dir"
createGitRepo "$lockfileSummaryFlake" "--initial-branch=main"
# Test that the --commit-lock-file-summary flag and its alias work

View File

@ -38,12 +38,21 @@ EOF
}
createSimpleGitFlake() {
requireGit
local flakeDir="$1"
writeSimpleFlake "$flakeDir"
git -C "$flakeDir" add flake.nix simple.nix shell.nix simple.builder.sh config.nix
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() {
local flakeDir="$1"
cat > "$flakeDir/flake.nix" <<EOF

View File

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

View File

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

View File

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