Giter VIP home page Giter VIP logo

Comments (4)

DavSanchez avatar DavSanchez commented on May 20, 2024

Hi, here home-manager acts as a stand-alone installation. If it was a NixOS module then the reference to a home.nix file would be inside the nixosConfigurations attrset's modules:

    nixosConfigurations = {
      hostname = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            home-manager.users.jdoe = import ./home.nix;
            # Optionally, use home-manager.extraSpecialArgs to pass
            # arguments to home.nix
          }
        ];
      };
    };

What is discussed in #12 is that apparently a home-manager needs to be activated when used for the first time.

According to the home-manager manual section for stand-alone installs using flakes, you should do this first:

$ nix build --no-link <flake-uri>#homeConfigurations.jdoe.activationPackage
$ "$(nix path-info <flake-uri>#homeConfigurations.jdoe.activationPackage)"/activate

Then home-manager will be correctly sourced on the login shell and subsequent calls to home-manager switch --flake '<flake-uri>#jdoe' should work.

The manual seems to say that from 21.05 onwards you can do just home-manager switch --flake '<flake-uri>#jdoe' and it will be expanded to the correct activationPackage, but it did not work in my case in 22.05 (nor in a nix-darwin setup). I needed to activate it first using the above 2 commands before home-manager switch --flake '<flake-uri>#jdoe' started to work properly.

Before that, my shell was trying to source hm-session-vars.sh from the wrong path (complained that the file was missing). The activate step put the files in the correct place.

from nix-starter-configs.

Misterio77 avatar Misterio77 commented on May 20, 2024

@DavSanchez is correct, this template provides a standalone home-manager config. As they showed, it's pretty simple to use it as a NixOS module instead, if you prefer.

I would add, however, that getting the home-manager is easier than remembering that big nix build command: nix shell nixpkgs#home-manager should get you going.
You can alternatively use the provided shell.nix that automatically provides you with the latest nix (with flakes and nix-command enabled), git, and home-manager. Just run nix develop or nix-shell and you should be good to go.

from nix-starter-configs.

ParetoOptimalDev avatar ParetoOptimalDev commented on May 20, 2024

Thank you both for your help. Your answers make sense but leave me with some questions.

Doesn't using home-manager as a nixos module subsume the standalone home-manager case?

Plus it would seem to avoid the user not having home-manager like I did.

Are there downsides to using the home-manager module?

from nix-starter-configs.

Misterio77 avatar Misterio77 commented on May 20, 2024

Are there downsides to using the home-manager module?

The main one is just that you need to rebuild the system (including using sudo) when changing home configs, but it's mostly a personal preference.
It is worth noting that home-manager works on other distros and darwin, so having the standalone version available is nice to have, even if you mainly use NixOS.

The home-manager nixos module pretty much just creates a user systemd unit that calls the hm activation script, so they're not really incompatible. That means you can even combine the two, e.g. include your home config into your nixos system config, and iterate on it with home-manager switch.

from nix-starter-configs.

Related Issues (20)

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.