blob: 98d6339dbe5eba6cf5b4e3b26c6ce665f88b9f08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
{ config, lib, pkgs, ... }:
with builtins;
with lib;
let
cfg = config.lass.per-user;
out = {
options.lass.per-user = api;
config = imp;
};
api = mkOption {
type = with types; attrsOf (submodule {
options = {
packages = mkOption {
type = listOf path;
default = [];
};
};
});
default = {};
};
imp = {
#
# TODO only shellInit and use well-known paths
#
environment.shellInit = ''
if test -e ${user-profiles}/"$LOGNAME"; then
. ${user-profiles}/"$LOGNAME"
fi
'';
environment.interactiveShellInit = ''
if test -e ${user-profiles}/"$LOGNAME"; then
. ${user-profiles}/"$LOGNAME"
fi
'';
environment.profileRelativeEnvVars.PATH = mkForce [ "/bin" ];
};
user-profiles = pkgs.runCommand "user-profiles" {} ''
mkdir $out
${concatStrings (mapAttrsToList (logname: { packages, ... }: ''
cat > $out/${logname} <<\EOF
${optionalString (length packages > 0) (
let path = makeSearchPath "bin" packages; in
''export PATH="$PATH":${escapeShellArg path}''
)}
EOF
'') cfg)}
'';
in out
|