diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix
index d66580b7b9be..2d1b0ffb54ce 100644
--- a/nixos/modules/system/activation/top-level.nix
+++ b/nixos/modules/system/activation/top-level.nix
@@ -178,9 +178,10 @@ in
default = false;
description = ''
If enabled, copies the NixOS configuration file
- $NIXOS_CONFIG (usually
- /etc/nixos/configuration.nix)
- to the system store path.
+ (usually /etc/nixos/configuration.nix)
+ and links it from the resulting system
+ (getting to /run/current-system/configuration.nix).
+ Note that only this single file is copied, even if it imports others.
'';
};
@@ -238,7 +239,9 @@ in
system.extraSystemBuilderCmds =
optionalString
config.system.copySystemConfiguration
- "cp ${maybeEnv "NIXOS_CONFIG" "/etc/nixos/configuration.nix"} $out";
+ ''ln -s '${import ../../../lib/from-env.nix "NIXOS_CONFIG" }' \
+ "$out/configuration.nix"
+ '';
system.build.toplevel = system;