home-environment: check files for '.' prefix

Nix does not allow files whose name start with a '.' in the Nix store.
This commit makes a not of this fact in the `home.file.source` option
and also adds an assertion verifying that no such file is given.

Closes #4
This commit is contained in:
Robert Helgesson 2017-02-21 21:41:05 +01:00
parent beba608705
commit a3900340e4
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86

View file

@ -114,7 +114,11 @@ in
source = mkOption {
type = types.path;
description = "Path of the source file.";
description = ''
Path of the source file. Note, the file name must not
start with a period since Nix will not allow such
names in the Nix store.
'';
};
mode = mkOption {
@ -206,6 +210,20 @@ in
};
config = {
assertions = [
(let
badFiles =
filter (hasPrefix ".")
(map (v: baseNameOf (toString v.source))
(attrValues cfg.file));
badFilesStr = toString badFiles;
in
{
assertion = badFiles == [];
message = "Source file names must not start with '.': ${badFilesStr}";
})
];
home.sessionVariables =
let
maybeSet = name: value: