rename filename to fileExtension

This commit is contained in:
lassulus 2023-07-22 16:20:50 +02:00
parent efb2d33d4f
commit af3d3a7538
26 changed files with 28 additions and 28 deletions

View File

@ -188,7 +188,7 @@ images can be built from that flake by running:
formatConfigs.my-custom-format = {config, modulesPath, ...}: { formatConfigs.my-custom-format = {config, modulesPath, ...}: {
imports = ["${toString modulesPath}/installer/cd-dvd/installation-cd-base.nix"]; imports = ["${toString modulesPath}/installer/cd-dvd/installation-cd-base.nix"];
formatAttr = "isoImage"; formatAttr = "isoImage";
filename = "*.iso"; fileExtension = ".iso";
networking.wireless.networks = { networking.wireless.networks = {
# ... # ...
}; };

View File

@ -31,9 +31,9 @@
# attrset of formats to be exposed under config.system.formats # attrset of formats to be exposed under config.system.formats
formats = lib.flip lib.mapAttrs allConfigs ( formats = lib.flip lib.mapAttrs allConfigs (
formatName: conf: pkgs.runCommand "${conf.config.system.build.${conf.config.formatAttr}.name}${conf.config.filename}" {} '' formatName: conf: pkgs.runCommand "${conf.config.system.build.${conf.config.formatAttr}.name}${conf.config.fileExtension}" {} ''
set -efu set -efu
target=$(find '${conf.config.system.build.${conf.config.formatAttr}}' -name '*${conf.config.filename}' -xtype f -print -quit) target=$(find '${conf.config.system.build.${conf.config.formatAttr}}' -name '*${conf.config.fileExtension}' -xtype f -print -quit)
ln -s "$target" "$out" ln -s "$target" "$out"
'' ''
); );

View File

@ -37,7 +37,7 @@ Tests using the all-formats module through a flake.
}: { }: {
imports = ["${toString modulesPath}/installer/cd-dvd/installation-cd-base.nix"]; imports = ["${toString modulesPath}/installer/cd-dvd/installation-cd-base.nix"];
formatAttr = "isoImage"; formatAttr = "isoImage";
filename = "*.iso"; fileExtension = ".iso";
networking.wireless.networks = { networking.wireless.networks = {
# ... # ...
}; };

View File

@ -7,7 +7,7 @@
key = "github:nix-community/nixos-generators/format-module.nix"; key = "github:nix-community/nixos-generators/format-module.nix";
options = { options = {
filename = lib.mkOption { fileExtension = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "Declare the path of the wanted file in the output directory"; description = "Declare the path of the wanted file in the output directory";
default = ""; default = "";

View File

@ -2,5 +2,5 @@
imports = [./kexec.nix]; imports = [./kexec.nix];
formatAttr = lib.mkForce "kexec_bundle"; formatAttr = lib.mkForce "kexec_bundle";
filename = lib.mkForce "*-kexec_bundle"; fileExtension = lib.mkForce "*-kexec_bundle";
} }

View File

@ -67,5 +67,5 @@ in {
networking.hostName = lib.mkDefault "kexec"; networking.hostName = lib.mkDefault "kexec";
formatAttr = "kexec_tarball"; formatAttr = "kexec_tarball";
filename = "*/tarball/*.tar.xz"; fileExtension = "*/tarball/*.tar.xz";
} }

View File

@ -4,5 +4,5 @@
]; ];
formatAttr = "amazonImage"; formatAttr = "amazonImage";
filename = ".vhd"; fileExtension = ".vhd";
} }

View File

@ -4,5 +4,5 @@
]; ];
formatAttr = "digitalOceanImage"; formatAttr = "digitalOceanImage";
filename = ".qcow2.gz"; fileExtension = ".qcow2.gz";
} }

View File

@ -11,5 +11,5 @@
services.journald.console = "/dev/console"; services.journald.console = "/dev/console";
formatAttr = "tarball"; formatAttr = "tarball";
filename = ".tar.xz"; fileExtension = ".tar.xz";
} }

View File

@ -4,5 +4,5 @@
]; ];
formatAttr = "googleComputeImage"; formatAttr = "googleComputeImage";
filename = ".raw.tar.gz"; fileExtension = ".raw.tar.gz";
} }

View File

@ -4,5 +4,5 @@
]; ];
formatAttr = "hypervImage"; formatAttr = "hypervImage";
filename = ".vhdx"; fileExtension = ".vhdx";
} }

View File

@ -13,5 +13,5 @@
virtualisation.hypervGuest.enable = true; virtualisation.hypervGuest.enable = true;
formatAttr = "isoImage"; formatAttr = "isoImage";
filename = ".iso"; fileExtension = ".iso";
} }

