home-environment: replace option 'mode' with option 'executable'

nix-store only allows modes 'r--' and 'r-x'
This commit is contained in:
Cornelius Mika 2017-09-06 10:17:27 +02:00
parent 2524d92e2b
commit afa573952c
2 changed files with 12 additions and 9 deletions

View file

@ -124,18 +124,21 @@ in
'';
};
mode = mkOption {
type = types.str;
default = "444";
description = "The permissions to apply to the file.";
executable = mkOption {
type = types.bool;
default = false;
description = "Make file executable.";
};
};
config = {
target = mkDefault name;
source = mkIf (config.text != null) (
mkDefault (pkgs.writeText "home-file" config.text)
);
source = mkIf (config.text != null)
(mkDefault (pkgs.writeTextFile {
name = "home-file";
text = config.text;
executable = config.executable;
}));
};
})
);
@ -419,7 +422,7 @@ in
mkdir -pv "$(dirname "$out/${v.target}")"
ln -sv "${v.source}" "$out/${v.target}"
else
install -D -m${v.mode} "${v.source}" "$out/${v.target}"
install -D -m${if v.executable then "+x" else "-x"} "${v.source}" "$out/${v.target}"
fi
''
) cfg.file

View file

@ -72,7 +72,7 @@ in
};
home.file.".xsession" = {
mode = "555";
executable = true;
text = ''
if [[ -e "$HOME/.profile" ]]; then
. "$HOME/.profile"