Skip to content

Commit

Permalink
specialisation: escape specialisation name
Browse files Browse the repository at this point in the history
The specialisation name is included in home.extraBuilderCommands
without being properly escaped and checked. This commit fixes that.
  • Loading branch information
ToborWinner authored and rycee committed Mar 5, 2025
1 parent f6ac8a3 commit 486b066
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/misc/specialisation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down

0 comments on commit 486b066

Please sign in to comment.