View File

@ -13,5 +13,5 @@
systemd.services.sshd.wantedBy = lib.mkForce ["multi-user.target"]; systemd.services.sshd.wantedBy = lib.mkForce ["multi-user.target"];
formatAttr = "isoImage"; formatAttr = "isoImage";
filename = ".iso"; fileExtension = ".iso";
} }

View File

@ -14,5 +14,5 @@
isoImage.makeUsbBootable = true; isoImage.makeUsbBootable = true;
formatAttr = "isoImage"; formatAttr = "isoImage";
filename = ".iso"; fileExtension = ".iso";
} }

View File

@ -4,5 +4,5 @@
]; ];
formatAttr = "kubevirtImage"; formatAttr = "kubevirtImage";
filename = ".qcow2"; fileExtension = ".qcow2";
} }

View File

@ -10,7 +10,7 @@
]; ];
formatAttr = "linode"; formatAttr = "linode";
filename = ".img.gz"; fileExtension = ".img.gz";
system.build.linode = import "${toString modulesPath}/../lib/make-disk-image.nix" { system.build.linode = import "${toString modulesPath}/../lib/make-disk-image.nix" {
inherit lib config pkgs; inherit lib config pkgs;

View File

@ -9,5 +9,5 @@
]; ];
formatAttr = "metadata"; formatAttr = "metadata";
filename = ".tar.xz"; fileExtension = ".tar.xz";
} }

View File

@ -10,5 +10,5 @@
]; ];
formatAttr = "tarball"; formatAttr = "tarball";
filename = ".tar.xz"; fileExtension = ".tar.xz";
} }

View File

@ -16,5 +16,5 @@ else {
"${toString modulesPath}/../maintainers/scripts/openstack/openstack-image.nix" "${toString modulesPath}/../maintainers/scripts/openstack/openstack-image.nix"
]; ];
formatAttr = "openstackImage"; formatAttr = "openstackImage";
filename = ".qcow2"; fileExtension = ".qcow2";
} }

View File

@ -3,5 +3,5 @@
"${toString modulesPath}/virtualisation/proxmox-lxc.nix" "${toString modulesPath}/virtualisation/proxmox-lxc.nix"
]; ];
formatAttr = "tarball"; formatAttr = "tarball";
filename = ".tar.xz"; fileExtension = ".tar.xz";
} }

View File

@ -3,5 +3,5 @@
"${toString modulesPath}/virtualisation/proxmox-image.nix" "${toString modulesPath}/virtualisation/proxmox-image.nix"
]; ];
formatAttr = "VMA"; formatAttr = "VMA";
filename = ".vma.zst"; fileExtension = ".vma.zst";
} }

View File

@ -35,5 +35,5 @@
}; };
formatAttr = "qcow"; formatAttr = "qcow";
filename = ".qcow2"; fileExtension = ".qcow2";
} }

View File

@ -26,5 +26,5 @@
}; };
formatAttr = "raw"; formatAttr = "raw";
filename = ".img"; fileExtension = ".img";
} }

View File

@ -4,5 +4,5 @@
]; ];
formatAttr = "virtualBoxOVA"; formatAttr = "virtualBoxOVA";
filename = ".ova"; fileExtension = ".ova";
} }

View File

@ -4,5 +4,5 @@
]; ];
formatAttr = "vmwareImage"; formatAttr = "vmwareImage";
filename = ".vmdk"; fileExtension = ".vmdk";
} }

View File

@ -163,13 +163,13 @@ if [[ -n $cores ]]; then
fi fi
formatAttr=$(nix-instantiate "${nix_args[@]}" --eval --json -A config.formatAttr | jq -r .) formatAttr=$(nix-instantiate "${nix_args[@]}" --eval --json -A config.formatAttr | jq -r .)
filename=$(nix-instantiate "${nix_args[@]}" --eval --json -A config.filename | jq -r .) fileExtension=$(nix-instantiate "${nix_args[@]}" --eval --json -A config.fileExtension | jq -r .)
out=$(nix-build "${nix_args[@]}" "${nix_build_args[@]}" -A "config.system.build.$formatAttr") out=$(nix-build "${nix_args[@]}" "${nix_build_args[@]}" -A "config.system.build.$formatAttr")
if [[ -z $run ]]; then if [[ -z $run ]]; then
# show the first file, ignoring nix-support # show the first file, ignoring nix-support
find "$out" -name "*$filename" -xtype f -print -quit find "$out" -name "*$fileExtension" -xtype f -print -quit
else else
runner=$(find "$out"/bin -type l -print -quit) runner=$(find "$out"/bin -type l -print -quit)
exec "$runner" exec "$runner"