significantly improve purity

This commit is contained in:
Qyriad 2026-02-09 14:32:56 +01:00
parent 45a7d43f77
commit 68e9b9a1e4
12 changed files with 139 additions and 230 deletions

View file

@ -5,5 +5,5 @@
set -euo pipefail
mkdir -vp "$out/share/nixos"
cp -rv ${./configuration.nix} "$out/share/nixos/configuration.nix"
cp -rv ${../../modules/dynamicism} "$out/share/nixos/dynamicism"
#cp -rv ${../../modules/dynamicism} "$out/share/nixos/dynamicism"
''

View file

@ -1,22 +1,18 @@
{ pkgs, lib, config, modulesPath, ... }:
let
name = config.networking.hostName;
nixosLibPath = (modulesPath + "/../lib");
moduleList = import (modulesPath + "/module-list.nix");
optionalPath = p: lib.optional (builtins.pathExists p) p;
dynixFromSearchPath = let
res = builtins.tryEval <dynix>;
in lib.optional res.success res.value;
in
assert builtins.pathExists nixosLibPath;
builtins.seq lib
builtins.seq modulesPath
builtins.seq moduleList
{
imports = moduleList ++ [
(modulesPath + "/testing/test-instrumentation.nix")
"${modulesPath}/testing/test-instrumentation.nix"
./hardware-configuration.nix
] ++ lib.concatLists [
(optionalPath ./hardware-configuration.nix)
(optionalPath ./dynamicism)
(optionalPath ../../modules/dynamicism)
dynixFromSearchPath
];
system.switch.enable = true;
@ -32,13 +28,18 @@ builtins.seq moduleList
nix = {
package = pkgs.lixPackageSets.latest.lix;
nixPath = [ "nixpkgs=${pkgs.path}" ];
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;
};
};
@ -54,6 +55,7 @@ builtins.seq moduleList
dynamicism.for.gotosocial.enable = true;
environment.pathsToLink = [ "/share" ];
environment.extraOutputsToInstall = [ "modules" ];
environment.variables = {
"NIXOS_CONFIG" = "/etc/nixos/configuration.nix";
};

View file

@ -0,0 +1,7 @@
/** Dummy hardware configuration.
* Will be replaced with the real one in the test VM.
*/
{ ... }:
{
}

View file

@ -52,11 +52,17 @@ def get_config_file() -> str:
machine.wait_for_unit("default.target")
assert "lix" in machine.succeed("nix --version").lower()
machine.log("INIT")
run_log(machine, "nixos-generate-config")
machine.succeed("nix profile install -vv $(realpath /run/current-system/sw/share/nixos/modules/dynix)")
machine.succeed("nixos-generate-config")
machine.succeed("mkdir -vp /etc/nixos")
machine.succeed("cp -rv /run/current-system/sw/share/nixos/* /etc/nixos/")
machine.succeed("env PAGER= nixos-rebuild switch --log-format raw-with-logs -v --fallback >&2")
# 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.log("REBUILDING configuration inside VM")
machine.succeed("env PAGER= nixos-rebuild switch --log-format raw-with-logs --fallback")
config_text = get_config_file()
lines = config_text.splitlines()

View file

@ -1,22 +1,23 @@
{
pkgs,
lib,
config,
...
}:
{ dynix, ... }:
{
name = "nixos-test-dynamicism-main";
defaults = { ... }: { };
#node.pkgsReadOnly = false;
extraPythonPackages = p: [
p.beartype
];
nodes.machine = { pkgs, config, ... }: {
imports = [ ./configuration.nix ];
# NOTE: Anything in this `nodes.machine = ` module will not be included
# in the VM's NixOS configuration once it does `nixos-rebuild switch`,
# except for `./configuration.nix` which will be copied to `/etc/nixos/`.
# dynix will also be statefully installed to root's user profile.
imports = [
./configuration.nix
(toString dynix)
];
system.includeBuildDependencies = true;
system.switch.enable = true;

View file

@ -1,8 +1,31 @@
{
pkgs ? import <nixpkgs> { },
lib ? pkgs.lib,
}: lib.makeScope lib.callPackageWith (self: let
inherit (pkgs.testers) runNixOSTest;
in {
basic = runNixOSTest ./basic/test.nix;
qpkgs ? let
src = fetchTree (builtins.parseFlakeRef "github:Qyriad/nur-packages");
in import src { inherit pkgs; },
lib ? qpkgs.lib,
dynix ? qpkgs.callPackage ../modules-package.nix { },
}: let
runDynixTest = testModule: pkgs.testers.runNixOSTest {
imports = [ testModule ];
# Note: these are arguments to the *test* modules.
# Not the NixOS modules for the NixOS configuration the test is testing.
# Wew.
_module.args = { inherit dynix; };
# Why is this argument called "extraBaseModule**s**" but take a single module argument...
extraBaseModules = { name, ... }: {
#imports = [ dynixInjectionModule ];
config.environment.systemPackages = [ dynix ];
# Just making something in this strict in `name`,
# which is only present as an argument for nodes and I don't want to
# confuse that with the test modules.
config.warnings = builtins.seq name [ ];
};
};
in lib.makeScope lib.callPackageWith (self: {
basic = runDynixTest ./basic/test.nix;
})