fix unlocked flake.lock in tests
This commit is contained in:
@@ -158,14 +158,26 @@ in
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
# the test's flake.nix with locked clan-core input
|
# the test's flake.nix with locked clan-core input
|
||||||
flakeForSandbox = hostPkgs.runCommand "offline-flake-for-test-${config.name}" { } ''
|
flakeForSandbox =
|
||||||
cp -r ${config.clan.directory} $out
|
hostPkgs.runCommand "offline-flake-for-test-${config.name}"
|
||||||
chmod +w -R $out
|
{
|
||||||
substituteInPlace $out/flake.nix \
|
nativeBuildInputs = [ hostPkgs.nix ];
|
||||||
--replace-fail \
|
}
|
||||||
"https://git.clan.lol/clan/clan-core/archive/main.tar.gz" \
|
''
|
||||||
"${clan-core.packages.${hostPkgs.system}.clan-core-flake}"
|
cp -r ${config.clan.directory} $out
|
||||||
'';
|
chmod +w -R $out
|
||||||
|
substituteInPlace $out/flake.nix \
|
||||||
|
--replace-fail \
|
||||||
|
"https://git.clan.lol/clan/clan-core/archive/main.tar.gz" \
|
||||||
|
"${clan-core.packages.${hostPkgs.system}.clan-core-flake}"
|
||||||
|
|
||||||
|
# Create a proper lock file for the test flake
|
||||||
|
export HOME=$(mktemp -d)
|
||||||
|
nix flake lock $out \
|
||||||
|
--extra-experimental-features 'nix-command flakes' \
|
||||||
|
--override-input clan-core ${clan-core.packages.${hostPkgs.system}.clan-core-flake} \
|
||||||
|
--override-input nixpkgs ${clan-core.inputs.nixpkgs}
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from clan_cli.tests import age_keys
|
|||||||
from clan_cli.tests.fixture_error import FixtureError
|
from clan_cli.tests.fixture_error import FixtureError
|
||||||
from clan_cli.tests.root import CLAN_CORE
|
from clan_cli.tests.root import CLAN_CORE
|
||||||
from clan_cli.tests.temporary_dir import TEMPDIR
|
from clan_cli.tests.temporary_dir import TEMPDIR
|
||||||
|
from clan_lib import cmd
|
||||||
from clan_lib.dirs import (
|
from clan_lib.dirs import (
|
||||||
TemplateType,
|
TemplateType,
|
||||||
clan_templates,
|
clan_templates,
|
||||||
@@ -23,7 +24,7 @@ from clan_lib.dirs import (
|
|||||||
from clan_lib.flake import Flake
|
from clan_lib.flake import Flake
|
||||||
from clan_lib.locked_open import locked_open
|
from clan_lib.locked_open import locked_open
|
||||||
from clan_lib.machines.machines import Machine
|
from clan_lib.machines.machines import Machine
|
||||||
from clan_lib.nix import nix_test_store
|
from clan_lib.nix import nix_command, nix_test_store
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -86,6 +87,11 @@ def substitute(
|
|||||||
print(f"flake: {flake}")
|
print(f"flake: {flake}")
|
||||||
file.write_text(buf)
|
file.write_text(buf)
|
||||||
|
|
||||||
|
# Lock the flake after substitution if clan_core was replaced
|
||||||
|
if clan_core_flake:
|
||||||
|
flake_dir = file.parent
|
||||||
|
cmd.run(nix_command(["flake", "lock"]), cmd.RunOpts(cwd=flake_dir))
|
||||||
|
|
||||||
|
|
||||||
class FlakeForTest(NamedTuple):
|
class FlakeForTest(NamedTuple):
|
||||||
path: Path
|
path: Path
|
||||||
|
|||||||
Reference in New Issue
Block a user