mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-30 10:53:11 +00:00
4a9d9928dc
The `nix.*` options, apart from options for setting up the daemon itself, currently provide a lot of setting mappings for the Nix daemon configuration. The scope of the mapping yields convience, but the line where an option is considered essential is blurry. For instance, the `extra-sandbox-paths` mapping is provided without its primary consumer, and the corresponding `sandbox-paths` option is also not mapped. The current system increases the maintenance burden as maintainers have to closely follow upstream changes. In this case, there are two state versions of Nix which have to be maintained collectively, with different options avaliable. This commit aims to following the standard outlined in RFC 42[1] to implement a structural setting pattern. The Nix configuration is encoded at its core as key-value pairs which maps nicely to attribute sets, making it feasible to express in the Nix language itself. Some existing options are kept such as `buildMachines` and `registry` which present a simplified interface to managing the respective settings. The interface is exposed as `nix.settings`. Legacy configurations are mapped to their corresponding options under `nix.settings` for backwards compatibility. Various options settings in other nixos modules and relevant tests have been updated to use structural setting for consistency. The generation and validation of the configration file has been modified to use `writeTextFile` instead of `runCommand` for clarity. Note that validation is now mandatory as strict checking of options has been pushed down to the derivation level due to freeformType consuming unmatched options. Furthermore, validation can not occur when cross-compiling due to current limitations. A new option `publicHostKey` was added to the `buildMachines` submodule corresponding to the base64 encoded public host key settings exposed in the builder syntax. The build machine generation was subsequently rewritten to use `concatStringsSep` for better performance by grouping concatenations. [1] - https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md
162 lines
5.3 KiB
Nix
162 lines
5.3 KiB
Nix
import ./make-test-python.nix (
|
|
{ pkgs, lib, ... }:
|
|
let
|
|
initiatorName = "iqn.2020-08.org.linux-iscsi.initiatorhost:example";
|
|
targetName = "iqn.2003-01.org.linux-iscsi.target.x8664:sn.acf8fd9c23af";
|
|
in
|
|
{
|
|
name = "iscsi";
|
|
meta = {
|
|
maintainers = pkgs.lib.teams.deshaw.members
|
|
++ (with pkgs.lib.maintainers; [ ajs124 ]);
|
|
};
|
|
|
|
nodes = {
|
|
target = { config, pkgs, lib, ... }: {
|
|
services.target = {
|
|
enable = true;
|
|
config = {
|
|
fabric_modules = [];
|
|
storage_objects = [
|
|
{
|
|
dev = "/dev/vdb";
|
|
name = "test";
|
|
plugin = "block";
|
|
write_back = true;
|
|
wwn = "92b17c3f-6b40-4168-b082-ceeb7b495522";
|
|
}
|
|
];
|
|
targets = [
|
|
{
|
|
fabric = "iscsi";
|
|
tpgs = [
|
|
{
|
|
enable = true;
|
|
attributes = {
|
|
authentication = 0;
|
|
generate_node_acls = 1;
|
|
};
|
|
luns = [
|
|
{
|
|
alias = "94dfe06967";
|
|
alua_tg_pt_gp_name = "default_tg_pt_gp";
|
|
index = 0;
|
|
storage_object = "/backstores/block/test";
|
|
}
|
|
];
|
|
node_acls = [
|
|
{
|
|
mapped_luns = [
|
|
{
|
|
alias = "d42f5bdf8a";
|
|
index = 0;
|
|
tpg_lun = 0;
|
|
write_protect = false;
|
|
}
|
|
];
|
|
node_wwn = initiatorName;
|
|
}
|
|
];
|
|
portals = [
|
|
{
|
|
ip_address = "0.0.0.0";
|
|
iser = false;
|
|
offload = false;
|
|
port = 3260;
|
|
}
|
|
];
|
|
tag = 1;
|
|
}
|
|
];
|
|
wwn = targetName;
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
networking.firewall.allowedTCPPorts = [ 3260 ];
|
|
networking.firewall.allowedUDPPorts = [ 3260 ];
|
|
|
|
virtualisation.memorySize = 2048;
|
|
virtualisation.emptyDiskImages = [ 2048 ];
|
|
};
|
|
|
|
initiatorAuto = { nodes, config, pkgs, ... }: {
|
|
services.openiscsi = {
|
|
enable = true;
|
|
enableAutoLoginOut = true;
|
|
discoverPortal = "target";
|
|
name = initiatorName;
|
|
};
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
xfsprogs
|
|
];
|
|
|
|
system.extraDependencies = [ nodes.initiatorRootDisk.config.system.build.toplevel ];
|
|
|
|
nix.settings = {
|
|
substituters = lib.mkForce [];
|
|
hashed-mirrors = null;
|
|
connect-timeout = 1;
|
|
};
|
|
};
|
|
|
|
initiatorRootDisk = { config, pkgs, modulesPath, lib, ... }: {
|
|
boot.loader.grub.enable = false;
|
|
boot.kernelParams = lib.mkOverride 5 (
|
|
[
|
|
"boot.shell_on_fail"
|
|
"console=tty1"
|
|
"ip=${config.networking.primaryIPAddress}:::255.255.255.0::ens9:none"
|
|
]
|
|
);
|
|
|
|
# defaults to true, puts some code in the initrd that tries to mount an overlayfs on /nix/store
|
|
virtualisation.writableStore = false;
|
|
|
|
fileSystems = lib.mkOverride 5 {
|
|
"/" = {
|
|
fsType = "xfs";
|
|
device = "/dev/sda";
|
|
options = [ "_netdev" ];
|
|
};
|
|
};
|
|
|
|
boot.iscsi-initiator = {
|
|
discoverPortal = "target";
|
|
name = initiatorName;
|
|
target = targetName;
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript = { nodes, ... }: ''
|
|
target.start()
|
|
target.wait_for_unit("iscsi-target.service")
|
|
|
|
initiatorAuto.start()
|
|
|
|
initiatorAuto.wait_for_unit("iscsid.service")
|
|
initiatorAuto.wait_for_unit("iscsi.service")
|
|
initiatorAuto.get_unit_info("iscsi")
|
|
|
|
initiatorAuto.succeed("set -x; while ! test -e /dev/sda; do sleep 1; done")
|
|
|
|
initiatorAuto.succeed("mkfs.xfs /dev/sda")
|
|
initiatorAuto.succeed("mkdir /mnt && mount /dev/sda /mnt")
|
|
initiatorAuto.succeed(
|
|
"nixos-install --no-bootloader --no-root-passwd --system ${nodes.initiatorRootDisk.config.system.build.toplevel}"
|
|
)
|
|
initiatorAuto.succeed("umount /mnt && rmdir /mnt")
|
|
initiatorAuto.shutdown()
|
|
|
|
initiatorRootDisk.start()
|
|
initiatorRootDisk.wait_for_unit("multi-user.target")
|
|
initiatorRootDisk.wait_for_unit("iscsid")
|
|
initiatorRootDisk.succeed("touch test")
|
|
initiatorRootDisk.shutdown()
|
|
'';
|
|
}
|
|
)
|