Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installers/tools: add system.disableInstallerTools option #104828

Merged

Conversation

matthewbauer
Copy link
Member

This option can be set to disable installer tools like nixos-rebuild,
nixos-install, and nixos-generate-config (as well as more). This is
nice when a system is not expected to be rebuild or reconfigure itself
such as in a stateless PXE setup, as well as other embedded scenarios.
Note, that the system can still be updated, but it must either get
nixos-rebuild from another source, or, for embedded systems, be
upgraded by another machine like:

nix copy "$system" --to "ssh://root@" && ssh "root@"
"nix-env -p /nix/var/nix/profiles/system --set $system && $system/bin/switch-to-configuration switch".

Along with other options, this allows removing Perl from a closure.
For example:

{
boot.enableContainers = false;
environment.defaultPackages = [];
system.disableInstallerTools = true;
}

should not include Perl.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

This option can be set to disable installer tools like nixos-rebuild,
nixos-install, and nixos-generate-config (as well as more). This is
nice when a system is not expected to be rebuild or reconfigure itself
such as in a stateless PXE setup, as well as other embedded scenarios.
Note, that the system can still be updated, but it must either get
nixos-rebuild from another source, or, for embedded systems, be
upgraded by another machine like:

  nix copy "$system" --to "ssh://root@<host>" && ssh "root@<host>"
  "nix-env -p /nix/var/nix/profiles/system --set $system && $system/bin/switch-to-configuration switch".

Along with other options, this allows removing Perl from a closure.
For example:

{
  boot.enableContainers = false;
  environment.defaultPackages = [];
  system.disableInstallerTools = true;
}

should not include Perl.
@vikanezrimaya
Copy link
Member

Another step to the minimal NixOS image (#21315)! Diff LGTM

Copy link
Member

@davidak davidak left a comment

Choose a reason for hiding this comment

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

Looks good

Not tested

@davidak
Copy link
Member

davidak commented Apr 1, 2021

@matthewbauer thanks

maybe a hydra test could be added to test a minimal system, so Perl is not included? do you want to add it here or should it be new pr?

@i-do-cpp
Copy link
Contributor

PR that adds a test for this option: #137484

I propose to merge this PR and handle the test in the other PR

Copy link
Member

@Artturin Artturin left a comment

Choose a reason for hiding this comment

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

Tested in a vm both disabled and enabled

@Artturin Artturin merged commit 045bf13 into NixOS:master Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants