summary refs log tree commit diff
path: root/nixos/modules/system/activation/top-level.nix
diff options
context:
space:
mode:
authorJanne Heß <janne@hess.ooo>2022-01-05 12:59:47 +0100
committerJanne Heß <janne@hess.ooo>2022-01-20 15:10:23 +0100
commit96d36b0c2e5a4be7c5538f7dea7c16154081af29 (patch)
treefef8a2c3ef95cda75702bdc770137ac61a87869e /nixos/modules/system/activation/top-level.nix
parent80475b46f52a1e28a70b1866c2a8edb071208ac8 (diff)
downloadnixpkgs-96d36b0c2e5a4be7c5538f7dea7c16154081af29.tar
nixpkgs-96d36b0c2e5a4be7c5538f7dea7c16154081af29.tar.gz
nixpkgs-96d36b0c2e5a4be7c5538f7dea7c16154081af29.tar.bz2
nixpkgs-96d36b0c2e5a4be7c5538f7dea7c16154081af29.tar.lz
nixpkgs-96d36b0c2e5a4be7c5538f7dea7c16154081af29.tar.xz
nixpkgs-96d36b0c2e5a4be7c5538f7dea7c16154081af29.tar.zst
nixpkgs-96d36b0c2e5a4be7c5538f7dea7c16154081af29.zip
nixos/switch-to-configuration: Proper unit file parser
This replaces the naive K=V unit parser with a proper INI parser from a
library and adds proper support for override files. Also adds a bunch of
comments about parsing, I hope this makes it easier to understand and
maintain in the future.

There are multiple reasons to do so, the first one is just general
correctness with is nice imo. But to get to more serious reasons (I
didn't put in all that effort for nothing) is that this is the first
step torwards more clever restart/reload handling. By using a library
like Data::Compare a future PR could replace the current way of
fingerprinting units (which is to compare store paths) by comparing the
hashes. This is more precise because units won't get restarted because
the order of the options change, comments are added, some dependency of
writeText changes, .... Also this allows us to add a feature like
`X-Reload-Triggers` so the unit can either be reloaded when these change
or restarted when everything else changes, giving module authors the
ability to have their services reloaded without having to fear that
updates are not applied because the service doesn't get restarted.
Another reason why this feature is nice is that now that the unit files
are parsed correctly (and values are just extracted from one section),
potential future rewrites can just rely on some INI library without
having to implement their own weird parser that is compatible with this
script.

This also comes with a new subroutine to handle systemd booleans because
I thought the current way of handling it was just ugly. This also allows
overriding values this script reads in an override file.

Apart from making this script more compatible with the world around it,
this also fixes two issues I saw bugging exactly 0 (zero) people. First
is that this script now supports multiple override files, also ones that
are not called override.conf and the second one is that `1` and `on` are
treated as bools by systemd but were previously not parsed as such by
switch-to-configuration.
Diffstat (limited to 'nixos/modules/system/activation/top-level.nix')
-rw-r--r--nixos/modules/system/activation/top-level.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix
index 1c588ff9691..0f26aaf72ec 100644
--- a/nixos/modules/system/activation/top-level.nix
+++ b/nixos/modules/system/activation/top-level.nix
@@ -119,7 +119,7 @@ let
     configurationName = config.boot.loader.grub.configurationName;
 
     # Needed by switch-to-configuration.
-    perl = pkgs.perl.withPackages (p: with p; [ FileSlurp NetDBus XMLParser XMLTwig ]);
+    perl = pkgs.perl.withPackages (p: with p; [ FileSlurp NetDBus XMLParser XMLTwig ConfigIniFiles ]);
   };
 
   # Handle assertions and warnings