Skip to content

busybox-static: init#341780

Open
alyssais wants to merge 1 commit intoNixOS:masterfrom
alyssais:busybox-static
Open

busybox-static: init#341780
alyssais wants to merge 1 commit intoNixOS:masterfrom
alyssais:busybox-static

Conversation

@alyssais
Copy link
Member

Description of changes

Most of the uses of pkgsStatic inside pkgs are just for busybox. Using pkgsStatic inside the package set is a layering violation — the idea behind pkgsStatic was to give users a way to build all packages statically — and bloats build closures with a whole separate toolchain for no good reason. Since there's a legitimate need for a static busybox, let's just add a normal package for it.

As part of this, I've changed busybox-sandbox-shell to just use the normal Busybox package, since it already overrides the passed Busybox to be static.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@alyssais alyssais requested a review from roberth as a code owner September 14, 2024 09:26
@alyssais alyssais added the 6.topic: static Static builds (e.g. pkgsStatic) label Sep 14, 2024
The main reason to use pkgsStatic inside pkgs seems to just be for
busybox.  Using pkgsStatic inside the package set is a layering
violation — the idea behind pkgsStatic was to give _users_ a way to
build _all_ packages statically — and bloats build closures with a
whole separate toolchain for no good reason.  Since there's a
legitimate need for a static busybox, let's just add a normal package
for it.

As part of this, I've changed busybox-sandbox-shell to just use the
normal Busybox package, since it already overrides the passed Busybox
to be static.
else busybox;
};
busybox-static = busybox.override { enableStatic = true; };
busybox-sandbox-shell = callPackage ../os-specific/linux/busybox/sandbox-shell.nix { };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Busybox is used by nix inside its sandbox for /bin/sh, which needs to be self-standing. So I'm pretty sure this needs to be built with useMusl otherwise it leaves references to other /nix/store paths.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that was true, how would this have worked in the else branch above, before? i.e. for RISC-V or LoongArch64 or bionic? Those didn't use musl - did those cases not have those references for a different reason?

Copy link
Contributor

@wolfgangwalther wolfgangwalther Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, @szlend, this kind of contradicts the comment you added in https://github.com/NixOS/nixpkgs/pull/314845/files#diff-baf2a52d7f904b2863c773307b5c8fd5969e0da50b97b696ead87818f001c710R9-R11. Essentially this PR just takes it a step further and follows through on that comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is true. Just because libc can access some paths, it doesn't mean that the shell will want to, and in fact I'd say it's extremely unlikely.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be right, it's possible failing to find those references (e.g. glibc locales) is not fatal, but it still feels wrong to have broken /nix/store references in the nix sandbox. I'd leave it to nix maintainers to decide.

# GNS3 2.3.26 requires a static BusyBox for the Docker integration
prePatch = ''
cp ${pkgsStatic.busybox}/bin/busybox gns3server/compute/docker/resources/bin/busybox
cp ${busybox-static}/bin/busybox gns3server/compute/docker/resources/bin/busybox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed that removing the whole prePatch makes the build for gns3-server fail, but using busybox-static keeps it working, so this change should be good!

else busybox;
};
busybox-static = busybox.override { enableStatic = true; };
busybox-sandbox-shell = callPackage ../os-specific/linux/busybox/sandbox-shell.nix { };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The busybox-sandbox-shell changes seem to be in wrong place in a commit named busybox-static: init.

@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Sep 14, 2024
@ofborg ofborg bot requested a review from anthonyroussel September 14, 2024 10:37
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. labels Sep 14, 2024
@anthonyroussel anthonyroussel added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 18, 2024
@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: static Static builds (e.g. pkgsStatic) 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants