mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
Merge pull request #127 from kalbasit/nix-darwin_user-packages
users: install user packages via users.users.<name?>.packages
This commit is contained in:
commit
ece03c592e
5 changed files with 56 additions and 6 deletions
|
@ -152,12 +152,11 @@ in
|
|||
|
||||
environment.systemPath = [ (makeBinPath cfg.profiles) "/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" ];
|
||||
|
||||
environment.profiles =
|
||||
[ # Use user, default and system profiles.
|
||||
"$HOME/.nix-profile"
|
||||
"/run/current-system/sw"
|
||||
"/nix/var/nix/profiles/default"
|
||||
];
|
||||
# Use user, default and system profiles.
|
||||
environment.profiles = mkMerge [
|
||||
(mkOrder 800 [ "$HOME/.nix-profile" ])
|
||||
[ "/run/current-system/sw" "/nix/var/nix/profiles/default" ]
|
||||
];
|
||||
|
||||
environment.pathsToLink = [ "/bin" "/share/locale" ];
|
||||
|
||||
|
|
|
@ -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 = mkOrder 900 [ "/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 = {
|
||||
|
|
|
@ -117,6 +117,7 @@ let
|
|||
tests.system-path = makeTest ./tests/system-path.nix;
|
||||
tests.system-shells = makeTest ./tests/system-shells.nix;
|
||||
tests.users-groups = makeTest ./tests/users-groups.nix;
|
||||
tests.users-packages = makeTest ./tests/users-packages.nix;
|
||||
tests.fonts = makeTest ./tests/fonts.nix;
|
||||
|
||||
}
|
||||
|
|
28
tests/users-packages.nix
Normal file
28
tests/users-packages.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
hello = pkgs.runCommand "hello-0.0.0" {} ''
|
||||
mkdir -p $out/bin $out/lib
|
||||
touch $out/bin/hello $out/lib/libhello.dylib
|
||||
'';
|
||||
in
|
||||
|
||||
{
|
||||
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 = [ hello ];
|
||||
|
||||
test = ''
|
||||
echo checking hello binary in /etc/profiles/per-user/foo/bin >&2
|
||||
test -e ${config.out}/etc/profiles/per-user/foo/bin/hello
|
||||
test "$(readlink -f ${config.out}/etc/profiles/per-user/foo/bin/hello)" = "${hello}/bin/hello"
|
||||
|
||||
echo checking for unexpected paths in /etc/profiles/per-user/foo/bin >&2
|
||||
test -e ${config.out}/etc/profiles/per-user/foo/lib/libhello.dylib && return
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue