nixos-generators/nixos-generate.nix
James Alseth 4c7b914d1f Add disk-size argument
Many formats generate an image only large enough for the generated NixOS
config. This quickly runs out of space for NixOS servers that are updated
over time rather than being redeployed with fresh images.

Signed-off-by: James Alseth <james@jalseth.me>
2024-02-11 11:47:50 -08:00

33 lines
797 B
Nix

{
nixpkgs ? <nixpkgs>,
configuration ? <nixos-config>,
system ? builtins.currentSystem,
diskSize ? "auto",
formatConfig,
flakeUri ? null,
flakeAttr ? null,
}: let
module = import ./format-module.nix;
# Will only get evaluated when used, so no worries
flake = builtins.getFlake flakeUri;
flakeSystem = flake.outputs.packages."${system}".nixosConfigurations."${flakeAttr}" or flake.outputs.nixosConfigurations."${flakeAttr}";
in
if flakeUri != null
then
flakeSystem.extendModules {
modules = [module formatConfig];
}
else
import "${toString nixpkgs}/nixos/lib/eval-config.nix" {
inherit system;
specialArgs = {
diskSize = diskSize;
};
modules = [
module
formatConfig
configuration
];
}