Merge PR #1460
This commit is contained in:
commit
a063b73d5c
10 changed files with 87 additions and 6 deletions
|
@ -313,5 +313,22 @@ home-manager.useUserPackages = true;
|
||||||
value in the future.
|
value in the future.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
By default, Home Manager uses a private <literal>pkgs</literal> instance
|
||||||
|
that is configured via the <option>home-manager.users.<name>.nixpkgs</option> options.
|
||||||
|
To instead use the global <literal>pkgs</literal> that is configured via
|
||||||
|
the system level <option>nixpkgs</option> options, set
|
||||||
|
</para>
|
||||||
|
<programlisting language="nix">
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
This saves an extra Nixpkgs evaluation, adds consistency, and removes the
|
||||||
|
dependency on <envar>NIX_PATH</envar>, which is otherwise used for
|
||||||
|
importing Nixpkgs.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
</section>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
outputs = { self, nixpkgs }: rec {
|
outputs = { self, nixpkgs }: rec {
|
||||||
nixosModules.home-manager = import ./nixos;
|
nixosModules.home-manager = import ./nixos;
|
||||||
|
|
||||||
|
darwinModules.home-manager = import ./nix-darwin;
|
||||||
|
|
||||||
lib = {
|
lib = {
|
||||||
homeManagerConfiguration = { configuration, system, homeDirectory
|
homeManagerConfiguration = { configuration, system, homeDirectory
|
||||||
, username
|
, username
|
||||||
|
|
|
@ -189,6 +189,7 @@ let
|
||||||
(loadModule ./services/xscreensaver.nix { })
|
(loadModule ./services/xscreensaver.nix { })
|
||||||
(loadModule ./services/xsuspender.nix { condition = hostPlatform.isLinux; })
|
(loadModule ./services/xsuspender.nix { condition = hostPlatform.isLinux; })
|
||||||
(loadModule ./systemd.nix { })
|
(loadModule ./systemd.nix { })
|
||||||
|
(loadModule ./targets/darwin.nix { condition = hostPlatform.isDarwin; })
|
||||||
(loadModule ./targets/generic-linux.nix { condition = hostPlatform.isLinux; })
|
(loadModule ./targets/generic-linux.nix { condition = hostPlatform.isLinux; })
|
||||||
(loadModule ./xcursor.nix { })
|
(loadModule ./xcursor.nix { })
|
||||||
(loadModule ./xresources.nix { })
|
(loadModule ./xresources.nix { })
|
||||||
|
|
14
modules/targets/darwin.nix
Normal file
14
modules/targets/darwin.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin {
|
||||||
|
# Install MacOS applications to the user environment.
|
||||||
|
home.file."Applications/Home Manager Apps".source = let
|
||||||
|
apps = pkgs.buildEnv {
|
||||||
|
name = "home-manager-applications";
|
||||||
|
paths = config.home.packages;
|
||||||
|
pathsToLink = "/Applications";
|
||||||
|
};
|
||||||
|
in "${apps}/Applications";
|
||||||
|
};
|
||||||
|
}
|
|
@ -10,11 +10,12 @@ let
|
||||||
|
|
||||||
hmModule = types.submoduleWith {
|
hmModule = types.submoduleWith {
|
||||||
specialArgs = { lib = extendedLib; };
|
specialArgs = { lib = extendedLib; };
|
||||||
modules = [(
|
modules = [
|
||||||
{name, ...}: {
|
({ name, ... }: {
|
||||||
imports = import ../modules/modules.nix {
|
imports = import ../modules/modules.nix {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
lib = extendedLib;
|
lib = extendedLib;
|
||||||
|
useNixpkgsModule = !cfg.useGlobalPkgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
@ -24,8 +25,8 @@ let
|
||||||
home.username = config.users.users.${name}.name;
|
home.username = config.users.users.${name}.name;
|
||||||
home.homeDirectory = config.users.users.${name}.home;
|
home.homeDirectory = config.users.users.${name}.home;
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
)];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
@ -38,6 +39,24 @@ in
|
||||||
<option>users.users.‹name?›.packages</option> option.
|
<option>users.users.‹name?›.packages</option> option.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
useGlobalPkgs = mkEnableOption ''
|
||||||
|
using the system configuration's <literal>pkgs</literal>
|
||||||
|
argument in Home Manager. This disables the Home Manager
|
||||||
|
options <option>nixpkgs.*</option>
|
||||||
|
'';
|
||||||
|
|
||||||
|
backupFileExtension = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
example = "backup";
|
||||||
|
description = ''
|
||||||
|
On activation move existing files by appending the given
|
||||||
|
file extension rather than exiting with an error.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
verbose = mkEnableOption "verbose output on activation";
|
||||||
|
|
||||||
users = mkOption {
|
users = mkOption {
|
||||||
type = types.attrsOf hmModule;
|
type = types.attrsOf hmModule;
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -77,7 +96,12 @@ in
|
||||||
system.activationScripts.postActivation.text =
|
system.activationScripts.postActivation.text =
|
||||||
concatStringsSep "\n" (mapAttrsToList (username: usercfg: ''
|
concatStringsSep "\n" (mapAttrsToList (username: usercfg: ''
|
||||||
echo Activating home-manager configuration for ${username}
|
echo Activating home-manager configuration for ${username}
|
||||||
sudo -u ${username} -i ${usercfg.home.activationPackage}/activate
|
sudo -u ${username} -i ${pkgs.writeShellScript "activation-${username}" ''
|
||||||
|
${lib.optionalString (cfg.backupFileExtension != null)
|
||||||
|
"export HOME_MANAGER_BACKUP_EXT=${lib.escapeShellArg cfg.backupFileExtension}"}
|
||||||
|
${lib.optionalString cfg.verbose "export VERBOSE=1"}
|
||||||
|
exec ${usercfg.home.activationPackage}/activate
|
||||||
|
''}
|
||||||
'') cfg.users);
|
'') cfg.users);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,8 @@ import nmt {
|
||||||
./modules/programs/zplug
|
./modules/programs/zplug
|
||||||
./modules/programs/zsh
|
./modules/programs/zsh
|
||||||
./modules/xresources
|
./modules/xresources
|
||||||
|
] ++ lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
|
||||||
|
./modules/targets-darwin
|
||||||
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
||||||
./meta # Suffices to run on one platform.
|
./meta # Suffices to run on one platform.
|
||||||
./modules/misc/debug
|
./modules/misc/debug
|
||||||
|
@ -93,6 +95,6 @@ import nmt {
|
||||||
./modules/services/window-managers/i3
|
./modules/services/window-managers/i3
|
||||||
./modules/services/window-managers/sway
|
./modules/services/window-managers/sway
|
||||||
./modules/systemd
|
./modules/systemd
|
||||||
./modules/targets
|
./modules/targets-linux
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
20
tests/modules/targets-darwin/darwin.nix
Normal file
20
tests/modules/targets-darwin/darwin.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
darwinTestApp = pkgs.runCommandLocal "target-darwin-example-app" { } ''
|
||||||
|
mkdir -p $out/Applications
|
||||||
|
touch $out/Applications/example-app
|
||||||
|
'';
|
||||||
|
|
||||||
|
in {
|
||||||
|
config = {
|
||||||
|
home.packages = [ darwinTestApp ];
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists 'home-files/Applications/Home Manager Apps/example-app'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
1
tests/modules/targets-darwin/default.nix
Normal file
1
tests/modules/targets-darwin/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ targets-darwin = ./darwin.nix; }
|
Loading…
Reference in a new issue