mirror of
https://github.com/nix-community/nixos-generators.git
synced 2024-11-22 01:52:05 +03:00
nix fmt
This commit is contained in:
parent
7c60ba4bc8
commit
409f3e6e38
@ -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;
|
||||
|
@ -1,7 +1,4 @@
|
||||
{
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
{lib, ...}: {
|
||||
services.sshd.enable = true;
|
||||
services.nginx.enable = true;
|
||||
|
||||
|
@ -11,7 +11,8 @@ in {
|
||||
];
|
||||
|
||||
hyperv.baseImageSize =
|
||||
if diskSize == "auto" then "auto"
|
||||
if diskSize == "auto"
|
||||
then "auto"
|
||||
else lib.strings.toIntBase10 diskSize;
|
||||
|
||||
formatAttr = "hypervImage";
|
||||
|
@ -13,14 +13,14 @@ 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
|
||||
echo "init=${builtins.unsafeDiscardStringContext config.system.build.toplevel}/init ${toString config.boot.kernelParams}" > $out/cmdline
|
||||
nuke-refs $out/kernel
|
||||
'';
|
||||
|
||||
|
||||
kexec_script = pkgs.writeTextFile {
|
||||
executable = true;
|
||||
name = "kexec-nixos";
|
||||
@ -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" {
|
||||
|
@ -1,4 +1,8 @@
|
||||
{lib, modulesPath, ...}: {
|
||||
{
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
"${toString modulesPath}/virtualisation/proxmox-lxc.nix"
|
||||
];
|
||||
|
@ -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";
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,8 @@ in {
|
||||
];
|
||||
|
||||
vmware.baseImageSize =
|
||||
if diskSize == "auto" then "auto"
|
||||
if diskSize == "auto"
|
||||
then "auto"
|
||||
else lib.strings.toIntBase10 diskSize;
|
||||
|
||||
formatAttr = "vmwareImage";
|
||||
|
Loading…
Reference in New Issue
Block a user