flash: don't allow partitioning time secrets
This commit is contained in:
@@ -1,5 +1,25 @@
|
|||||||
{ self, ... }:
|
{ self, lib, ... }:
|
||||||
{
|
{
|
||||||
|
clan.machines.test-flash-machine = {
|
||||||
|
clan.core.networking.targetHost = "test-flash-machine";
|
||||||
|
fileSystems."/".device = lib.mkDefault "/dev/vda";
|
||||||
|
boot.loader.grub.device = lib.mkDefault "/dev/vda";
|
||||||
|
|
||||||
|
imports = [ self.nixosModules.test-flash-machine ];
|
||||||
|
};
|
||||||
|
|
||||||
|
flake.nixosModules = {
|
||||||
|
test-flash-machine =
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
imports = [ self.nixosModules.test-install-machine ];
|
||||||
|
|
||||||
|
clan.core.vars.generators.test = lib.mkForce { };
|
||||||
|
|
||||||
|
disko.devices.disk.main.preCreateHook = lib.mkForce "";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
perSystem =
|
perSystem =
|
||||||
{
|
{
|
||||||
nodes,
|
nodes,
|
||||||
@@ -10,19 +30,18 @@
|
|||||||
let
|
let
|
||||||
dependencies = [
|
dependencies = [
|
||||||
pkgs.disko
|
pkgs.disko
|
||||||
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine.pkgs.perlPackages.ConfigIniFiles
|
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-flash-machine.pkgs.perlPackages.ConfigIniFiles
|
||||||
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine.pkgs.perlPackages.FileSlurp
|
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-flash-machine.pkgs.perlPackages.FileSlurp
|
||||||
|
|
||||||
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine.config.system.build.toplevel
|
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-flash-machine.config.system.build.toplevel
|
||||||
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine.config.system.build.diskoScript
|
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-flash-machine.config.system.build.diskoScript
|
||||||
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine.config.system.build.diskoScript.drvPath
|
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-flash-machine.config.system.build.diskoScript.drvPath
|
||||||
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine.config.system.clan.deployment.file
|
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-flash-machine.config.system.clan.deployment.file
|
||||||
|
|
||||||
] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
|
] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
|
||||||
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Currently disabled...
|
|
||||||
checks = pkgs.lib.mkIf (pkgs.stdenv.isLinux) {
|
checks = pkgs.lib.mkIf (pkgs.stdenv.isLinux) {
|
||||||
flash = (import ../lib/test-base.nix) {
|
flash = (import ../lib/test-base.nix) {
|
||||||
name = "flash";
|
name = "flash";
|
||||||
@@ -46,7 +65,7 @@
|
|||||||
testScript = ''
|
testScript = ''
|
||||||
start_all()
|
start_all()
|
||||||
|
|
||||||
machine.succeed("clan flash write --debug --flake ${../..} --yes --disk main /dev/vdb test-install-machine")
|
machine.succeed("clan flash write --debug --flake ${../..} --yes --disk main /dev/vdb test-flash-machine")
|
||||||
'';
|
'';
|
||||||
} { inherit pkgs self; };
|
} { inherit pkgs self; };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from clan_cli.facts.generate import generate_facts
|
|||||||
from clan_cli.facts.secret_modules import SecretStoreBase
|
from clan_cli.facts.secret_modules import SecretStoreBase
|
||||||
from clan_cli.machines.machines import Machine
|
from clan_cli.machines.machines import Machine
|
||||||
from clan_cli.nix import nix_shell
|
from clan_cli.nix import nix_shell
|
||||||
from clan_cli.vars.generate import generate_vars_for_machine
|
from clan_cli.vars.generate import generate_vars
|
||||||
|
|
||||||
from .automount import pause_automounting
|
from .automount import pause_automounting
|
||||||
from .list import list_possible_keymaps, list_possible_languages
|
from .list import list_possible_keymaps, list_possible_languages
|
||||||
@@ -54,8 +54,8 @@ def flash_machine(
|
|||||||
extra_args = []
|
extra_args = []
|
||||||
system_config_nix: dict[str, Any] = {}
|
system_config_nix: dict[str, Any] = {}
|
||||||
|
|
||||||
generate_vars_for_machine(machine, generator_name=None, regenerate=False)
|
|
||||||
generate_facts([machine])
|
generate_facts([machine])
|
||||||
|
generate_vars([machine])
|
||||||
|
|
||||||
if system_config.language:
|
if system_config.language:
|
||||||
if system_config.language not in list_possible_languages():
|
if system_config.language not in list_possible_languages():
|
||||||
@@ -90,6 +90,12 @@ def flash_machine(
|
|||||||
"users": {"root": {"openssh": {"authorizedKeys": {"keys": root_keys}}}}
|
"users": {"root": {"openssh": {"authorizedKeys": {"keys": root_keys}}}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for generator in machine.vars_generators:
|
||||||
|
for file in generator.files:
|
||||||
|
if file.needed_for == "partitioning":
|
||||||
|
msg = f"Partitioning time secrets are not supported with `clan flash write`: clan.core.vars.generators.{generator.name}.files.{file.name}"
|
||||||
|
raise ClanError(msg)
|
||||||
|
|
||||||
secret_facts_module = importlib.import_module(machine.secret_facts_module)
|
secret_facts_module = importlib.import_module(machine.secret_facts_module)
|
||||||
secret_facts_store: SecretStoreBase = secret_facts_module.SecretStore(
|
secret_facts_store: SecretStoreBase = secret_facts_module.SecretStore(
|
||||||
machine=machine
|
machine=machine
|
||||||
|
|||||||
Reference in New Issue
Block a user