makeSquashfsManifest: recursively create squashfs
This commit is contained in:
parent
6ecf5bfa0f
commit
138e51b3b3
@ -1,4 +1,5 @@
|
|||||||
{ callPackage }:
|
{ callPackage }:
|
||||||
{
|
{
|
||||||
makeCpioRecursive = callPackage ./cpio-recursive {};
|
makeCpioRecursive = callPackage ./cpio-recursive {};
|
||||||
|
makeSquashfsManifest = callPackage ./squashfs-recursive {};
|
||||||
}
|
}
|
||||||
|
|||||||
21
pkgs/squashfs-recursive/default.nix
Normal file
21
pkgs/squashfs-recursive/default.nix
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{ runCommand, nixUnstable, jq, path }:
|
||||||
|
let
|
||||||
|
map-squash = ./map-squash.nix;
|
||||||
|
|
||||||
|
mkSquashfsManifest = { name, storeContents, reverse ? false }:
|
||||||
|
runCommand "${name}-squashfs-manifest" {
|
||||||
|
buildInputs = [ nixUnstable jq ];
|
||||||
|
requiredSystemFeatures = [ "recursive-nix" ];
|
||||||
|
exportReferencesGraph = [ "root" storeContents ];
|
||||||
|
NIX_PATH = "nixpkgs=${path}";
|
||||||
|
} ''
|
||||||
|
cat root | grep /nix/store | sort | uniq | jq -R . | jq -s . > paths.json
|
||||||
|
nix-build ${map-squash} --arg pathsJson ./paths.json --arg reverse ${if reverse then "true" else "false"}
|
||||||
|
|
||||||
|
touch $out
|
||||||
|
for f in $(cat result); do
|
||||||
|
find "$f" -type f >> $out
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
mkSquashfsManifest
|
||||||
30
pkgs/squashfs-recursive/map-squash.nix
Normal file
30
pkgs/squashfs-recursive/map-squash.nix
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{ reverse ? false, pathsJson, pkgs ? import <nixpkgs> {} }:
|
||||||
|
let
|
||||||
|
namePart = strPath:
|
||||||
|
let
|
||||||
|
nameParts = builtins.tail (builtins.tail (builtins.split "[-]" strPath));
|
||||||
|
namePartsWithDashes = (builtins.map (x: if x == [] then "-" else x) nameParts);
|
||||||
|
in
|
||||||
|
builtins.foldl' (collect: part: "${collect}${part}") "" namePartsWithDashes;
|
||||||
|
|
||||||
|
paths = builtins.fromJSON (builtins.readFile pathsJson);
|
||||||
|
mksquash = strPath: pkgs.runCommand "${namePart strPath}-squash" {
|
||||||
|
buildInputs = [ pkgs.squashfsTools pkgs.utillinux ];
|
||||||
|
} ''
|
||||||
|
mkdir $out
|
||||||
|
revout=$(echo "$(basename ${strPath})" | rev)
|
||||||
|
mksquashfs \
|
||||||
|
"${builtins.storePath strPath}" \
|
||||||
|
./result \
|
||||||
|
-comp gzip -Xcompression-level 9 \
|
||||||
|
-keep-as-directory \
|
||||||
|
-all-root
|
||||||
|
|
||||||
|
if ${if reverse then "true" else "false"}; then
|
||||||
|
tac result > result.rev
|
||||||
|
mv result.rev result
|
||||||
|
fi
|
||||||
|
mv result "$out/$revout"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
pkgs.writeText "squashes" (pkgs.lib.concatMapStringsSep "\n" mksquash paths)
|
||||||
Loading…
Reference in New Issue
Block a user