Desktop: Reduce Nix package closure size (#3737)
This commit is contained in:
parent
acab171bc5
commit
2f5ccad5ea
|
|
@ -1,27 +1,24 @@
|
||||||
{ pkgs, inputs, ... }:
|
{ pkgs, inputs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cef = pkgs.cef-binary.overrideAttrs {
|
cefPath = pkgs.cef-binary.overrideAttrs (finalAttrs: {
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
strip $out/Release/*.so*
|
rm -r $out/* $out/.* || true
|
||||||
|
strip ./Release/*.so*
|
||||||
|
mv ./Release/* $out/
|
||||||
|
find "./Resources/locales" -maxdepth 1 -type f ! -name 'en-US.pak' -delete
|
||||||
|
mv ./Resources/* $out/
|
||||||
|
mv ./include $out/
|
||||||
|
|
||||||
|
echo '${
|
||||||
|
builtins.toJSON {
|
||||||
|
type = "minimal";
|
||||||
|
name = builtins.baseNameOf finalAttrs.src.url;
|
||||||
|
sha1 = "";
|
||||||
|
}
|
||||||
|
}' > $out/archive.json
|
||||||
'';
|
'';
|
||||||
};
|
});
|
||||||
|
|
||||||
cefPath = pkgs.runCommand "cef-path" { } ''
|
|
||||||
mkdir -p $out
|
|
||||||
|
|
||||||
ln -s ${cef}/include $out/include
|
|
||||||
find ${cef}/Release -name "*" -type f -exec ln -s {} $out/ \;
|
|
||||||
find ${cef}/Resources -name "*" -maxdepth 1 -exec ln -s {} $out/ \;
|
|
||||||
|
|
||||||
echo '${
|
|
||||||
builtins.toJSON {
|
|
||||||
type = "minimal";
|
|
||||||
name = builtins.baseNameOf cef.src.url;
|
|
||||||
sha1 = "";
|
|
||||||
}
|
|
||||||
}' > $out/archive.json
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
env.CEF_PATH = cefPath;
|
env.CEF_PATH = cefPath;
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1763938834,
|
"lastModified": 1770169865,
|
||||||
"narHash": "sha256-j8iB0Yr4zAvQLueCZ5abxfk6fnG/SJ5JnGUziETjwfg=",
|
"narHash": "sha256-iPiy13xzDQ9GjpOez+NNIjh/qjl7i4RDf9dF2x5mF9I=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "d9e753122e51cee64eb8d2dddfe11148f339f5a2",
|
"rev": "8254ccf3b5b5131890ee073776f2e61c6d1e55d4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -49,11 +49,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1764242076,
|
"lastModified": 1770197578,
|
||||||
"narHash": "sha256-sKoIWfnijJ0+9e4wRvIgm/HgE27bzwQxcEmo2J/gNpI=",
|
"narHash": "sha256-AYqlWrX09+HvGs8zM6ebZ1pwUqjkfpnv8mewYwAo+iM=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "2fad6eac6077f03fe109c4d4eb171cf96791faa4",
|
"rev": "00c21e4c93d963c50d4c0c89bfa84ed6e0694df2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -79,11 +79,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1764297505,
|
"lastModified": 1770347142,
|
||||||
"narHash": "sha256-qrLpVu2/hA9Cu6IovMEsgh9YRyvmmWS+bSx7C1JGChA=",
|
"narHash": "sha256-uz+ZSqXpXEPtdRPYwvgsum/CfNq7AUQ/0gZHqTigiPM=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "9623580f8ce09ec444b9aca107566ec5db110e62",
|
"rev": "2859683cd9ef7858d324c5399b0d8d6652bf4044",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,14 @@ let
|
||||||
build = ''
|
build = ''
|
||||||
mkdir -p out
|
mkdir -p out
|
||||||
mkdir -p out/bin
|
mkdir -p out/bin
|
||||||
cp ${graphite}/bin/.graphite-wrapped out/bin/graphite
|
cp ${graphite}/bin/graphite out/bin/graphite
|
||||||
chmod -v +w out/bin/graphite
|
chmod -v +w out/bin/graphite
|
||||||
patchelf --set-rpath '$ORIGIN/../lib:$ORIGIN/../lib/cef' --set-interpreter '/lib64/ld-linux-x86-64.so.2' out/bin/graphite
|
patchelf \
|
||||||
|
--set-rpath '$ORIGIN/../lib:$ORIGIN/../lib/cef' \
|
||||||
|
--set-interpreter '/lib64/ld-linux-x86-64.so.2' \
|
||||||
|
--remove-needed libGL.so \
|
||||||
|
out/bin/graphite
|
||||||
|
cp -r ${graphite}/share out/share
|
||||||
mkdir -p out/lib/cef
|
mkdir -p out/lib/cef
|
||||||
mkdir -p ./cef
|
mkdir -p ./cef
|
||||||
tar -xvf ${pkgs.cef-binary.src} -C ./cef --strip-components=1
|
tar -xvf ${pkgs.cef-binary.src} -C ./cef --strip-components=1
|
||||||
|
|
@ -30,7 +35,6 @@ let
|
||||||
cp -r ./cef/Resources/* out/lib/cef/
|
cp -r ./cef/Resources/* out/lib/cef/
|
||||||
find "out/lib/cef/locales" -type f ! -name 'en-US*' -delete
|
find "out/lib/cef/locales" -type f ! -name 'en-US*' -delete
|
||||||
${pkgs.bintools}/bin/strip out/lib/cef/*.so*
|
${pkgs.bintools}/bin/strip out/lib/cef/*.so*
|
||||||
cp -r ${graphite}/share out/share
|
|
||||||
'';
|
'';
|
||||||
install =
|
install =
|
||||||
if tar then
|
if tar then
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,16 @@ let
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
tar -xvf ${brandingTar} -C $out --strip-components 1
|
tar -xvf ${brandingTar} -C $out --strip-components 1
|
||||||
'';
|
'';
|
||||||
|
cargoVendorDir = deps.crane.lib.vendorCargoDeps { inherit (info) src; };
|
||||||
resourcesCommon = {
|
resourcesCommon = {
|
||||||
pname = "${info.pname}-resources";
|
pname = "${info.pname}-resources";
|
||||||
inherit (info) version src;
|
inherit (info) version src;
|
||||||
|
inherit cargoVendorDir;
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
doCheck = false;
|
|
||||||
nativeBuildInputs = tools.frontend;
|
nativeBuildInputs = tools.frontend;
|
||||||
env.CARGO_PROFILE = if dev then "dev" else "release";
|
env.CARGO_PROFILE = if dev then "dev" else "release";
|
||||||
cargoExtraArgs = "--target wasm32-unknown-unknown -p graphite-wasm --no-default-features --features native";
|
cargoExtraArgs = "--target wasm32-unknown-unknown -p graphite-wasm --no-default-features --features native";
|
||||||
|
doCheck = false;
|
||||||
};
|
};
|
||||||
resources = deps.crane.lib.buildPackage (
|
resources = deps.crane.lib.buildPackage (
|
||||||
resourcesCommon
|
resourcesCommon
|
||||||
|
|
@ -52,7 +54,7 @@ let
|
||||||
npmConfigScript = "setup";
|
npmConfigScript = "setup";
|
||||||
makeCacheWritable = true;
|
makeCacheWritable = true;
|
||||||
|
|
||||||
nativeBuildInputs = tools.frontend ++ [ pkgs.importNpmLock.npmConfigHook ];
|
nativeBuildInputs = tools.frontend ++ [ pkgs.importNpmLock.npmConfigHook pkgs.removeReferencesTo ];
|
||||||
|
|
||||||
prePatch = ''
|
prePatch = ''
|
||||||
mkdir branding
|
mkdir branding
|
||||||
|
|
@ -72,13 +74,18 @@ let
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cp -r frontend/dist/* $out/
|
cp -r frontend/dist/* $out/
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
postFixup = ''
|
||||||
|
find "$out" -type f -exec remove-references-to -t "${cargoVendorDir}" '{}' +
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
common = {
|
common = {
|
||||||
inherit (info) pname version src;
|
inherit (info) pname version src;
|
||||||
|
inherit cargoVendorDir;
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
buildInputs = libs.desktop-all;
|
buildInputs = libs.desktop-all;
|
||||||
nativeBuildInputs = tools.desktop ++ [ pkgs.makeWrapper ];
|
nativeBuildInputs = tools.desktop ++ [ pkgs.makeWrapper pkgs.removeReferencesTo ];
|
||||||
env = deps.cef.env // {
|
env = deps.cef.env // {
|
||||||
CARGO_PROFILE = if dev then "dev" else "release";
|
CARGO_PROFILE = if dev then "dev" else "release";
|
||||||
};
|
};
|
||||||
|
|
@ -138,9 +145,12 @@ deps.crane.lib.buildPackage (
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postFixup = ''
|
postFixup = ''
|
||||||
wrapProgram "$out/bin/graphite" \
|
remove-references-to -t "${cargoVendorDir}" $out/bin/graphite
|
||||||
--prefix LD_LIBRARY_PATH : "${pkgs.lib.makeLibraryPath libs.desktop-all}:${deps.cef.env.CEF_PATH}" \
|
|
||||||
--set CEF_PATH "${deps.cef.env.CEF_PATH}"
|
patchelf \
|
||||||
|
--set-rpath "${pkgs.lib.makeLibraryPath libs.desktop-all}:${deps.cef.env.CEF_PATH}" \
|
||||||
|
--add-needed libGL.so \
|
||||||
|
$out/bin/graphite
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue