This commit is contained in:
phaer 2024-09-05 11:43:41 +02:00
parent 7c60ba4bc8
commit 409f3e6e38
7 changed files with 43 additions and 33 deletions

View File

@ -30,25 +30,27 @@
allConfigs = lib.mapAttrs (formatName: evalFormat) config.formatConfigs;
# adds an evaluated `config` to the derivation attributes of a format for introspection
exposeConfig = conf: output: output.overrideAttrs (old: {
passthru.config = conf.config;
});
exposeConfig = conf: output:
output.overrideAttrs (old: {
passthru.config = conf.config;
});
# attrset of formats to be exposed under config.system.formats
formats = lib.flip lib.mapAttrs allConfigs (
formatName: conf: exposeConfig conf (
pkgs.runCommand "${conf.config.system.build.${conf.config.formatAttr}.name}" {} ''
set -efu
target=$(find '${conf.config.system.build.${conf.config.formatAttr}}' -name '*${conf.config.fileExtension}' -xtype f -print -quit)
if [ -z "$target" ]; then
echo "No target file found for ${conf.config.formatAttr} format"
echo "Check the content of this build path: ${conf.config.system.build.${conf.config.formatAttr}}"
exit 1
fi
mkdir $out
ln -s "$target" "$out/$(basename "$target")"
''
)
formatName: conf:
exposeConfig conf (
pkgs.runCommand "${conf.config.system.build.${conf.config.formatAttr}.name}" {} ''
set -efu
target=$(find '${conf.config.system.build.${conf.config.formatAttr}}' -name '*${conf.config.fileExtension}' -xtype f -print -quit)
if [ -z "$target" ]; then
echo "No target file found for ${conf.config.formatAttr} format"
echo "Check the content of this build path: ${conf.config.system.build.${conf.config.formatAttr}}"
exit 1
fi
mkdir $out
ln -s "$target" "$out/$(basename "$target")"
''
)
);
in {
_file = ./all-formats.nix;

View File

@ -1,7 +1,4 @@
{
lib,
...
}: {
{lib, ...}: {
services.sshd.enable = true;
services.nginx.enable = true;

View File

@ -11,7 +11,8 @@ in {
];
hyperv.baseImageSize =
if diskSize == "auto" then "auto"
if diskSize == "auto"
then "auto"
else lib.strings.toIntBase10 diskSize;
formatAttr = "hypervImage";

View File

@ -13,7 +13,7 @@ in {
];
system.build = rec {
image = pkgs.runCommand "image" { buildInputs = [ pkgs.nukeReferences ]; } ''
image = pkgs.runCommand "image" {buildInputs = [pkgs.nukeReferences];} ''
mkdir $out
cp ${config.system.build.kernel}/${config.system.boot.loader.kernelFile} $out/kernel
cp ${config.system.build.netbootRamdisk}/initrd $out/initrd
@ -44,7 +44,7 @@ in {
sync
echo "executing kernel, filesystems will be improperly umounted"
kexec -e
'';
'';
};
kexec_tarball = maybe.mkForce (pkgs.callPackage "${toString modulesPath}/../lib/make-system-tarball.nix" {

View File

@ -1,4 +1,8 @@
{lib, modulesPath, ...}: {
{
lib,
modulesPath,
...
}: {
imports = [
"${toString modulesPath}/virtualisation/proxmox-lxc.nix"
];

View File

@ -1,5 +1,10 @@
{ config, lib, pkgs, modulesPath, ... }:
{
config,
lib,
pkgs,
modulesPath,
...
}: {
# for virtio kernel drivers
imports = [
"${toString modulesPath}/profiles/qemu-guest.nix"
@ -8,17 +13,18 @@
options = {
boot = {
consoles = lib.mkOption {
default = [ "ttyS0" ] ++
(lib.optional (pkgs.stdenv.hostPlatform.isAarch) "ttyAMA0,115200") ++
(lib.optional (pkgs.stdenv.hostPlatform.isRiscV64) "ttySIF0,115200");
default =
["ttyS0"]
++ (lib.optional (pkgs.stdenv.hostPlatform.isAarch) "ttyAMA0,115200")
++ (lib.optional (pkgs.stdenv.hostPlatform.isRiscV64) "ttySIF0,115200");
description = "Kernel console boot flags to pass to boot.kernelParams";
example = [ "ttyS2,115200" ];
example = ["ttyS2,115200"];
};
diskSize = lib.mkOption {
default = "auto";
description = "The disk size in megabytes of the system disk image.";
type = with lib.types; oneOf [ ints.positive (enum [ "auto" ])];
type = with lib.types; oneOf [ints.positive (enum ["auto"])];
};
};
};
@ -54,4 +60,3 @@
fileExtension = ".qcow2";
};
}

View File

@ -11,7 +11,8 @@ in {
];
vmware.baseImageSize =
if diskSize == "auto" then "auto"
if diskSize == "auto"
then "auto"
else lib.strings.toIntBase10 diskSize;
formatAttr = "vmwareImage";