Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
677155bb9a | |||
fade7e4ab4 | |||
04e521ff87 |
@ -3,72 +3,79 @@
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
}: let
|
||||
testDriver = hostPkgs.python3.pkgs.callPackage ./package.nix {
|
||||
inherit (config) extraPythonPackages;
|
||||
inherit (hostPkgs.pkgs) util-linux systemd;
|
||||
};
|
||||
containers = map (m: m.system.build.toplevel) (lib.attrValues config.nodes);
|
||||
pythonizeName =
|
||||
name:
|
||||
let
|
||||
head = lib.substring 0 1 name;
|
||||
tail = lib.substring 1 (-1) name;
|
||||
in
|
||||
(if builtins.match "[A-z_]" head == null then "_" else head)
|
||||
+ lib.stringAsChars (c: if builtins.match "[A-z0-9_]" c == null then "_" else c) tail;
|
||||
nodeHostNames =
|
||||
let
|
||||
nodesList = map (c: c.system.name) (lib.attrValues config.nodes);
|
||||
in
|
||||
pythonizeName = name: let
|
||||
head = lib.substring 0 1 name;
|
||||
tail = lib.substring 1 (-1) name;
|
||||
in
|
||||
(
|
||||
if builtins.match "[A-z_]" head == null
|
||||
then "_"
|
||||
else head
|
||||
)
|
||||
+ lib.stringAsChars (c:
|
||||
if builtins.match "[A-z0-9_]" c == null
|
||||
then "_"
|
||||
else c)
|
||||
tail;
|
||||
nodeHostNames = let
|
||||
nodesList = map (c: c.system.name) (lib.attrValues config.nodes);
|
||||
in
|
||||
nodesList ++ lib.optional (lib.length nodesList == 1 && !lib.elem "machine" nodesList) "machine";
|
||||
machineNames = map (name: "${name}: Machine;") pythonizedNames;
|
||||
pythonizedNames = map pythonizeName nodeHostNames;
|
||||
in
|
||||
{
|
||||
in {
|
||||
driver = lib.mkForce (
|
||||
hostPkgs.runCommand "nixos-test-driver-${config.name}"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
{
|
||||
nativeBuildInputs =
|
||||
[
|
||||
hostPkgs.makeWrapper
|
||||
] ++ lib.optionals (!config.skipTypeCheck) [ hostPkgs.mypy ];
|
||||
buildInputs = [ testDriver ];
|
||||
testScript = config.testScriptString;
|
||||
preferLocalBuild = true;
|
||||
passthru = config.passthru;
|
||||
meta = config.meta // {
|
||||
]
|
||||
++ lib.optionals (!config.skipTypeCheck) [hostPkgs.mypy];
|
||||
buildInputs = [testDriver];
|
||||
testScript = config.testScriptString;
|
||||
preferLocalBuild = true;
|
||||
passthru = config.passthru;
|
||||
meta =
|
||||
config.meta
|
||||
// {
|
||||
mainProgram = "nixos-test-driver";
|
||||
};
|
||||
}
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
}
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
|
||||
containers=(${toString containers})
|
||||
containers=(${toString containers})
|
||||
|
||||
${lib.optionalString (!config.skipTypeCheck) ''
|
||||
# prepend type hints so the test script can be type checked with mypy
|
||||
cat "${./test-script-prepend.py}" >> testScriptWithTypes
|
||||
echo "${builtins.toString machineNames}" >> testScriptWithTypes
|
||||
echo -n "$testScript" >> testScriptWithTypes
|
||||
${lib.optionalString (!config.skipTypeCheck) ''
|
||||
# prepend type hints so the test script can be type checked with mypy
|
||||
cat "${./test-script-prepend.py}" >> testScriptWithTypes
|
||||
echo "${builtins.toString machineNames}" >> testScriptWithTypes
|
||||
echo -n "$testScript" >> testScriptWithTypes
|
||||
|
||||
echo "Running type check (enable/disable: config.skipTypeCheck)"
|
||||
echo "See https://nixos.org/manual/nixos/stable/#test-opt-skipTypeCheck"
|
||||
echo "Running type check (enable/disable: config.skipTypeCheck)"
|
||||
echo "See https://nixos.org/manual/nixos/stable/#test-opt-skipTypeCheck"
|
||||
|
||||
mypy --no-implicit-optional \
|
||||
--pretty \
|
||||
--no-color-output \
|
||||
testScriptWithTypes
|
||||
''}
|
||||
mypy --no-implicit-optional \
|
||||
--pretty \
|
||||
--no-color-output \
|
||||
testScriptWithTypes
|
||||
''}
|
||||
|
||||
echo -n "$testScript" >> $out/test-script
|
||||
echo -n "$testScript" >> $out/test-script
|
||||
|
||||
ln -s ${testDriver}/bin/nixos-test-driver $out/bin/nixos-test-driver
|
||||
ln -s ${testDriver}/bin/nixos-test-driver $out/bin/nixos-test-driver
|
||||
|
||||
wrapProgram $out/bin/nixos-test-driver \
|
||||
${lib.concatStringsSep " " (map (name: "--add-flags '--container ${name}'") containers)} \
|
||||
--add-flags "--test-script '$out/test-script'"
|
||||
''
|
||||
wrapProgram $out/bin/nixos-test-driver \
|
||||
${lib.concatStringsSep " " (map (name: "--add-flags '--container ${name}'") containers)} \
|
||||
--add-flags "--test-script '$out/test-script'"
|
||||
''
|
||||
);
|
||||
|
||||
test = lib.mkForce (
|
||||
@ -77,7 +84,9 @@ in
|
||||
derivation = hostPkgs.stdenv.mkDerivation {
|
||||
name = "vm-test-run-${config.name}";
|
||||
|
||||
requiredSystemFeatures = [ "uid-range" ];
|
||||
# error: feature 'uid-range' requires the setting 'auto-allocate-uids' to be enabled
|
||||
requiredSystemFeatures = ["uid-range"];
|
||||
#auto-allocate-uids.enable = true;
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
|
@ -1,6 +1,9 @@
|
||||
{ config, lib, ... }:
|
||||
{
|
||||
options.clan.disk-layouts.singleDiskExt4 = {
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
options.disko.devices.disk.main = {
|
||||
device = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "/dev/disk/by-id/ata-Samsung_SSD_850_EVO_250GB_S21PNXAGB12345";
|
||||
@ -13,7 +16,7 @@
|
||||
disk = {
|
||||
main = {
|
||||
type = "disk";
|
||||
device = config.clan.disk-layouts.singleDiskExt4.device;
|
||||
device = config.disko.devices.disk.main.device;
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
|
@ -1,9 +1,8 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
{inputs, ...}: {
|
||||
flake.clanModules = {
|
||||
disk-layouts = {
|
||||
imports = [
|
||||
./disk-layouts
|
||||
# ./disk-layouts
|
||||
inputs.disko.nixosModules.default
|
||||
];
|
||||
};
|
||||
|
4
sops/users/lgo/key.json
Executable file
4
sops/users/lgo/key.json
Executable file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"publickey": "age1zs3553f02lxdgpdvfwv7pm4q4qpgq5ztc5vqakaehatj624g29nsqpz754",
|
||||
"type": "age"
|
||||
}
|
Loading…
Reference in New Issue
Block a user