`hdn` 1.0.0: install a package with `hdn add pkgs.hello`

I’m pleased to announce the first stable release of my program, hdn.

hdn is a small utility that provides a poetry/cargo-like interface for quickly adding and removing your home-manager packages. It’s mainly geared towards people like me who use home-manager only to install packages, and not manage dotfiles.

Here are screenshots of it in action:

(1) Adding packages: multiple packages can be specified.

(2) hdn scans the list of packages before adding, so duplicates are never added.

(3) hdn automatically rolls back home.nix if home-manager fails.

I’ve been using it myself these past few weeks, and it’s been quite convenient! Hopefully it’s useful to you as well.

Let me know what you think, and in particular, please let me know if the binary releases are broken. Since I’m on macOS, I haven’t been able to test the Linux binaries.

Installation

cargo install hdn

or, a download a pre-built binary from the Releases page on GitHub.

5 Likes

How does it compare to using something like this and catting or anewing into a file (./pkgs)

pipe ./pkgs [
  fileContents
  (splitString "\n")
  (flip attrVals pkgs)
]

What is the difference between this and using users.users.<name>.packages?

To be honest, I’m not very familiar with the Nix expression language, so I’m not certain I understand what this is doing. By the looks of it, it’s editing the attribute, and you use anew (nifty tool, thanks for the link btw) to skip duplicates. Seems like a good idea. But, if I understand correctly, that doesn’t handle removing packages, or rolling back to the original version if home-manager fails.

I wasn’t sure myself, so I looked it up, and there have been some posts asking that same question:

2 Likes

TL’DR: security concerns

The need of sudo or another elevation mechanism that allows the user to generally change anything about the system.

1 Like

Hi there!

I’m using Nix w/ Home Manager on a non-NixOS GNU+Linux flavor to manage my CLI tools (otherwise, Flatpak FTW).

What would be the advantage of hdn over running home-manager edit?

I used to use home-manager edit, and I’m grateful that it exists. But, after a while of using it, I felt like there were too many steps involved just to install a package:

  1. run home-manager edit
  2. in your editor, navigate to the end of the home.packages attribute
  3. write your packages
  4. save and quit out of your editor
  5. run home-manager switch
  6. inspect the output, and undo your changes if you mistyped something

With hdn, it’s simplified to one step:

  1. run hdn add [your packages]

I had the exact same idea as hdn in my notebook written down: to avoid the long editing loop.
I love the sound of hdn so far – very excited to try it out.

How long till it’s in nixpkgs so I can add it via home-manager? :wink:

1 Like

I love the sound of hdn so far – very excited to try it out.

Glad to hear!

How long till it’s in nixpkgs so I can add it via home-manager?

Packaging it in nixpkgs would be a good idea, I’ll add that to my to-do list.