at master 1.9 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8{ 9 imports = [ 10 (lib.mkRemovedOptionModule [ "system" "switch" "enableNg" ] '' 11 This option controlled the usage of the new switch-to-configuration-ng, 12 which is now the only switch-to-configuration implementation. This option 13 can be removed from configuration. If there are outstanding issues 14 preventing you from using the new implementation, please open an issue on 15 GitHub. 16 '') 17 ]; 18 19 options.system.switch.enable = lib.mkOption { 20 type = lib.types.bool; 21 default = true; 22 description = '' 23 Whether to include the capability to switch configurations. 24 25 Disabling this makes the system unable to be reconfigured via `nixos-rebuild`. 26 27 This is good for image based appliances where updates are handled 28 outside the image. Reducing features makes the image lighter and 29 slightly more secure. 30 ''; 31 }; 32 33 config = lib.mkIf config.system.switch.enable { 34 # Use a subshell so we can source makeWrapper's setup hook without 35 # affecting the rest of activatableSystemBuilderCommands. 36 system.activatableSystemBuilderCommands = '' 37 ( 38 source ${pkgs.buildPackages.makeWrapper}/nix-support/setup-hook 39 40 mkdir $out/bin 41 ln -sf ${lib.getExe pkgs.switch-to-configuration-ng} $out/bin/switch-to-configuration 42 wrapProgram $out/bin/switch-to-configuration \ 43 --set OUT $out \ 44 --set TOPLEVEL ''${!toplevelVar} \ 45 --set DISTRO_ID ${lib.escapeShellArg config.system.nixos.distroId} \ 46 --set INSTALL_BOOTLOADER ${lib.escapeShellArg config.system.build.installBootLoader} \ 47 --set PRE_SWITCH_CHECK ${lib.escapeShellArg config.system.preSwitchChecksScript} \ 48 --set LOCALE_ARCHIVE ${config.i18n.glibcLocales}/lib/locale/locale-archive \ 49 --set SYSTEMD ${config.systemd.package} 50 ) 51 ''; 52 }; 53}