1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

home-manager: point <home-manager> to project root

Before this path would point to the modules path. Using the project
root instead makes it possible to set `<home-manager>` to point to a
downloadable archive of Home Manager. This should make it
significantly easier to install and keep Home Manager up to date.

To match this change we also deprecate the Home Manager option

    programs.home-manager.modulesPath

and instead ask users to use

    programs.home-manager.path
This commit is contained in:
Robert Helgesson 2017-10-21 20:51:28 +02:00
parent 5605e46acb
commit bf3a8c6383
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86
6 changed files with 96 additions and 21 deletions

View file

@ -1,2 +1,14 @@
# Simply defer to the home-manager script derivation.
import ./home-manager
{ pkgs ? import <nixpkgs> {} }:
rec {
home-manager = import ./home-manager {
inherit pkgs;
path = ./.;
};
install =
pkgs.runCommand
"home-manager-install"
{ propagatedBuildInputs = [ home-manager ]; }
"";
}

View file

@ -1,14 +1,14 @@
{ pkgs
# Extra path to the Home Manager modules. If set then this path will
# be tried before `$HOME/.config/nixpkgs/home-manager/modules` and
# `$HOME/.nixpkgs/home-manager/modules`.
, modulesPath ? null
# Extra path to Home Manager. If set then this path will be tried
# before `$HOME/.config/nixpkgs/home-manager` and
# `$HOME/.nixpkgs/home-manager`.
, path ? null
}:
let
modulesPathStr = if modulesPath == null then "" else modulesPath;
pathStr = if path == null then "" else path;
in
@ -24,8 +24,7 @@ pkgs.stdenv.mkDerivation {
--subst-var-by bash "${pkgs.bash}" \
--subst-var-by coreutils "${pkgs.coreutils}" \
--subst-var-by less "${pkgs.less}" \
--subst-var-by MODULES_PATH '${modulesPathStr}' \
--subst-var-by HOME_MANAGER_EXPR_PATH "${./home-manager.nix}"
--subst-var-by HOME_MANAGER_PATH '${pathStr}'
'';
meta = with pkgs.stdenv.lib; {

View file

@ -40,13 +40,13 @@ function setConfigFile() {
exit 1
}
function setHomeManagerModulesPath() {
local modulesPath
for modulesPath in "@MODULES_PATH@" \
"$HOME/.config/nixpkgs/home-manager/modules" \
"$HOME/.nixpkgs/home-manager/modules" ; do
if [[ -e "$modulesPath" ]] ; then
export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$modulesPath"
function setHomeManagerNixPath() {
local path
for path in "@HOME_MANAGER_PATH@" \
"$HOME/.config/nixpkgs/home-manager" \
"$HOME/.nixpkgs/home-manager" ; do
if [[ -e "$path" || "$path" =~ ^https?:// ]] ; then
export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$path"
return
fi
done
@ -54,7 +54,7 @@ function setHomeManagerModulesPath() {
function doBuildAttr() {
setConfigFile
setHomeManagerModulesPath
setHomeManagerNixPath
local extraArgs="$*"
@ -67,7 +67,7 @@ function doBuildAttr() {
fi
nix-build \
"@HOME_MANAGER_EXPR_PATH@" \
"<home-manager/home-manager/home-manager.nix>" \
$extraArgs \
--argstr confPath "$HOME_MANAGER_CONFIG" \
--argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"

View file

@ -9,7 +9,7 @@ with pkgs.lib;
let
env = import <home-manager> {
env = import <home-manager/modules> {
configuration =
let
conf = import confPath;

View file

@ -370,6 +370,46 @@ in
chosen version.
'';
}
{
time = "2017-10-23T22:54:33+00:00";
condition = config.programs.home-manager.modulesPath != null;
message = ''
The 'programs.home-manager.modulesPath' option is now
deprecated and will be removed on November 24, 2017. Please
use the option 'programs.home-manager.path' instead.
'';
}
{
time = "2017-10-23T23:10:29+00:00";
condition = !config.programs.home-manager.enable;
message = ''
Unfortunately, due to some internal restructuring it is no
longer possible to install the home-manager command when
having
home-manager = import ./home-manager { inherit pkgs; };
in the '~/.config/nixpkgs/config.nix' package override
section. Attempting to use the above override will now
result in the error "cannot coerce a set to a string".
To resolve this please delete the override from the
'config.nix' file and either link the Home Manager overlay
$ ln -s ~/.config/nixpkgs/home-manager/overlay.nix \
~/.config/nixpkgs/overlays/home-manager.nix
or add
programs.home-manager.enable = true;
to your Home Manager configuration. The latter is
recommended as the home-manager tool then is updated
automatically whenever you do a switch.
'';
}
];
};
}

View file

@ -16,6 +16,19 @@ in
programs.home-manager = {
enable = mkEnableOption "Home Manager";
path = mkOption {
type = types.nullOr types.str;
default = null;
example = "$HOME/devel/home-manager";
description = ''
The default path to use for Home Manager. If this path does
not exist then
<filename>$HOME/.config/nixpkgs/home-manager</filename> and
<filename>$HOME/.nixpkgs/home-manager</filename> will be
attempted.
'';
};
modulesPath = mkOption {
type = types.nullOr types.str;
default = null;
@ -25,17 +38,28 @@ in
path does not exist then
<filename>$HOME/.config/nixpkgs/home-manager/modules</filename>
and <filename>$HOME/.nixpkgs/home-manager/modules</filename>
will be attempted.
will be attempted. DEPRECATED: Use
<varname>programs.home-manager.path</varname> instead.
'';
};
};
};
config = mkIf cfg.enable {
assertions = [{
assertion = cfg.path == null || cfg.modulesPath == null;
message = "Cannot simultaneously use "
+ "'programs.home-manager.path' and "
+ "'programs.home-manager.modulesPath'.";
}];
home.packages = [
(import ../../home-manager {
inherit pkgs;
inherit (cfg) modulesPath;
path =
if cfg.modulesPath != null
then "$(dirname ${cfg.modulesPath})"
else cfg.path;
})
];