Skip to content

Commit

Permalink
misc/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 committed Feb 10, 2025
1 parent 5af1b9a commit 1d8c783
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 1d8c783

Please sign in to comment.