# How can I declaratively install packages for myself without using home-manager?

**URL:** https://discourse.nixos.org/t/how-can-i-declaratively-install-packages-for-myself-without-using-home-manager/10133
**Category:** Help
**Created:** [November 21, 2020, 8:14pm UTC](https://discourse.nixos.org/t/how-can-i-declaratively-install-packages-for-myself-without-using-home-manager/10133 "2020-11-21T20:14:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![anon20203487](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@anon20203487](https://discourse.nixos.org/u/anon20203487)
#### Post date: [November 21, 2020, 8:14pm UTC](https://discourse.nixos.org/t/how-can-i-declaratively-install-packages-for-myself-without-using-home-manager/10133/1 "2020-11-21T20:14:11Z")

</div>

TL;DR: _I wanna make my own home manager with blackjack and flakes_

Hello, people! I am a bit confused.

Summarizing a bit: my usage of home-manager is simply install programs via `home.packages` list and manually edit dotfiles (I use org mode to help on it). Even when home-manager offers modules, I prefer to edit files by hand.

So my question is: how can I manage my home directory in a more handmade manner?  
My idea is to use something like

> $\> some-nix-command my-config.nix # output: some useful directory like `/nix/var/nix/profiles/per-user/<username>/...`  
> $\> edit-configuration # something like `emacs .bashrc .profile .config/...`  
> $\> use-the-system

Also, I want to use as much as possible teh new flakes infrastructure, specially to get rid of NIX\_PATH variable.

I was trying to follow the [Matej Cotman’s article](https://blog.matejc.com/blogs/myblog/control-your-packages-with-nix-environments) but I stuck because it uses the old Nix command.

---

<div class="post-metadata">

### Author: ![colemickens](https://discourse.nixos.org/user_avatar/discourse.nixos.org/colemickens/32/624_2.png) [@colemickens](https://discourse.nixos.org/u/colemickens)
#### Post date: [November 21, 2020, 8:26pm UTC](https://discourse.nixos.org/t/how-can-i-declaratively-install-packages-for-myself-without-using-home-manager/10133/2 "2020-11-21T20:26:19Z")

</div>

I don’t understand what you’re trying to achieve. If you don’t want to use HM modules and instead want to write config files by hand, that’s fine, you can use `home.file` to have those files symlinked in place.

---

<div class="post-metadata">

### Author: ![hmenke](https://discourse.nixos.org/user_avatar/discourse.nixos.org/hmenke/32/2369_2.png) [@hmenke](https://discourse.nixos.org/u/hmenke)
#### Post date: [November 21, 2020, 8:38pm UTC](https://discourse.nixos.org/t/how-can-i-declaratively-install-packages-for-myself-without-using-home-manager/10133/3 "2020-11-21T20:38:06Z")

</div>

I found this thread incredibly helpful.

> [@Declarative package management for normal users](https://discourse.nixos.org/t/declarative-package-management-for-normal-users/1823/2):
>
> There are multiple ways of managing declarative profiles. 1) Attrset, compatible with imperative use of nix-env [lnl-overlay.nix · GitHub](https://git.io/fAQHW) ; 2) buildEnv, providing more control over the paths that are linked into the profile [Expression for a buildEnv-based declarative user environment. · GitHub](https://git.io/fp0aU) ; 3) home-manager, providing nixos-like config for your ~ [GitHub - nix-community/home-manager: Manage a user environment using Nix [maintainer=@rycee]](https://github.com/rycee/home-manager)

It links to a lot of very nice examples. Personally I’m using method 2) `buildEnv`. If you have some specific questions about it, feel free to ask.

---

<div class="post-metadata">

### Author: ![anon20203487](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@anon20203487](https://discourse.nixos.org/u/anon20203487)
#### Post date: [November 22, 2020, 2:48am UTC](https://discourse.nixos.org/t/how-can-i-declaratively-install-packages-for-myself-without-using-home-manager/10133/4 "2020-11-22T02:48:40Z")

</div>

Very fine, @hmenke. Now I need to adapt it to the flakes format somehow.

---

<div class="post-metadata">

### Author: ![anon20203487](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@anon20203487](https://discourse.nixos.org/u/anon20203487)
#### Post date: [November 23, 2020, 12:56am UTC](https://discourse.nixos.org/t/how-can-i-declaratively-install-packages-for-myself-without-using-home-manager/10133/5 "2020-11-23T00:56:25Z")

</div>

@colemickens yes, I can just “forget” those things in HM. But

- It defeats the purposes of HM;
- I just want to understand it and do it in my own way. HM looks a bit “hiding the things” to me.

(Nothing against HM, of course. I just think it is not to me.)

* * *

@hmenke have you tried to use the new Flakes feature of Nix in that home setup?

---

<div class="post-metadata">

### Author: ![hmenke](https://discourse.nixos.org/user_avatar/discourse.nixos.org/hmenke/32/2369_2.png) [@hmenke](https://discourse.nixos.org/u/hmenke)
#### Post date: [November 23, 2020, 9:52am UTC](https://discourse.nixos.org/t/how-can-i-declaratively-install-packages-for-myself-without-using-home-manager/10133/6 "2020-11-23T09:52:09Z")

</div>

I don’t think you can use Flakes with it yet because the `buildEnv` approach (as well as the overlay approach) are based on `nix-env`. However, you can still use pinning to bypass Nix channels like so

```auto
let
  nixexprs = fetchTarball {
    url = "https://nixos.org/channels/nixos-20.09/nixexprs.tar.xz";
  };
  pkgs = import nixexprs { };

in with pkgs;
buildEnv {
  # ...
}

```
