Function( Function { head: Destructured( FunctionHeadDestructured { ellipsis: false, identifier: None, arguments: [ FunctionHeadDestructuredArgument { identifier: "pkgs", default: None, }, FunctionHeadDestructuredArgument { identifier: "lib", default: None, }, FunctionHeadDestructuredArgument { identifier: "storePaths", default: None, }, FunctionHeadDestructuredArgument { identifier: "compressImage", default: Some( Identifier( Identifier { id: "false", span: Span { start: Position { line: 11, column: 19, }, end: Position { line: 11, column: 24, }, }, }, ), ), }, FunctionHeadDestructuredArgument { identifier: "zstd", default: None, }, FunctionHeadDestructuredArgument { identifier: "populateImageCommands", default: Some( String( String_ { parts: [], span: Span { start: Position { line: 14, column: 27, }, end: Position { line: 14, column: 29, }, }, }, ), ), }, FunctionHeadDestructuredArgument { identifier: "volumeLabel", default: None, }, FunctionHeadDestructuredArgument { identifier: "uuid", default: Some( String( String_ { parts: [ Raw( PartRaw { content: "44444444-4444-4444-8888-888888888888", span: Span { start: Position { line: 16, column: 11, }, end: Position { line: 16, column: 47, }, }, }, ), ], span: Span { start: Position { line: 16, column: 10, }, end: Position { line: 16, column: 48, }, }, }, ), ), }, FunctionHeadDestructuredArgument { identifier: "e2fsprogs", default: None, }, FunctionHeadDestructuredArgument { identifier: "libfaketime", default: None, }, FunctionHeadDestructuredArgument { identifier: "perl", default: None, }, FunctionHeadDestructuredArgument { identifier: "fakeroot", default: None, }, ], }, ), body: LetIn( LetIn { bindings: [ KeyValue( BindingKeyValue { from: [ Raw( PartRaw { content: "sdClosureInfo", span: Span { start: Position { line: 24, column: 3, }, end: Position { line: 24, column: 16, }, }, }, ), ], to: FunctionApplication( FunctionApplication { function: PropertyAccess( PropertyAccess { expression: Identifier( Identifier { id: "pkgs", span: Span { start: Position { line: 24, column: 19, }, end: Position { line: 24, column: 23, }, }, }, ), attribute_path: [ Raw( PartRaw { content: "buildPackages", span: Span { start: Position { line: 24, column: 24, }, end: Position { line: 24, column: 37, }, }, }, ), Raw( PartRaw { content: "closureInfo", span: Span { start: Position { line: 24, column: 38, }, end: Position { line: 24, column: 49, }, }, }, ), ], default: None, }, ), arguments: [ Map( Map { recursive: false, bindings: [ KeyValue( BindingKeyValue { from: [ Raw( PartRaw { content: "rootPaths", span: Span { start: Position { line: 24, column: 52, }, end: Position { line: 24, column: 61, }, }, }, ), ], to: Identifier( Identifier { id: "storePaths", span: Span { start: Position { line: 24, column: 64, }, end: Position { line: 24, column: 74, }, }, }, ), }, ), ], span: Span { start: Position { line: 24, column: 50, }, end: Position { line: 24, column: 77, }, }, }, ), ], }, ), }, ), ], target: FunctionApplication( FunctionApplication { function: PropertyAccess( PropertyAccess { expression: Identifier( Identifier { id: "pkgs", span: Span { start: Position { line: 26, column: 1, }, end: Position { line: 26, column: 5, }, }, }, ), attribute_path: [ Raw( PartRaw { content: "stdenv", span: Span { start: Position { line: 26, column: 6, }, end: Position { line: 26, column: 12, }, }, }, ), Raw( PartRaw { content: "mkDerivation", span: Span { start: Position { line: 26, column: 13, }, end: Position { line: 26, column: 25, }, }, }, ), ], default: None, }, ), arguments: [ Map( Map { recursive: false, bindings: [ KeyValue( BindingKeyValue { from: [ Raw( PartRaw { content: "name", span: Span { start: Position { line: 27, column: 3, }, end: Position { line: 27, column: 7, }, }, }, ), ], to: String( String_ { parts: [ Raw( PartRaw { content: "ext4-fs.img", span: Span { start: Position { line: 27, column: 11, }, end: Position { line: 27, column: 64, }, }, }, ), Interpolation( PartInterpolation { expression: FunctionApplication( FunctionApplication { function: PropertyAccess( PropertyAccess { expression: Identifier( Identifier { id: "lib", span: Span { start: Position { line: 27, column: 24, }, end: Position { line: 27, column: 27, }, }, }, ), attribute_path: [ Raw( PartRaw { content: "optionalString", span: Span { start: Position { line: 27, column: 28, }, end: Position { line: 27, column: 42, }, }, }, ), ], default: None, }, ), arguments: [ Identifier( Identifier { id: "compressImage", span: Span { start: Position { line: 27, column: 43, }, end: Position { line: 27, column: 56, }, }, }, ), String( String_ { parts: [ Raw( PartRaw { content: ".zst", span: Span { start: Position { line: 27, column: 58, }, end: Position { line: 27, column: 62, }, }, }, ), ], span: Span { start: Position { line: 27, column: 57, }, end: Position { line: 27, column: 63, }, }, }, ), ], }, ), }, ), ], span: Span { start: Position { line: 27, column: 10, }, end: Position { line: 27, column: 65, }, }, }, ), }, ), KeyValue( BindingKeyValue { from: [ Raw( PartRaw { content: "nativeBuildInputs", span: Span { start: Position { line: 29, column: 3, }, end: Position { line: 29, column: 20, }, }, }, ), ], to: BinaryOperation( BinaryOperation { left: List( List { elements: [ PropertyAccess( PropertyAccess { expression: Identifier( Identifier { id: "e2fsprogs", span: Span { start: Position { line: 29, column: 25, }, end: Position { line: 29, column: 34, }, }, }, ), attribute_path: [ Raw( PartRaw { content: "bin", span: Span { start: Position { line: 29, column: 35, }, end: Position { line: 29, column: 38, }, }, }, ), ], default: None, }, ), Identifier( Identifier { id: "libfaketime", span: Span { start: Position { line: 29, column: 39, }, end: Position { line: 29, column: 50, }, }, }, ), Identifier( Identifier { id: "perl", span: Span { start: Position { line: 29, column: 51, }, end: Position { line: 29, column: 55, }, }, }, ), Identifier( Identifier { id: "fakeroot", span: Span { start: Position { line: 29, column: 56, }, end: Position { line: 29, column: 64, }, }, }, ), ], span: Span { start: Position { line: 29, column: 23, }, end: Position { line: 29, column: 66, }, }, }, ), operator: Concatenation, right: FunctionApplication( FunctionApplication { function: PropertyAccess( PropertyAccess { expression: Identifier( Identifier { id: "lib", span: Span { start: Position { line: 30, column: 6, }, end: Position { line: 30, column: 9, }, }, }, ), attribute_path: [ Raw( PartRaw { content: "optional", span: Span { start: Position { line: 30, column: 10, }, end: Position { line: 30, column: 18, }, }, }, ), ], default: None, }, ), arguments: [ Identifier( Identifier { id: "compressImage", span: Span { start: Position { line: 30, column: 19, }, end: Position { line: 30, column: 32, }, }, }, ), Identifier( Identifier { id: "zstd", span: Span { start: Position { line: 30, column: 33, }, end: Position { line: 30, column: 37, }, }, }, ), ], }, ), }, ), }, ), KeyValue( BindingKeyValue { from: [ Raw( PartRaw { content: "buildCommand", span: Span { start: Position { line: 32, column: 3, }, end: Position { line: 32, column: 15, }, }, }, ), ], to: IndentedString( IndentedString { parts: [ Raw( PartRaw { content: "", span: Span { start: Position { line: 34, column: 1, }, end: Position { line: 34, column: 7, }, }, }, ), Interpolation( PartInterpolation { expression: IfThenElse( IfThenElse { predicate: Identifier( Identifier { id: "compressImage", span: Span { start: Position { line: 34, column: 12, }, end: Position { line: 34, column: 25, }, }, }, ), then: String( String_ { parts: [ Raw( PartRaw { content: "img=temp.img", span: Span { start: Position { line: 34, column: 32, }, end: Position { line: 34, column: 44, }, }, }, ), ], span: Span { start: Position { line: 34, column: 31, }, end: Position { line: 34, column: 45, }, }, }, ), else_: String( String_ { parts: [ Raw( PartRaw { content: "img=$out", span: Span { start: Position { line: 34, column: 52, }, end: Position { line: 34, column: 60, }, }, }, ), ], span: Span { start: Position { line: 34, column: 51, }, end: Position { line: 34, column: 61, }, }, }, ), span: Span { start: Position { line: 34, column: 9, }, end: Position { line: 34, column: 61, }, }, }, ), }, ), Raw( PartRaw { content: "\n(\nmkdir -p ./files\n", span: Span { start: Position { line: 34, column: 1, }, end: Position { line: 37, column: 7, }, }, }, ), Interpolation( PartInterpolation { expression: Identifier( Identifier { id: "populateImageCommands", span: Span { start: Position { line: 37, column: 9, }, end: Position { line: 37, column: 30, }, }, }, ), }, ), Raw( PartRaw { content: "\n)\n\necho \"Preparing store paths for image...\"\n\n# Create nix/store before copying path\nmkdir -p ./rootImage/nix/store\n\nxargs -I % cp -a --reflink=auto % -t ./rootImage/nix/store/ < ", span: Span { start: Position { line: 34, column: 1, }, end: Position { line: 45, column: 69, }, }, }, ), Interpolation( PartInterpolation { expression: Identifier( Identifier { id: "sdClosureInfo", span: Span { start: Position { line: 45, column: 71, }, end: Position { line: 45, column: 84, }, }, }, ), }, ), Raw( PartRaw { content: "/store-paths\n(\n GLOBIGNORE=\".:..\"\n shopt -u dotglob\n\n for f in ./files/*; do\n cp -a --reflink=auto -t ./rootImage/ \"$f\"\n done\n)\n\n# Also include a manifest of the closures in a format suitable for nix-store --load-db\ncp ", span: Span { start: Position { line: 34, column: 1, }, end: Position { line: 56, column: 10, }, }, }, ), Interpolation( PartInterpolation { expression: Identifier( Identifier { id: "sdClosureInfo", span: Span { start: Position { line: 56, column: 12, }, end: Position { line: 56, column: 25, }, }, }, ), }, ), Raw( PartRaw { content: "/registration ./rootImage/nix-path-registration\n\n# Make a crude approximation of the size of the target image.\n# If the script starts failing, increase the fudge factors here.\nnumInodes=$(find ./rootImage | wc -l)\nnumDataBlocks=$(du -s -c -B 4096 --apparent-size ./rootImage | tail -1 | awk '{ print int($1 * 1.10) }')\nbytes=$((2 * 4096 * $numInodes + 4096 * $numDataBlocks))\necho \"Creating an EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks)\"\n\ntruncate -s $bytes $img\n\nfaketime -f \"1970-01-01 00:00:01\" fakeroot mkfs.ext4 -L ", span: Span { start: Position { line: 34, column: 1, }, end: Position { line: 67, column: 63, }, }, }, ), Interpolation( PartInterpolation { expression: Identifier( Identifier { id: "volumeLabel", span: Span { start: Position { line: 67, column: 65, }, end: Position { line: 67, column: 76, }, }, }, ), }, ), Raw( PartRaw { content: " -U ", span: Span { start: Position { line: 34, column: 1, }, end: Position { line: 67, column: 81, }, }, }, ), Interpolation( PartInterpolation { expression: Identifier( Identifier { id: "uuid", span: Span { start: Position { line: 67, column: 83, }, end: Position { line: 67, column: 87, }, }, }, ), }, ), Raw( PartRaw { content: " -d ./rootImage $img\n\nexport EXT2FS_NO_MTAB_OK=yes\n# I have ended up with corrupted images sometimes, I suspect that happens when the build machine's disk gets full during the build.\nif ! fsck.ext4 -n -f $img; then\n echo \"--- Fsck failed for EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks) ---\"\n cat errorlog\n return 1\nfi\n\n# We may want to shrink the file system and resize the image to\n# get rid of the unnecessary slack here--but see\n# https://github.com/NixOS/nixpkgs/issues/125121 for caveats.\n\n# shrink to fit\nresize2fs -M $img\n\n# Add 16 MebiByte to the current_size\nnew_size=$(dumpe2fs -h $img | awk -F: \\\n '/Block count/{count=$2} /Block size/{size=$2} END{print (count*size+16*2**20)/size}')\n\nresize2fs $img $new_size\n\nif [ ", span: Span { start: Position { line: 34, column: 1, }, end: Position { line: 90, column: 12, }, }, }, ), Interpolation( PartInterpolation { expression: FunctionApplication( FunctionApplication { function: PropertyAccess( PropertyAccess { expression: Identifier( Identifier { id: "builtins", span: Span { start: Position { line: 90, column: 14, }, end: Position { line: 90, column: 22, }, }, }, ), attribute_path: [ Raw( PartRaw { content: "toString", span: Span { start: Position { line: 90, column: 23, }, end: Position { line: 90, column: 31, }, }, }, ), ], default: None, }, ), arguments: [ Identifier( Identifier { id: "compressImage", span: Span { start: Position { line: 90, column: 32, }, end: Position { line: 90, column: 45, }, }, }, ), ], }, ), }, ), Raw( PartRaw { content: " ]; then\n echo \"Compressing image\"\n zstd -v --no-progress ./$img -o $out\nfi\n", span: Span { start: Position { line: 34, column: 1, }, end: Position { line: 94, column: 5, }, }, }, ), ], span: Span { start: Position { line: 33, column: 5, }, end: Position { line: 94, column: 7, }, }, }, ), }, ), ], span: Span { start: Position { line: 26, column: 26, }, end: Position { line: 95, column: 2, }, }, }, ), ], }, ), span: Span { start: Position { line: 23, column: 1, }, end: Position { line: 95, column: 2, }, }, }, ), span: Span { start: Position { line: 6, column: 1, }, end: Position { line: 95, column: 2, }, }, }, )