mirror of
https://github.com/nix-community/home-manager
synced 2024-12-24 18:59:47 +01:00
gnome-terminal: add assertion on profile names
This commit is contained in:
parent
5c23226768
commit
f58889c07e
3 changed files with 48 additions and 2 deletions
|
@ -292,12 +292,30 @@ in {
|
|||
profile = mkOption {
|
||||
default = { };
|
||||
type = types.attrsOf profileSubModule;
|
||||
description = "A set of Gnome Terminal profiles.";
|
||||
description = ''
|
||||
A set of Gnome Terminal profiles. Note, the name of a profile must be
|
||||
a UUID. You can generate one, for example, using {command}`uuidgen`
|
||||
(from `util-linux`).
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
(let
|
||||
uuidre =
|
||||
"[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}";
|
||||
erroneous =
|
||||
filter (n: builtins.match uuidre n == null) (attrNames cfg.profile);
|
||||
in {
|
||||
assertion = erroneous == [ ];
|
||||
message = ''
|
||||
The attribute name of a Gnome Terminal profile must be a UUID.
|
||||
Incorrect profile names: ${concatStringsSep ", " erroneous}'';
|
||||
})
|
||||
];
|
||||
|
||||
home.packages = [ pkgs.gnome.gnome-terminal ];
|
||||
|
||||
dconf.settings = let dconfPath = "org/gnome/terminal/legacy";
|
||||
|
|
25
tests/modules/programs/gnome-terminal/bad-profile-name.nix
Normal file
25
tests/modules/programs/gnome-terminal/bad-profile-name.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
programs.gnome-terminal = {
|
||||
enable = true;
|
||||
profile = {
|
||||
bad-name = { visibleName = "a"; };
|
||||
"e0b782ed-6aca-44eb-8c75-62b3706b6220" = {
|
||||
default = true;
|
||||
visibleName = "b";
|
||||
};
|
||||
another-bad-name = { visibleName = "c"; };
|
||||
};
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(self: super: { gnome.gnome-terminal = config.lib.test.mkStubPackage { }; })
|
||||
];
|
||||
|
||||
test.stubs.dconf = { };
|
||||
|
||||
test.asserts.assertions.expected = [''
|
||||
The attribute name of a Gnome Terminal profile must be a UUID.
|
||||
Incorrect profile names: another-bad-name, bad-name''];
|
||||
}
|
|
@ -1 +1,4 @@
|
|||
{ gnome-terminal-1 = ./gnome-terminal-1.nix; }
|
||||
{
|
||||
gnome-terminal-1 = ./gnome-terminal-1.nix;
|
||||
gnome-terminal-bad-profile-name = ./bad-profile-name.nix;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue