Skip to content

systemd: remove bash#429972

Merged
flokli merged 10 commits intoNixOS:stagingfrom
nikstur:bashless-systemd-staging
Aug 10, 2025
Merged

systemd: remove bash#429972
flokli merged 10 commits intoNixOS:stagingfrom
nikstur:bashless-systemd-staging

Conversation

@nikstur
Copy link
Contributor

@nikstur nikstur commented Jul 31, 2025

Enforce that the closure of systemd remains bashless.

See the individual commits for more reasoning.

Review commit-by-commit.

Depended on (already merged):

Part of #428908

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nikstur nikstur changed the title Bashless systemd staging systemd: remove bash Jul 31, 2025
@nix-owners nix-owners bot requested review from aanderse, arianvp and flokli July 31, 2025 22:41
@nikstur nikstur requested a review from LordGrimmauld July 31, 2025 22:48
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. labels Jul 31, 2025
@nix-owners nix-owners bot requested review from 7c6f434c, ajs124, fpletz and lovek323 July 31, 2025 22:50
@flokli
Copy link
Member

flokli commented Aug 1, 2025

With #429797 merged, can you rebase this?

@nikstur nikstur force-pushed the bashless-systemd-staging branch from d780ca1 to 7e52ac3 Compare August 1, 2025 12:39
@nikstur
Copy link
Contributor Author

nikstur commented Aug 1, 2025

Rebased to include the cracklib changes.

Bashless kbd depends on legionus/kbd#138 and that's why I removed the disallowedRequisites commit.

An alternative would be to not directly depend on kbd in systemd. However I wouldn't know which path to use. /run/current-system/sw/bin doens't work as it's not available in the initrd.

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 4, 2025
@nikstur nikstur force-pushed the bashless-systemd-staging branch from 7e52ac3 to 6de672f Compare August 5, 2025 11:21
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 5, 2025
@nikstur
Copy link
Contributor Author

nikstur commented Aug 5, 2025

Disabled compression in kbd now to get rid of bash. Fonts and keymaps are now stored uncompressed by default.

From the 899eb19700d40c124e5f30475323de0091f20755:

