1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-05 16:27:03 +00:00

users: install user packages via users.users.<name?>.packages

This commit is contained in:
Wael M. Nasreddine 2019-02-20 08:20:32 -08:00
parent 94d2d20a5f
commit 4ffabd184a
No known key found for this signature in database
GPG key ID: FD437548E0BF0F5F
3 changed files with 39 additions and 0 deletions

View file

@ -158,5 +158,16 @@ in
'') deletedUsers}
'';
environment.etc = mapAttrs' (name: { packages, ... }: {
name = "profiles/per-user/${name}";
value.source = pkgs.buildEnv {
name = "user-environment";
paths = packages;
inherit (config.environment) pathsToLink extraOutputsToInstall;
inherit (config.system.path) postBuild;
};
}) (filterAttrs (_: u: u.packages != []) cfg.users);
environment.profiles = [ "/etc/profiles/per-user/$USER" ];
};
}

View file

@ -57,6 +57,17 @@ with lib;
example = literalExample "pkgs.bashInteractive";
description = "The user's shell.";
};
packages = mkOption {
type = types.listOf types.package;
default = [];
example = literalExample "[ pkgs.firefox pkgs.thunderbird ]";
description = ''
The set of packages that should be made availabe to the user.
This is in contrast to <option>environment.systemPackages</option>,
which adds packages to all users.
'';
};
};
config = {

17
tests/users-packages.nix Normal file
View file

@ -0,0 +1,17 @@
{ config, pkgs, ... }:
{
users.knownUsers = [ "foo" ];
users.users.foo.uid = 42000;
users.users.foo.gid = 42000;
users.users.foo.description = "Foo user";
users.users.foo.isHidden = false;
users.users.foo.home = "/Users/foo";
users.users.foo.shell = "/run/current-system/sw/bin/bash";
users.users.foo.packages = [ pkgs.hello ];
test = ''
echo "checking for hello in /etc/profiles/per-user/foo" >&2
test -x /etc/profiles/per-user/foo/bin/hello
'';
}