From 0fc68a3d1d2a03da543209f922e75d2fa0a55e28 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 2 Aug 2012 15:11:29 -0400 Subject: [PATCH] Rewrite switch-to-configuration in Perl This will make it more efficient to do systemd dependency graph processing (if necessary). --- .../activation/switch-to-configuration.pl | 57 ++++++++++++++++++ .../activation/switch-to-configuration.sh | 59 ------------------- modules/system/activation/top-level.nix | 20 +++---- 3 files changed, 65 insertions(+), 71 deletions(-) create mode 100644 modules/system/activation/switch-to-configuration.pl delete mode 100644 modules/system/activation/switch-to-configuration.sh diff --git a/modules/system/activation/switch-to-configuration.pl b/modules/system/activation/switch-to-configuration.pl new file mode 100644 index 000000000000..199c23d8ab0e --- /dev/null +++ b/modules/system/activation/switch-to-configuration.pl @@ -0,0 +1,57 @@ +#! @perl@ + +use strict; +use warnings; +use File::Slurp; + +my $action = shift @ARGV; + +if (!defined $action || ($action ne "switch" && $action ne "boot" && $action ne "test")) { + print STDERR < 'quiet') // ""; +my $newVersion = read_file("@out@/init-interface-version"); + +if ($newVersion ne $oldVersion) { + print STDERR < $out/kernel-params @@ -130,7 +130,7 @@ let done mkdir $out/bin - substituteAll ${./switch-to-configuration.sh} $out/bin/switch-to-configuration + substituteAll ${./switch-to-configuration.pl} $out/bin/switch-to-configuration chmod +x $out/bin/switch-to-configuration ${config.system.extraSystemBuilderCmds} @@ -146,6 +146,9 @@ let name = "nixos-${config.system.nixosVersion}"; preferLocalBuild = true; buildCommand = systemBuilder; + + inherit (pkgs) systemd; + inherit children; kernelParams = config.boot.kernelParams ++ config.boot.extraKernelParams; @@ -164,17 +167,10 @@ let # to the activation script. noRestartIfChanged = attrValues (mapAttrs (n: v: if v.restartIfChanged then [] else ["[${v.name}]=1"]) config.jobs); - # Most of these are needed by grub-install. - path = - [ pkgs.coreutils - pkgs.gnused - pkgs.gnugrep - pkgs.findutils - pkgs.diffutils - pkgs.systemd - ]; - configurationName = config.boot.loader.grub.configurationName; + + # Needed by switch-to-configuration. + perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl"; };