Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

home-manager:init at 2017-10-11 #30330

Merged
merged 12 commits into from Dec 30, 2017
Merged

home-manager:init at 2017-10-11 #30330

merged 12 commits into from Dec 30, 2017

Conversation

pasqui23
Copy link
Contributor

@pasqui23 pasqui23 commented Oct 11, 2017

Motivation for this change

home-manager is a manager of user environments using nix

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@bjornfor bjornfor requested a review from rycee October 12, 2017 06:16
--subst-var-by MODULES_PATH '${modulesPathStr}' \
--subst-var-by HOME_MANAGER_EXPR_PATH "${dot}.nix"

wrapProgram $out/bin/home-manager --prefix NIX_PATH : home-manager=${src}/modules
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting NIX_PATH here could set

--subst-var-by MODULES_PATH '${if modulesPath == null then "${src}/modules" else modulesPath}'

above. Then a user could override the path to the modules, if they want, but by default it should use the downloaded ones.

@@ -1115,6 +1115,8 @@ with pkgs;

hid-listen = callPackage ../tools/misc/hid-listen { };

home-manager = callPackage ../applications/misc/home-manager {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Home Manager would be considered a tool rather than an application since it is not intended for interactive use.

@rycee
Copy link
Member

rycee commented Oct 12, 2017

It would be really nice to have Home Manager be installable directly from Nixpkgs but I've avoided it thus far due to the general difficulty posed by keeping the modules up-to-date. Basically, whenever something changes in the Home Manager modules we'd have to bump the version of the Nixpkgs package. Maybe it is not a big problem for Nixpkgs unstable but once it ends up in a stable version things get trickier, I guess.

#Taken directly from
#https://github.com/rycee/home-manager/blob/9c1b3735b402346533449efc741f191d6ef578dd/home-manager/default.nix

{ pkgs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arguments should be made more "standard". I.e., instead of pulling everything from pkgs, should include stdenv, fetchFromGitHub, bash, coreutils, etc. here.


pkgs.stdenv.mkDerivation rec{
name = "home-manager-${version}";
version="2017-10-11";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have spaces around =.

@peterhoeg
Copy link
Member

I understand this is taken verbatim from upstream, but it really requires quite a bit of cleanup to be ready for merging.

@pasqui23
Copy link
Contributor Author

Just integrated @rycee's suggestions.
As for nixos stable,it would just pin to a stable revision of the repository,just like any other program that is fetched from GitHub.

Thus the nixpkgs stable and unstable would point to different revisions,and the stable one would be frozen to where it was when nixpkgs was frozen.

Copy link
Member

@peterhoeg peterhoeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the issues are minor.

#Taken directly from
#https://github.com/rycee/home-manager/blob/9c1b3735b402346533449efc741f191d6ef578dd/home-manager/default.nix

{ pkgs,bash,coreutils,less,stdenv,makeWrapper,fetchFromGitHub
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We don't need pkgs
  2. We typically put a space after comma ,

, modulesPath ? null
}:

stdenv.mkDerivation rec{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after rec

stdenv.mkDerivation rec{
name = "home-manager-${version}";
version = "2017-10-11";
src=fetchFromGitHub{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before and after =

rev = "7e6f3364bcf0a0ec838aa4853f550a9a7b5ed027";
sha256 = "04wl0jpha19fsnyc5a8y4pkss9by468k0i5w5bjswnaz792yji6v";
};
buildInputs=[makeWrapper];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. nativeBuildInputs not buildInputs for makeWrapper
  2. = spaces
  3. Space after [ and before ].

sha256 = "04wl0jpha19fsnyc5a8y4pkss9by468k0i5w5bjswnaz792yji6v";
};
buildInputs=[makeWrapper];
phases = [ "installPhase" ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably in general don't want to override phases. Instead specifically exclude the phases you don't need. In this case that will probably be dontBuild = true;.

'';

meta = with stdenv.lib; {
description = "A user environment configurator";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about license?


meta = with stdenv.lib; {
description = "A user environment configurator";
maintainers = [ maintainers.rycee ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be maintainers = with maintainers; [ rycee ];

@pasqui23
Copy link
Contributor Author

Ok why the the Travis build is failing?

@rycee
Copy link
Member

rycee commented Oct 21, 2017

The Travis failure seems unrelated to your PR.

@pasqui23
Copy link
Contributor Author

Ok,I am trying to update home-manager but with the following default.nix i get only error: file 'home-manager/home-manager/home-manager.nix' was not found in the Nix search path (add it using $NIX_PATH or -I) when doing home-manager switch


{ bash, coreutils, less, stdenv, makeWrapper, fetchFromGitHub

  # 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`.
, confPath ? ""
}:

stdenv.mkDerivation rec {
  name = "home-manager-${version}";
  version = "2017-11-22";
  src = fetchFromGitHub{
    owner = "rycee";
    repo = "home-manager";
    rev = "3c875267afdac6348e5e7177df10364db8bb5edd";
    sha256 = "0wz73dsjpa4847n3j24lm7s9il622pgmhrqmjibzka9bk5wl4wzs";
  };
  nativeBuildInputs = [ makeWrapper ];
  dontBuild = true;

  installPhase = let
    dot = "${src}/home-manager/home-manager" ;
    mod = if modulesPath == null then "${src}/modules" else modulesPath;

  in ''
    install -v -D -m755 ${dot} $out/bin/home-manager

    substituteInPlace $out/bin/home-manager \
      --subst-var-by bash "${bash}" \
      --subst-var-by coreutils "${coreutils}" \
      --subst-var-by less "${less}" \
      --subst-var-by MODULES_PATH '${mod}:${dot}.nix' \
      --subst-var-by HOME_MANAGER_EXPR_PATH "${dot}.nix"\
      --subst-var-by HOME_MANAGER_PATH '${confPath}'

  '';

  meta = with stdenv.lib; {
    description = "A user environment configurator";
    maintainers = with maintainers; [ rycee ];
    platforms = platforms.linux;
    license = licenses.mit;
  };
}

@rycee
Copy link
Member

rycee commented Nov 22, 2017

HM was in nix-community/home-manager@bf3a8c6 changed to only use HOME_MANAGER_PATH. I.e. the substitutions MODULES_PATH and HOME_MANAGER_EXPR_PATH were removed. So to fix your issue I believe you can change the line

--subst-var-by HOME_MANAGER_PATH '${confPath}'

to read

--subst-var-by HOME_MANAGER_PATH '${src}'

This change was made to support the new installation instructions and also using Home Manager as a NixOS module.

My suggestion is still to install HM separately from Nixpkgs for now and use the programs.home-manager.enable option to automatically keep it up-to-date.

@pasqui23
Copy link
Contributor Author

I would like if @peterhoeg could review this pr,now that all automatic checks have passed

@peterhoeg
Copy link
Member

Just a few minor nitpicks:

a) the documentation at the top isn't correct - it isn't taken verbatim but adapted from
b) the spacing is odd - sometimes you have no blank lines between attributes and others (like inside the installPhase) you have extra blank lines

@peterhoeg peterhoeg merged commit 0dd7d21 into NixOS:master Dec 30, 2017
@peterhoeg
Copy link
Member

Thanks @pasqui23 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants