mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
nixos/specialisation: escape and restrict specialisation names (#405393)
This commit is contained in:
commit
139080c304
1 changed files with 11 additions and 1 deletions
|
@ -10,6 +10,8 @@
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
concatStringsSep
|
concatStringsSep
|
||||||
|
escapeShellArg
|
||||||
|
hasInfix
|
||||||
mapAttrs
|
mapAttrs
|
||||||
mapAttrsToList
|
mapAttrsToList
|
||||||
mkOption
|
mkOption
|
||||||
|
@ -84,10 +86,18 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
assertions = mapAttrsToList (name: _: {
|
||||||
|
assertion = !hasInfix "/" name;
|
||||||
|
message = ''
|
||||||
|
Specialisation names must not contain forward slashes.
|
||||||
|
Invalid specialisation name: ${name}
|
||||||
|
'';
|
||||||
|
}) config.specialisation;
|
||||||
|
|
||||||
system.systemBuilderCommands = ''
|
system.systemBuilderCommands = ''
|
||||||
mkdir $out/specialisation
|
mkdir $out/specialisation
|
||||||
${concatStringsSep "\n" (
|
${concatStringsSep "\n" (
|
||||||
mapAttrsToList (name: path: "ln -s ${path} $out/specialisation/${name}") children
|
mapAttrsToList (name: path: "ln -s ${path} $out/specialisation/${escapeShellArg name}") children
|
||||||
)}
|
)}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue