GithubHelp home page GithubHelp logo

ryantm / home-manager-template Goto Github PK

View Code? Open in Web Editor NEW
111.0 9.0 5.0 23 KB

A quick-start template for using home-manager in a more reproducible way.

Home Page: https://github.com/ryantm/home-manager-template

License: Creative Commons Zero v1.0 Universal

Nix 99.19% Shell 0.81%
nix nixos home-manager

home-manager-template's Introduction

home-manager template

This provides a quick-start template for using home-manager in a more reproducible way. You don't have to install home-manager, and it uses pinning.

Why?

home-manager is a great way to manage user-specific configuration ("dotfiles") in a reproducible way. This template takes reproducibility another step by making it so you do not need to install home-manager to use it, and do not need to install home-manager configuration files in a specific place.

Also, since this uses niv to pin nixpkgs and home-manager, you do not need nixpkgs on your path and can be sure the build will be the same on any computer.

Prerequisites

You must have nix installed on your machine.

curl -L https://nixos.org/nix/install | sh

Tutorial

  1. Click the "Use this template" button on GitHub

  2. Clone your repository onto the computer you want to configure

  3. Update dependencies (home-manager and nixpkgs) to the latest version:

    ./update-dependencies.sh

    which is just shorthand for:

    nix-shell --run "niv update"
    
  4. Edit ./home.nix to be how you want it.

  5. Run the switch script to switch to your configuration:

    ./switch.sh

    which is just shorthand for:

    nix-shell --run "home-manager switch"
    

Caveats

Since we do not install home-manager, you need to let home-manager manage your shell, otherwise it will not be able to add its hooks to your profile, e.g. no shell variables will get set by home-manager. Please consult home-manager documentation for exact required steps.

Also since we do not install home-manager, you cannot run the home-manager script from any directory and expect it to work. It must be run from within the nix-shell. (This is actually a feature!)

home-manager-template's People

Contributors

qrilka avatar ryantm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

home-manager-template's Issues

nix fails to record a dependency when home-manager is built this way

I noticed something weird about the way this installs home-manager. Starting with a fresh checkout of the repo:

$ git reset --hard
HEAD is now at 5725905 update nixpkgs-unstable, stop using nixpkgs-channels
$ nix-shell

[nix-shell:~/gitprojects/public/home-manager-template]$ type home-manager

home-manager is /nix/store/kh0l3n7aba7gqz1asspbb55pkgx2w1p1-home-manager/bin/home-manager

Let's look at what nix thinks the dependencies of home-manager are:

[nix-shell:~/gitprojects/public/home-manager-template]$ nix-store --query --references /nix/store/kh0l3n7aba7gqz1asspbb55pkgx2w1p1-home-manager/bin/home-manager

/nix/store/7fdm1ij6f7xwjmhpici1bh3xh08n0sp7-coreutils-8.31
/nix/store/98an38bw0fwk6a5mickblc0h07jf00vz-gnused-4.8
/nix/store/chs6kqcqk2vmzmrckaa11dvm3qljcdni-less-551
/nix/store/k8p54jg8ipvnfz435mayf5bnqhw4qqap-bash-4.4-p23
/nix/store/ny7vshs45d5k193ql3b51dak0hjwwqc2-findutils-4.7.0

But look, there's a store path in there that was not picked up:

[nix-shell:~/gitprojects/public/home-manager-template]$ grep home-manager-src /nix/store/kh0l3n7aba7gqz1asspbb55pkgx2w1p1-home-manager/bin/home-manager

    for path in "/nix/store/qxdxvvbcfh2b39hd52zj1n2f6s24vnsc-home-manager-src" \

[nix-shell:~/gitprojects/public/home-manager-template]$ 

I can reproduce this basic thing just by running nix-build https://github.com/nix-community/home-manager/archive/refs/heads/master.zip -A home-manager so it's not necessarily a problem with this repository. And it probably won't cause a problem with the way this repository is structured. But it means that if you set up a gcroot for home-manager and collect garbage, you'll be left with a broken home-manager. Or if you try to use nix-copy-closure to copy home-manager somewhere, it will fail to copy the "home-manager-src" path.

What's going on?

Is nix the only prerequisite?

I have followed the instruction listed in the README and in the end I don't have any commands in my ~/.nix-profile/bin and thus switch.sh doesn't install anything.
Any idea what could I be doing wrong?
One note though that I don't use NixOS on this machine - I have Gentoo here.

do not use/update this - it's not working / tested

    "home-manager": {
        "branch": "master",
        "description": "Manage a user environment using Nix",
        "homepage": "https://rycee.gitlab.io/home-manager/",
        "owner": "rycee",
        "repo": "home-manager",
        "rev": "8537920706fafab12a2c2a138dfb6f5c35a6b240",
        "sha256": "1rkwiyag1i0r7ms6y6fl7m610z4rlbwmvja617bi710hybhsx8y9",
        "type": "tarball",
        "url": "https://github.com/rycee/home-manager/archive/8537920706fafab12a2c2a138dfb6f5c35a6b240.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    },
warning: unknown setting 'experimental-features'
warning: unknown setting 'experimental-features'
error: executing 'git': No such file or directory
error: executing 'git': No such file or directory
error: while evaluating the attribute 'buildCommand' of the derivation 'home-manager-generation' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/pkgs/build-support/trivial-builders.nix:7:7:
while evaluating the attribute 'text' of the derivation 'activation-script' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/pkgs/build-support/trivial-builders.nix:7:7:
while evaluating 'mkCmd' at /nix/store/m8i7r0j9ib3jph8azpcqpa3dlmicbzkv-source/modules/home-environment.nix:502:17, called from undefined position:
while evaluating the attribute 'data' at /nix/store/m8i7r0j9ib3jph8azpcqpa3dlmicbzkv-source/modules/lib/dag.nix:91:37:
while evaluating the attribute 'data' at /nix/store/m8i7r0j9ib3jph8azpcqpa3dlmicbzkv-source/modules/lib/dag.nix:85:9:
while evaluating the attribute 'data' at undefined position:
while evaluating 'g' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/attrsets.nix:276:19, called from undefined position:
while evaluating anonymous function at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:98:72, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/attrsets.nix:279:20:
while evaluating the attribute 'value' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:471:9:
while evaluating the option `home.activation.installPackages.data':
while evaluating the attribute 'mergedValue' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:503:5:
while evaluating the attribute 'values' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:497:9:
while evaluating the attribute 'values' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:596:7:
while evaluating anonymous function at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:483:28, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:483:17:
while evaluating definitions from `/nix/store/m8i7r0j9ib3jph8azpcqpa3dlmicbzkv-source/modules/home-environment.nix':
while evaluating 'dischargeProperties' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:555:25, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:484:137:
while evaluating the attribute 'value' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:338:44:
while evaluating the attribute 'passAsFile' of the derivation 'home-manager-path' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/pkgs/build-support/trivial-builders.nix:7:7:
while evaluating the attribute 'packages' at undefined position:
while evaluating 'g' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/attrsets.nix:276:19, called from undefined position:
while evaluating anonymous function at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:98:72, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/attrsets.nix:279:20:
while evaluating the attribute 'value' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:471:9:
while evaluating the option `home.packages':
while evaluating the attribute 'mergedValue' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:503:5:
while evaluating 'merge' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/types.nix:300:20, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:505:59:
while evaluating anonymous function at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/types.nix:301:35, called from undefined position:
while evaluating anonymous function at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/lists.nix:116:29, called from undefined position:
while evaluating anonymous function at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/types.nix:302:21, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/lists.nix:116:32:
while evaluating the attribute 'optionalValue' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:515:5:
while evaluating the attribute 'values' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:497:9:
while evaluating the attribute 'values' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:596:7:
while evaluating anonymous function at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:483:28, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:483:17:
while evaluating definitions from `/nix/store/m8i7r0j9ib3jph8azpcqpa3dlmicbzkv-source/modules/programs/firefox.nix':
while evaluating 'dischargeProperties' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:555:25, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:484:137:
while evaluating the attribute 'value' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/types.nix:306:38:
while evaluating the attribute 'package.override' at undefined position:
while evaluating 'g' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/attrsets.nix:276:19, called from undefined position:
while evaluating anonymous function at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:98:72, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/attrsets.nix:279:20:
while evaluating the attribute 'value' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:471:9:
while evaluating the option `programs.firefox.package':
while evaluating the attribute 'mergedValue' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:503:5:
while evaluating the attribute 'values' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:497:9:
while evaluating the attribute 'values' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:596:7:
while evaluating anonymous function at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:483:28, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:483:17:
while evaluating definitions from `/home/ae/ae_share_VM/z_DS_setup/home-manager/home.nix':
while evaluating 'dischargeProperties' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:555:25, called from /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:484:137:
while evaluating the attribute 'value' at /nix/store/ia8qfk4dyv21j956ccmaf6gy9zq7x650-source/lib/modules.nix:338:44:
program 'git' failed with exit code 1

There are 137 unread and relevant news items.
Read them by running the command 'home-manager news'.

One more prerequisite

I have spent man hours last night and also some time today trying to find out why I get an error from Stack on 1 of 2 mostly the same Ubuntu machines. And I use Stack installed using HM and based on this template. It appears that I was missing $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh in my ~/.bashrc and a workaround for locales wasn't working correctly.
It would be useful to have this documented. Thanks.

Installation fails at Update dependencies with "cannot coerce null to a string"

First thanks for the template,
I tried to follow the installation instructions, but it fails already in the first step.

error: cannot coerce null to a string

       at /nix/store/cl859pbyw47jzn4jn6ybiwayl0zby8ns-nixpkgs-unstable-src/pkgs/stdenv/generic/make-derivation.nix:192:19:

          191|         // (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) {
          192|           name = "${attrs.pname}-${attrs.version}";
             |                   ^
          193|         } // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) {
(use '--show-trace' to show detailed location information)

Full Trace:

error: cannot coerce null to a string

       at /nix/store/cl859pbyw47jzn4jn6ybiwayl0zby8ns-nixpkgs-unstable-src/pkgs/stdenv/generic/make-derivation.nix:192:19:

          191|         // (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) {
          192|           name = "${attrs.pname}-${attrs.version}";
             |                   ^
          193|         } // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) {

       … while evaluating the derivation attribute 'name'

       at /nix/store/cl859pbyw47jzn4jn6ybiwayl0zby8ns-nixpkgs-unstable-src/pkgs/stdenv/generic/make-derivation.nix:192:11:

          191|         // (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) {
          192|           name = "${attrs.pname}-${attrs.version}";
             |           ^
          193|         } // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) {

       … while evaluating the attribute 'depsBuildBuild' of the derivation 'gmp-6.2.0'

       at /nix/store/cl859pbyw47jzn4jn6ybiwayl0zby8ns-nixpkgs-unstable-src/pkgs/development/libraries/gmp/6.x.nix:14:3:

           13| let self = stdenv.mkDerivation rec {
           14|   name = "gmp-6.2.0";
             |   ^
           15|

       … while evaluating the attribute 'buildInputs' of the derivation 'coreutils-8.31'

       at /nix/store/cl859pbyw47jzn4jn6ybiwayl0zby8ns-nixpkgs-unstable-src/pkgs/stdenv/generic/make-derivation.nix:192:11:

          191|         // (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) {
          192|           name = "${attrs.pname}-${attrs.version}";
             |           ^
          193|         } // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) {

       … while evaluating the attribute 'configurePhase' of the derivation 'QuickCheck-2.13.2'

       at /nix/store/cl859pbyw47jzn4jn6ybiwayl0zby8ns-nixpkgs-unstable-src/pkgs/development/haskell-modules/generic-builder.nix:291:3:

          290| stdenv.mkDerivation ({
          291|   name = "${pname}-${version}";
             |   ^
          292|

       … while evaluating the attribute 'buildInputs' of the derivation 'attoparsec-0.13.2.4'

       at /nix/store/cl859pbyw47jzn4jn6ybiwayl0zby8ns-nixpkgs-unstable-src/pkgs/development/haskell-modules/generic-builder.nix:291:3:

          290| stdenv.mkDerivation ({
          291|   name = "${pname}-${version}";
             |   ^
          292|

       … while evaluating the attribute 'buildInputs' of the derivation 'aeson-1.4.7.1'

       at /nix/store/cl859pbyw47jzn4jn6ybiwayl0zby8ns-nixpkgs-unstable-src/pkgs/development/haskell-modules/generic-builder.nix:291:3:

          290| stdenv.mkDerivation ({
          291|   name = "${pname}-${version}";
             |   ^
          292|

       … while evaluating the attribute 'buildInputs' of the derivation 'niv-0.2.18'

       at /nix/store/cl859pbyw47jzn4jn6ybiwayl0zby8ns-nixpkgs-unstable-src/pkgs/development/haskell-modules/generic-builder.nix:291:3:

          290| stdenv.mkDerivation ({
          291|   name = "${pname}-${version}";
             |   ^
          292|

       … while evaluating the attribute 'buildInputs' of the derivation 'home-manager-shell'

       at /Users/yk/nixfiles/shell.nix:11:3:

           10|
           11|   name = "home-manager-shell";
             |   ^
           12|

Is this error maybe related to not being able to determine the platform (=darwin)?
I have Nix 2.4 installed on macOS Big Sur, so I should be good to go.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.