mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-15 05:59:17 +03:00
nixos/repart-image: improve overridability, use structuredAttrs
Parameters passed to systemd-repart are now passed to the build script via environment variable, which is defined as a list of strings in combination with `__structuredAttrs = true`. This should make it easier to customize the image build using `overrideAttrs`. Both the script used to amend the repart definitions and the amended definitions are now available via passthru.
This commit is contained in:
parent
d7570b0493
commit
f88148f05e
1 changed files with 25 additions and 10 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
{ lib
|
{ lib
|
||||||
, runCommand
|
, runCommand
|
||||||
|
, runCommandLocal
|
||||||
, python3
|
, python3
|
||||||
, black
|
, black
|
||||||
, ruff
|
, ruff
|
||||||
|
@ -50,6 +51,11 @@ let
|
||||||
mypy --strict $out
|
mypy --strict $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
amendedRepartDefinitions = runCommandLocal "amended-repart.d" {} ''
|
||||||
|
definitions=$(${amendRepartDefinitions} ${partitions} ${definitionsDirectory})
|
||||||
|
cp -r $definitions $out
|
||||||
|
'';
|
||||||
|
|
||||||
fileSystemToolMapping = {
|
fileSystemToolMapping = {
|
||||||
"vfat" = [ dosfstools mtools ];
|
"vfat" = [ dosfstools mtools ];
|
||||||
"ext4" = [ e2fsprogs.bin ];
|
"ext4" = [ e2fsprogs.bin ];
|
||||||
|
@ -74,28 +80,37 @@ in
|
||||||
|
|
||||||
runCommand imageFileBasename
|
runCommand imageFileBasename
|
||||||
{
|
{
|
||||||
|
__structuredAttrs = true;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
systemd
|
systemd
|
||||||
fakeroot
|
fakeroot
|
||||||
util-linux
|
util-linux
|
||||||
compressionPkg
|
compressionPkg
|
||||||
] ++ fileSystemTools;
|
] ++ fileSystemTools;
|
||||||
} ''
|
|
||||||
amendedRepartDefinitions=$(${amendRepartDefinitions} ${partitions} ${definitionsDirectory})
|
|
||||||
|
|
||||||
|
systemdRepartFlags = [
|
||||||
|
"--dry-run=no"
|
||||||
|
"--empty=create"
|
||||||
|
"--size=auto"
|
||||||
|
"--seed=${seed}"
|
||||||
|
"--definitions=${amendedRepartDefinitions}"
|
||||||
|
"--split=${lib.boolToString split}"
|
||||||
|
"--json=pretty"
|
||||||
|
] ++ lib.optionals (sectorSize != null) [
|
||||||
|
"--sector-size=${toString sectorSize}"
|
||||||
|
];
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
inherit amendRepartDefinitions amendedRepartDefinitions;
|
||||||
|
};
|
||||||
|
} ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cd $out
|
cd $out
|
||||||
|
|
||||||
echo "Building image with systemd-repart..."
|
echo "Building image with systemd-repart..."
|
||||||
unshare --map-root-user fakeroot systemd-repart \
|
unshare --map-root-user fakeroot systemd-repart \
|
||||||
--dry-run=no \
|
''${systemdRepartFlags[@]} \
|
||||||
--empty=create \
|
|
||||||
--size=auto \
|
|
||||||
--seed="${seed}" \
|
|
||||||
--definitions="$amendedRepartDefinitions" \
|
|
||||||
--split="${lib.boolToString split}" \
|
|
||||||
--json=pretty \
|
|
||||||
${lib.optionalString (sectorSize != null) "--sector-size=${toString sectorSize}"} \
|
|
||||||
${imageFileBasename}.raw \
|
${imageFileBasename}.raw \
|
||||||
| tee repart-output.json
|
| tee repart-output.json
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue