Reputation: 1937
What I think that I've understood about home-manager.
Instead of using
nix-env iA packageToBeInstalled
you write a list of package in a file (/home/nixos/.config/nixpkgs/home.nix that I from now on call just home.nix) you run
home-manager switch
and the package are installed.
But I have already installed some packages with nix-env. (home-manager for instance) I would like to have my configuration save just in home.nix in order to just have to import it and execute home-manager switch to import the exact same configuration in a other OS. Therefore I need a command replicating my configuration in home.nix.
Upvotes: 0
Views: 1021
Reputation: 7359
I am not aware of a tool that fully automates this.
The nix-env
list of installed packages is maintained in ~/.nix-profile/manifest.nix
, but does not contain the attribute path, which is the "name" you need to use in such configuration files.
To find the attribute paths for the things you've installed, you may first create an index of sorts based on your current nixpkgs (NIX_PATH etc):
nix-env -qaP >packages.tmp
and then use it to look up each package.
Here's a one-liner that doesn't work for all packages.
nix-env -q | while read name; do grep "$name" <packages.tmp; done
So make sure to read through nix-env -q
yourself and look up anything that's missing using for example https://search.nixos.org/packages.
To finalize, remove the imperatively installed packages with nix-env -e
, check nix-env -q
, and rm packages.tmp
.
Upvotes: 1