From a3900340e4823fa317972b7380da9aefd5615e1f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 21 Feb 2017 21:41:05 +0100 Subject: [PATCH] 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 --- modules/home-environment.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 70889eb52..69a1a38ae 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -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: