Skip to content

Commit

Permalink
nixos: switch to switch-to-configuration-ng by default (NixOS#339727)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilazy authored Sep 6, 2024
2 parents 1318c66 + a5cfd68 commit fe63e7a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 38 deletions.
6 changes: 0 additions & 6 deletions nixos/doc/manual/configuration/profiles/perlless.section.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Perlless {#sec-perlless}

::: {.warning}
If you enable this profile, you will NOT be able to switch to a new
configuration and thus you will not be able to rebuild your system with
nixos-rebuild!
:::

Render your system completely perlless (i.e. without the perl interpreter). This
includes a mechanism so that your build fails if it contains a Nix store path
that references the string "perl".
4 changes: 4 additions & 0 deletions nixos/doc/manual/release-notes/rl-2411.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
Users that want to keep PulseAudio will want to set `services.pipewire.enable = false;` and `hardware.pulseaudio.enable = true;`.
There is currently no plan to fully deprecate and remove PulseAudio, however, PipeWire should generally be preferred for new installs.

- The Rust rewrite of the `switch-to-configuration` program is now used for system activation by default.
If you experience any issues, please report them.
The original Perl script can still be used for now by setting `system.switch.enableNg` to `false`.

## New Modules {#sec-release-24.11-new-modules}

- [TaskChampion Sync-Server](https://github.com/GothenburgBitFactory/taskchampion-sync-server), a [Taskwariror 3](https://taskwarrior.org/docs/upgrade-3/) sync server, replacing Taskwarrior 2's sync server named [`taskserver`](https://github.com/GothenburgBitFactory/taskserver).
Expand Down
7 changes: 0 additions & 7 deletions nixos/modules/profiles/perlless.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

{

# switch-to-configuration-ng reimplements switch-to-configuration, but
# without perl.
system.switch = lib.mkDefault {
enable = false;
enableNg = true;
};

# Remove perl from activation
boot.initrd.systemd.enable = lib.mkDefault true;
system.etc.overlay.enable = lib.mkDefault true;
Expand Down
32 changes: 11 additions & 21 deletions nixos/modules/system/activation/switchable-system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ let

perlWrapped = pkgs.perl.withPackages (p: with p; [ ConfigIniFiles FileSlurp ]);

description = extra: ''
Whether to include the capability to switch configurations.
Disabling this makes the system unable to be reconfigured via `nixos-rebuild`.
${extra}
'';

in

{
Expand All @@ -20,7 +12,11 @@ in
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = description ''
description = ''
Whether to include the capability to switch configurations.
Disabling this makes the system unable to be reconfigured via `nixos-rebuild`.
This is good for image based appliances where updates are handled
outside the image. Reducing features makes the image lighter and
slightly more secure.
Expand All @@ -29,23 +25,17 @@ in

enableNg = lib.mkOption {
type = lib.types.bool;
default = false;
description = description ''
Whether to use `switch-to-configuration-ng`, an experimental
re-implementation of `switch-to-configuration` with the goal of
replacing the original.
default = config.system.switch.enable;
defaultText = lib.literalExpression "config.system.switch.enable";
description = ''
Whether to use `switch-to-configuration-ng`, the Rust-based
re-implementation of the original Perl `switch-to-configuration`.
'';
};
};

config = lib.mkMerge [
{
assertions = [{
assertion = with config.system.switch; enable -> !enableNg;
message = "Only one of system.switch.enable and system.switch.enableNg may be enabled at a time";
}];
}
(lib.mkIf config.system.switch.enable {
(lib.mkIf (config.system.switch.enable && !config.system.switch.enableNg) {
system.activatableSystemBuilderCommands = ''
mkdir $out/bin
substitute ${./switch-to-configuration.pl} $out/bin/switch-to-configuration \
Expand Down
5 changes: 1 addition & 4 deletions nixos/tests/switch-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ in {

nodes = {
machine = { pkgs, lib, ... }: {
system.switch = {
enable = !ng;
enableNg = ng;
};
system.switch.enableNg = ng;

environment.systemPackages = [ pkgs.socat ]; # for the socket activation stuff
users.mutableUsers = false;
Expand Down

0 comments on commit fe63e7a

Please sign in to comment.