working on harmonia
This commit is contained in:
parent
1f466b63d3
commit
8dba8e7ce8
20 changed files with 556 additions and 90 deletions
67
tests/tzupdate/configuration.nix
Normal file
67
tests/tzupdate/configuration.nix
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{ pkgs, lib, config, modulesPath, ... }:
|
||||
let
|
||||
name = config.networking.hostName;
|
||||
moduleList = import "${modulesPath}/module-list.nix";
|
||||
|
||||
dynixFromSearchPath = let
|
||||
res = builtins.tryEval <dynix>;
|
||||
in lib.optional res.success res.value;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
"${modulesPath}/testing/test-instrumentation.nix"
|
||||
./hardware-configuration.nix
|
||||
] ++ lib.concatLists [
|
||||
moduleList
|
||||
dynixFromSearchPath
|
||||
];
|
||||
|
||||
dynamicism.for.tzupdate.enable = true;
|
||||
services.tzupdate = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
system.switch.enable = true;
|
||||
documentation.enable = false;
|
||||
|
||||
networking.hostName = "tzupdate-machine";
|
||||
|
||||
boot.loader.grub = {
|
||||
enable = true;
|
||||
device = "/dev/vda";
|
||||
forceInstall = true;
|
||||
};
|
||||
|
||||
nix = {
|
||||
package = pkgs.lixPackageSets.latest.lix;
|
||||
nixPath = [
|
||||
"nixpkgs=${pkgs.path}"
|
||||
"/nix/var/nix/profiles/per-user/root/profile/share/nixos/modules"
|
||||
];
|
||||
|
||||
settings = {
|
||||
experimental-features = [ "nix-command" "pipe-operator" ];
|
||||
substituters = lib.mkForce [ ];
|
||||
hashed-mirrors = null;
|
||||
connect-timeout = 1;
|
||||
# For my debugging purposes.
|
||||
show-trace = true;
|
||||
};
|
||||
};
|
||||
|
||||
environment.pathsToLink = [ "/share" ];
|
||||
environment.extraOutputsToInstall = [ "modules" ];
|
||||
environment.variables = {
|
||||
"NIXOS_CONFIG" = "/etc/nixos/configuration.nix";
|
||||
};
|
||||
|
||||
environment.shellAliases = {
|
||||
ls = "eza --long --header --group --group-directories-first --classify --binary";
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
eza
|
||||
fd
|
||||
ripgrep
|
||||
];
|
||||
}
|
||||
4
tests/tzupdate/hardware-configuration.nix
Normal file
4
tests/tzupdate/hardware-configuration.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{ ... }:
|
||||
{
|
||||
|
||||
}
|
||||
52
tests/tzupdate/test-script.py
Normal file
52
tests/tzupdate/test-script.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#from pathlib import Path
|
||||
#import shlex
|
||||
#import textwrap
|
||||
from typing import cast, TYPE_CHECKING
|
||||
|
||||
from beartype import beartype
|
||||
|
||||
from test_driver.machine import Machine
|
||||
from test_driver.errors import RequestedAssertionFailed
|
||||
|
||||
if TYPE_CHECKING:
|
||||
global machine
|
||||
machine = cast(Machine, ...)
|
||||
assert machine.shell is not None
|
||||
|
||||
ls = "eza -lah --color=always --group-directories-first"
|
||||
|
||||
@beartype
|
||||
def run_log(machine: Machine, *commands: str, timeout: int | None = 60) -> str:
|
||||
output = ""
|
||||
for command in commands:
|
||||
with machine.nested(f"must succeed: {command}"):
|
||||
(status, out) = machine.execute(f"{command} | tee /dev/stderr", timeout=timeout)
|
||||
if status != 0:
|
||||
machine.log(f"output: {out}")
|
||||
raise RequestedAssertionFailed(
|
||||
f"command `{command}` failed (exit code {status})",
|
||||
)
|
||||
output += out
|
||||
|
||||
return output
|
||||
|
||||
machine.wait_for_unit("default.target")
|
||||
assert "lix" in machine.succeed("nix --version").lower()
|
||||
machine.log("INIT")
|
||||
|
||||
|
||||
machine.succeed("nixos-generate-config")
|
||||
machine.succeed("mkdir -vp /etc/nixos")
|
||||
# Dereference is required since that configuration.nix is probably a symlink to the store.
|
||||
machine.succeed("cp -rv --dereference /run/current-system/sw/share/nixos/configuration.nix /etc/nixos/")
|
||||
|
||||
machine.succeed("env PAGER= nixos-rebuild switch --log-format raw-with-logs --fallback")
|
||||
|
||||
@beartype
|
||||
def get_interval() -> str:
|
||||
prop = machine.get_unit_property("tzupdate.timer", "OnCalendar")
|
||||
print(f"{prop=}")
|
||||
|
||||
return prop
|
||||
|
||||
get_interval()
|
||||
24
tests/tzupdate/test.nix
Normal file
24
tests/tzupdate/test.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
name = "nixos-test-dynamicism-tzupdate";
|
||||
|
||||
extraPythonPackages = p: [
|
||||
p.beartype
|
||||
];
|
||||
|
||||
nodes.machine = { name, pkgs, ... }: {
|
||||
imports = [ ./configuration.nix ];
|
||||
|
||||
environment.systemPackages = let
|
||||
configFileTree = pkgs.runCommand "${name}-configuration-dot-nix" { } ''
|
||||
set -euo pipefail
|
||||
install -Dm a=r ${./configuration.nix} "$out/share/nixos/configuration.nix"
|
||||
'';
|
||||
in [
|
||||
configFileTree
|
||||
];
|
||||
};
|
||||
|
||||
testScript = builtins.readFile ./test-script.py;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue