Unverified Commit dc90d270 authored by Emily's avatar Emily Committed by GitHub
Browse files

treewide: remove Perl-based switch-to-configuration (#414882)

parents 9287609d c59d4343
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

- The Perl implementation of the `switch-to-configuration` program is removed. All switchable systems now use the Rust rewrite. Any prior usage of `system.switch.enableNg` must now be removed. If you have any outstanding issues with the new implementation, please open an issue on GitHub.

- The `services.polipo` module has been removed as `polipo` is unmaintained and archived upstream.

- The Pocket ID module ([`services.pocket-id`][#opt-services.pocket-id.enable]) and package (`pocket-id`) has been updated to 1.0.0. Some environment variables have been changed or removed, see the [migration guide](https://pocket-id.org/docs/setup/migrate-to-v1/).
+1 −1
Original line number Diff line number Diff line
@@ -256,7 +256,7 @@ in
      description = ''
        A program that writes a bootloader installation script to the path passed in the first command line argument.

        See `nixos/modules/system/activation/switch-to-configuration.pl`.
        See `pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs`.
      '';
      type = types.unique {
        message = ''
+0 −1027

File deleted.

Preview size limit exceeded, changes collapsed.

+37 −89
Original line number Diff line number Diff line
@@ -5,17 +5,18 @@
  ...
}:

let
  perlWrapped = pkgs.perl.withPackages (
    p: with p; [
      ConfigIniFiles
      FileSlurp
    ]
  );
in
{
  options.system.switch = {
    enable = lib.mkOption {
  imports = [
    (lib.mkRemovedOptionModule [ "system" "switch" "enableNg" ] ''
      This option controlled the usage of the new switch-to-configuration-ng,
      which is now the only switch-to-configuration implementation. This option
      can be removed from configuration. If there are outstanding issues
      preventing you from using the new implementation, please open an issue on
      GitHub.
    '')
  ];

  options.system.switch.enable = lib.mkOption {
    type = lib.types.bool;
    default = true;
    description = ''
@@ -29,58 +30,7 @@ in
    '';
  };

    enableNg = lib.mkOption {
      type = lib.types.bool;
      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 [
    (lib.mkIf (config.system.switch.enable && !config.system.switch.enableNg) {
      warnings = [
        ''
          The Perl implementation of switch-to-configuration will be deprecated
          and removed in the 25.05 release of NixOS. Please migrate to the
          newer implementation by removing `system.switch.enableNg = false`
          from your configuration. If you are unable to migrate due to any
          issues with the new implementation, please create an issue and tag
          the maintainers of `switch-to-configuration-ng`.
        ''
      ];

      system.activatableSystemBuilderCommands = ''
        mkdir $out/bin
        substitute ${./switch-to-configuration.pl} $out/bin/switch-to-configuration \
          --subst-var out \
          --subst-var-by toplevel ''${!toplevelVar} \
          --subst-var-by coreutils "${pkgs.coreutils}" \
          --subst-var-by distroId ${lib.escapeShellArg config.system.nixos.distroId} \
          --subst-var-by installBootLoader ${lib.escapeShellArg config.system.build.installBootLoader} \
          --subst-var-by preSwitchCheck ${lib.escapeShellArg config.system.preSwitchChecksScript} \
          --subst-var-by localeArchive "${config.i18n.glibcLocales}/lib/locale/locale-archive" \
          --subst-var-by perl "${perlWrapped}" \
          --subst-var-by shell "${pkgs.bash}/bin/sh" \
          --subst-var-by su "${pkgs.shadow.su}/bin/su" \
          --subst-var-by systemd "${config.systemd.package}" \
          --subst-var-by utillinux "${pkgs.util-linux}" \
          ;

        chmod +x $out/bin/switch-to-configuration
        ${lib.optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) ''
          if ! output=$(${perlWrapped}/bin/perl -c $out/bin/switch-to-configuration 2>&1); then
            echo "switch-to-configuration syntax is not valid:"
            echo "$output"
            exit 1
          fi
        ''}
      '';
    })
    (lib.mkIf config.system.switch.enableNg {
  config = lib.mkIf config.system.switch.enable {
    # Use a subshell so we can source makeWrapper's setup hook without
    # affecting the rest of activatableSystemBuilderCommands.
    system.activatableSystemBuilderCommands = ''
@@ -99,7 +49,5 @@ in
          --set SYSTEMD ${config.systemd.package}
      )
    '';
    })
  ];

  };
}
+1 −8
Original line number Diff line number Diff line
@@ -1283,14 +1283,7 @@ in
  swapspace = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./swapspace.nix { };
  sway = runTest ./sway.nix;
  swayfx = runTest ./swayfx.nix;
  switchTest = runTest {
    imports = [ ./switch-test.nix ];
    defaults.system.switch.enableNg = false;
  };
  switchTestNg = runTest {
    imports = [ ./switch-test.nix ];
    defaults.system.switch.enableNg = true;
  };
  switchTest = runTest ./switch-test.nix;
  sx = runTest ./sx.nix;
  sympa = runTest ./sympa.nix;
  syncthing = runTest ./syncthing.nix;
Loading