mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-05 08:17:01 +00:00
users: install user packages via users.users.<name?>.packages
This commit is contained in:
parent
94d2d20a5f
commit
4ffabd184a
3 changed files with 39 additions and 0 deletions
|
@ -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" ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
17
tests/users-packages.nix
Normal 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
|
||||
'';
|
||||
}
|
Loading…
Add table
Reference in a new issue