Increases the binary size by 2.3MiB. However, with the 9MiB saved
by removing the excessive dictionary from cracklib (#429797), this still
results in a net reduction of the mandatory closure size.

Once kbd allows using the compression libraries instead of shelling out
to the binaries (github.com/legionus/kbd#138) we can compress by
default again.

Add the package kbdCompressed for users that want to load custom
compressed fonts and keymaps. Alternatively, they can still uncompress
custom fonts and keymaps themselves and then call loadkeys/setfont on
it.

@nikstur nikstur force-pushed the bashless-systemd-staging branch from 6de672f to 277c9bb Compare August 6, 2025 14:55
@philiptaron
Copy link
Contributor

I'm really excited for this. Anything you need testing-wise, @nikstur?

@nikstur
Copy link
Contributor Author

nikstur commented Aug 7, 2025

I'm really excited for this. Anything you need testing-wise, @nikstur?

Awesome! Any of the normal systemd testing would be appreciated. I ran the lvm2-vdo tests already.

Probably makes sense to cherry-pick the changes onto master to not have to rebuild everything.

@nikstur nikstur mentioned this pull request Aug 8, 2025
13 tasks
nikstur added 10 commits August 10, 2025 20:29
This enables us to use the lib output without pulling in bash.

- Enable structuredAttrs
- Enable strictDeps
- Add bash to disallowedRequisites
This enables us to use the lib and out output without pulling in bash.

- Enable structuredAttrs
- Enable strictDeps
- Add bash to disallowedRequisites
This enables us to use the lib and bin output without pulling in bash.

- Enable structuredAttrs
- Enable strictDeps
- Add bash to disallowedRequisites
This enables us to use the lib output without pulling in bash.

- Enable structuredAttrs
- Enable strictDeps
- Add bash to disallowedRequisites
Removes the dependency on bash.

Increases the binary size by 2.3MiB. However, with the 9MiB saved
by removing the excessive dictionary from cracklib (NixOS#429797), this still
results in a net reduction of the mandatory closure size.

Once kbd allows using the compression libraries instead of shelling out
to the binaries (github.com/legionus/kbd/issues/138) we can compress by
default again.

Add the package `kbdCompressed` for users that want to load custom
compressed fonts and keymaps. Alternatively, they can still uncompress
custom fonts and keymaps themselves and then call loadkeys/setfont on
it.
This enables us to use the lib output without pulling in bash.

- Enable structuredAttrs
- Enable strictDeps
- Add bash to disallowedRequisites
Since systemd/systemd#17026 (v248 in 2020),
systemd can use nftables without any new dependency!

In 259, systemd plans to remove iptables suport altogether.
Using the ambient /bin/sh makes sense to use as the debug shell because
it's inherently something from the environment.

Some years ago this was changed to an explicit Nix Store path. However,
this doesn't really make sense and makes many things (like optionally
removing bash from the system) hard while not making anything easier or
better.
The only thing that needed bashInteractive were bash scripts for RPM.
Remove the RPM scripts (we definitely do not need) to get rid of
bashInteractive.
@nikstur nikstur force-pushed the bashless-systemd-staging branch from 17003fe to 294b2f5 Compare August 10, 2025 18:36
@flokli flokli merged commit 2781e07 into NixOS:staging Aug 10, 2025
19 of 23 checks passed
@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 1 This PR was reviewed and approved by one person. and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Aug 10, 2025
@nikstur nikstur deleted the bashless-systemd-staging branch August 10, 2025 18:43
@alyssais
Copy link
Member

pkgsStatic.lvm2 now fails to build due to the disallowed requisite

@LordGrimmauld
Copy link
Contributor

LordGrimmauld commented Aug 20, 2025

$ rg bash /nix/store/7hm30llifnv7pn2sa3s5kmdc5myskxf5-lvm2-static-x86_64-unknown-linux-musl-2.03.33
/nix/store/7hm30llifnv7pn2sa3s5kmdc5myskxf5-lvm2-static-x86_64-unknown-linux-musl-2.03.33/nix-support/propagated-build-inputs
1:/nix/store/y14g6gck5jppfpw3b1cihg9irn5r0zf7-libaio-static-x86_64-unknown-linux-musl-0.3.113 /nix/store/6s9c1kcqm1nka0krnda028kb69l154ra-bash-interactive-static-x86_64-unknown-linux-musl-5.3p3-dev

Don't ask me why, but somehow bash leaks into propagated-build-inputs on static.

@alyssais
Copy link
Member

Every build input becomes a propagated build input on static — is that helpful?

@nikstur
Copy link
Contributor Author

nikstur commented Aug 20, 2025

Every build input becomes a propagated build input on static — is that helpful?

So this whole idea of moving scripts to a separate output doesn't work on static because bash will always be propagated because its in the buildInputs?

Is there a way to fix this (i.e. to ensure that bash isn't propagated)?

@alyssais
Copy link
Member

Hmm. There are other packages that just rm -f nix-support/propagated-build-inputs, which really is the right thing to do in any output that doesn't contain static libraries. Maybe that's the right thing to do here (for now)?

In the long term we can probably revisit this behaviour of pkgsStatic. We've talked before about encoding absolute paths to libraries in .pc files to create references. If we ever end up doing that I think we can drop this propagation hack once and for all, but that's a way off for now.

@LordGrimmauld
Copy link
Contributor

There are other packages that just rm -f nix-support/propagated-build-inputs, which really is the right thing to do in any output that doesn't contain static libraries.

libaio is a valid reference in propagated build inputs though. We can't just outright delete propagation, or else consumers of lvm2 will break.

@LordGrimmauld
Copy link
Contributor

LordGrimmauld commented Aug 20, 2025

imo, until we have a "good" fix (removing the wild propagation on static in favor of pkg-config tricks (#394607, #394610 ?), we should just not do the disallowed requisites check on static.

@alyssais
Copy link
Member

libaio is a valid reference in propagated build inputs though. We can't just outright delete propagation, or else consumers of lvm2 will break.

Right…

@nikstur nikstur mentioned this pull request Aug 21, 2025
13 tasks
@nikstur
Copy link
Contributor Author

nikstur commented Aug 21, 2025

Fix is here: #435567

@alyssais
Copy link
Member

alyssais commented Sep 8, 2025

systemdUkify is another casualty, because Python depends on bash.

vcunat added a commit that referenced this pull request Sep 9, 2025
This is basically a revert of a tiny part of PR #429972.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: systemd Software suite that provides an array of system components for Linux operating systems. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants