1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-18 14:28:15 +00:00

specialisation: escape specialisation name

The specialisation name is included in home.extraBuilderCommands
without being properly escaped and checked. This commit fixes that.
This commit is contained in:
toborwinner 2025-02-09 21:32:30 +01:00 committed by Robert Helgesson
parent f6ac8a3414
commit 486b066025

View file

@ -71,10 +71,16 @@ with lib;
};
config = mkIf (config.specialisation != { }) {
assertions = map (n: {
assertion = !lib.hasInfix "/" n;
message =
"<name> in specialisation.<name> cannot contain a forward slash.";
}) (attrNames config.specialisation);
home.extraBuilderCommands = let
link = n: v:
let pkg = v.configuration.home.activationPackage;
in "ln -s ${pkg} $out/specialisation/${n}";
in "ln -s ${pkg} $out/specialisation/${escapeShellArg n}";
in ''
mkdir $out/specialisation
${concatStringsSep "\n" (mapAttrsToList link config.specialisation)}