mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-19 21:17:55 +00:00
WiP: revert garbage collector within nix environment. Doesn;t help and makes the docker image bigger
TODO: push v0.1.2 with those changes pointing circleci to use it Signed-off-by: Thierry Laurion <insurgo@riseup.net>
This commit is contained in:
parent
3d0991f6c1
commit
0b7ce534a8
@ -59,11 +59,12 @@ docker push tlaurion/heads-dev-env:v0.0.3
|
|||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
#To create the docker image, I was not able to set gcroot dynamically, so here are the manual steps so nix is not wiped per garbage collector
|
#To create the docker image, using garbage collector didn't help and made the size of the image grow bigger?! not using it reverting to what worked
|
||||||
mkdir -p /nix/var/nix/gcroots/per-user/$(whoami)
|
# produced image without garbage collector was 990 Mb image, with it (and stripping which is already done by nix builder...) its 1006Mb. Over my head
|
||||||
ln -sfn $(readlink -f $HOME/.nix-profile) /nix/var/nix/gcroots/per-user/$(whoami)/profile
|
sh <(curl -L https://nixos.org/nix/install) --no-daemon
|
||||||
|
. /home/user/.nix-profile/etc/profile.d/nix.sh
|
||||||
|
|
||||||
#And then build derivates and cal garbarrge collection (not yet successfull since docker build fails now)
|
#And then build derivates
|
||||||
nix build .#dockerImage && docker load < result && docker run --network host --rm -ti -v $(pwd):$(pwd) -w $(pwd) linuxboot/heads:dev-env
|
nix build .#dockerImage && docker load < result && docker run --network host --rm -ti -v $(pwd):$(pwd) -w $(pwd) linuxboot/heads:dev-env
|
||||||
|
|
||||||
#Use it
|
#Use it
|
||||||
@ -72,6 +73,6 @@ docker run -e DISPLAY=$DISPLAY --network host --rm -ti -v $(pwd):$(pwd) -w $(pwd
|
|||||||
|
|
||||||
#push it
|
#push it
|
||||||
docker login
|
docker login
|
||||||
docker tag linuxboot/heads:dev-env tlaurion/heads-dev-env:v0.0.9
|
docker tag linuxboot/heads:dev-env tlaurion/heads-dev-env:v0.1.2
|
||||||
docker push tlaurion/heads-dev-env:v0.0.9
|
docker push tlaurion/heads-dev-env:v0.1.2
|
||||||
|
|
||||||
|
34
flake.nix
34
flake.nix
@ -85,25 +85,10 @@
|
|||||||
sudo # ( °-° )
|
sudo # ( °-° )
|
||||||
upx
|
upx
|
||||||
];
|
];
|
||||||
|
|
||||||
# Stripping binaries to reduce size, while ensuring functionality is not affected.
|
|
||||||
stripBinaries = map (pkg: if pkg?isDerivation then pkg.overrideAttrs (oldAttrs: {
|
|
||||||
postInstall = oldAttrs.postInstall or "" + ''
|
|
||||||
strip $out/bin/* || true
|
|
||||||
'';
|
|
||||||
}) else pkg) deps;
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
# The development shell includes all the dependencies.
|
# The development shell includes all the dependencies.
|
||||||
devShell = pkgs.mkShellNoCC {
|
devShell = pkgs.mkShellNoCC {
|
||||||
buildInputs = stripBinaries ++ [ pkgs.nix ]; # Include the Nix package to provide nix-collect-garbage.
|
buildInputs = deps;
|
||||||
shellHook = ''
|
|
||||||
# Create a garbage collection root for the Nix profile
|
|
||||||
mkdir -p /nix/var/nix/gcroots/per-user/$(whoami)
|
|
||||||
echo $(readlink -f $HOME/.nix-profile) > /nix/var/nix/gcroots/per-user/$(whoami)/profile
|
|
||||||
# Perform garbage collection to clean up any unnecessary files.
|
|
||||||
nix-collect-garbage -d
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# myDevShell outputs environment variables necessary for development.
|
# myDevShell outputs environment variables necessary for development.
|
||||||
@ -123,20 +108,17 @@
|
|||||||
|
|
||||||
# Docker image configuration for the Heads project.
|
# Docker image configuration for the Heads project.
|
||||||
packages.dockerImage = pkgs.dockerTools.buildLayeredImage {
|
packages.dockerImage = pkgs.dockerTools.buildLayeredImage {
|
||||||
name = "linuxboot/heads"; # Image name.
|
name = "linuxboot/heads";
|
||||||
tag = "dev-env"; # Image tag.
|
tag = "dev-env";
|
||||||
config.Entrypoint = ["bash" "-c" ''source /devenv.sh; if (( $# == 0 )); then exec bash; else exec "$0" "$@"; fi'']; # Entrypoint configuration.
|
config.Entrypoint = ["bash" "-c" ''source /devenv.sh; if (( $# == 0 )); then exec bash; else exec "$0" "$@"; fi''];
|
||||||
|
contents =
|
||||||
# Contents of the Docker image, including stripped binaries for size optimization.
|
deps
|
||||||
contents = stripBinaries ++ [
|
++ [
|
||||||
pkgs.dockerTools.binSh
|
pkgs.dockerTools.binSh
|
||||||
pkgs.dockerTools.caCertificates
|
pkgs.dockerTools.caCertificates
|
||||||
pkgs.dockerTools.usrBinEnv
|
pkgs.dockerTools.usrBinEnv
|
||||||
];
|
];
|
||||||
|
enableFakechroot = true;
|
||||||
enableFakechroot = true; # Enable fakechroot for compatibility.
|
|
||||||
|
|
||||||
# Fake root commands to set up the environment inside the Docker image.
|
|
||||||
fakeRootCommands =
|
fakeRootCommands =
|
||||||
#bash
|
#bash
|
||||||
''
|
''
|
||||||
|
Loading…
Reference in New Issue
Block a user