mirror of
https://github.com/nix-community/nixos-generators.git
synced 2024-11-22 01:52:05 +03:00
rename filename to fileExtension
This commit is contained in:
parent
efb2d33d4f
commit
af3d3a7538
@ -188,7 +188,7 @@ images can be built from that flake by running:
|
||||
formatConfigs.my-custom-format = {config, modulesPath, ...}: {
|
||||
imports = ["${toString modulesPath}/installer/cd-dvd/installation-cd-base.nix"];
|
||||
formatAttr = "isoImage";
|
||||
filename = "*.iso";
|
||||
fileExtension = ".iso";
|
||||
networking.wireless.networks = {
|
||||
# ...
|
||||
};
|
||||
|
@ -31,9 +31,9 @@
|
||||
|
||||
# attrset of formats to be exposed under config.system.formats
|
||||
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
|
||||
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"
|
||||
''
|
||||
);
|
||||
|
@ -37,7 +37,7 @@ Tests using the all-formats module through a flake.
|
||||
}: {
|
||||
imports = ["${toString modulesPath}/installer/cd-dvd/installation-cd-base.nix"];
|
||||
formatAttr = "isoImage";
|
||||
filename = "*.iso";
|
||||
fileExtension = ".iso";
|
||||
networking.wireless.networks = {
|
||||
# ...
|
||||
};
|
||||
|
@ -7,7 +7,7 @@
|
||||
key = "github:nix-community/nixos-generators/format-module.nix";
|
||||
|
||||
options = {
|
||||
filename = lib.mkOption {
|
||||
fileExtension = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Declare the path of the wanted file in the output directory";
|
||||
default = "";
|
||||
|
@ -2,5 +2,5 @@
|
||||
imports = [./kexec.nix];
|
||||
|
||||
formatAttr = lib.mkForce "kexec_bundle";
|
||||
filename = lib.mkForce "*-kexec_bundle";
|
||||
fileExtension = lib.mkForce "*-kexec_bundle";
|
||||
}
|
||||
|
@ -67,5 +67,5 @@ in {
|
||||
networking.hostName = lib.mkDefault "kexec";
|
||||
|
||||
formatAttr = "kexec_tarball";
|
||||
filename = "*/tarball/*.tar.xz";
|
||||
fileExtension = "*/tarball/*.tar.xz";
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
];
|
||||
|
||||
formatAttr = "amazonImage";
|
||||
filename = ".vhd";
|
||||
fileExtension = ".vhd";
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
];
|
||||
|
||||
formatAttr = "digitalOceanImage";
|
||||
filename = ".qcow2.gz";
|
||||
fileExtension = ".qcow2.gz";
|
||||
}
|
||||
|
@ -11,5 +11,5 @@
|
||||
services.journald.console = "/dev/console";
|
||||
|
||||
formatAttr = "tarball";
|
||||
filename = ".tar.xz";
|
||||
fileExtension = ".tar.xz";
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
];
|
||||
|
||||
formatAttr = "googleComputeImage";
|
||||
filename = ".raw.tar.gz";
|
||||
fileExtension = ".raw.tar.gz";
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
];
|
||||
|
||||
formatAttr = "hypervImage";
|
||||
filename = ".vhdx";
|
||||
fileExtension = ".vhdx";
|
||||
}
|
||||
|
@ -13,5 +13,5 @@
|
||||
virtualisation.hypervGuest.enable = true;
|
||||
|
||||
formatAttr = "isoImage";
|
||||
filename = ".iso";
|
||||
fileExtension = ".iso";
|
||||
}
|
||||
|
@ -13,5 +13,5 @@
|
||||
systemd.services.sshd.wantedBy = lib.mkForce ["multi-user.target"];
|
||||
|
||||
formatAttr = "isoImage";
|
||||
filename = ".iso";
|
||||
fileExtension = ".iso";
|
||||
}
|
||||
|
@ -14,5 +14,5 @@
|
||||
isoImage.makeUsbBootable = true;
|
||||
|
||||
formatAttr = "isoImage";
|
||||
filename = ".iso";
|
||||
fileExtension = ".iso";
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
];
|
||||
|
||||
formatAttr = "kubevirtImage";
|
||||
filename = ".qcow2";
|
||||
fileExtension = ".qcow2";
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
];
|
||||
|
||||
formatAttr = "linode";
|
||||
filename = ".img.gz";
|
||||
fileExtension = ".img.gz";
|
||||
|
||||
system.build.linode = import "${toString modulesPath}/../lib/make-disk-image.nix" {
|
||||
inherit lib config pkgs;
|
||||
|
@ -9,5 +9,5 @@
|
||||
];
|
||||
|
||||
formatAttr = "metadata";
|
||||
filename = ".tar.xz";
|
||||
fileExtension = ".tar.xz";
|
||||
}
|
||||
|
@ -10,5 +10,5 @@
|
||||
];
|
||||
|
||||
formatAttr = "tarball";
|
||||
filename = ".tar.xz";
|
||||
fileExtension = ".tar.xz";
|
||||
}
|
||||
|
@ -16,5 +16,5 @@ else {
|
||||
"${toString modulesPath}/../maintainers/scripts/openstack/openstack-image.nix"
|
||||
];
|
||||
formatAttr = "openstackImage";
|
||||
filename = ".qcow2";
|
||||
fileExtension = ".qcow2";
|
||||
}
|
||||
|
@ -3,5 +3,5 @@
|
||||
"${toString modulesPath}/virtualisation/proxmox-lxc.nix"
|
||||
];
|
||||
formatAttr = "tarball";
|
||||
filename = ".tar.xz";
|
||||
fileExtension = ".tar.xz";
|
||||
}
|
||||
|
@ -3,5 +3,5 @@
|
||||
"${toString modulesPath}/virtualisation/proxmox-image.nix"
|
||||
];
|
||||
formatAttr = "VMA";
|
||||
filename = ".vma.zst";
|
||||
fileExtension = ".vma.zst";
|
||||
}
|
||||
|
@ -35,5 +35,5 @@
|
||||
};
|
||||
|
||||
formatAttr = "qcow";
|
||||
filename = ".qcow2";
|
||||
fileExtension = ".qcow2";
|
||||
}
|
||||
|
@ -26,5 +26,5 @@
|
||||
};
|
||||
|
||||
formatAttr = "raw";
|
||||
filename = ".img";
|
||||
fileExtension = ".img";
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
];
|
||||
|
||||
formatAttr = "virtualBoxOVA";
|
||||
filename = ".ova";
|
||||
fileExtension = ".ova";
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
];
|
||||
|
||||
formatAttr = "vmwareImage";
|
||||
filename = ".vmdk";
|
||||
fileExtension = ".vmdk";
|
||||
}
|
||||
|
@ -163,13 +163,13 @@ if [[ -n $cores ]]; then
|
||||
fi
|
||||
|
||||
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")
|
||||
|
||||
if [[ -z $run ]]; then
|
||||
# show the first file, ignoring nix-support
|
||||
find "$out" -name "*$filename" -xtype f -print -quit
|
||||
find "$out" -name "*$fileExtension" -xtype f -print -quit
|
||||
else
|
||||
runner=$(find "$out"/bin -type l -print -quit)
|
||||
exec "$runner"
|
||||
|
Loading…
Reference in New Issue
Block a user