1

I am using nix-env with multiple channels and local overrides to install packages on macOS and Nixos Linux on multiple computers. Sometimes I exclude packages from updates, because of problems. All this leads to quite some manual effort to maintain my user environments. I would like to use nix-copy-closure to copy as much as possible from one computer to another. I know it's possible to copy the profile as a whole using nix-copy-closure but how would I install it then? If that is not going to work, is it possible to copy all installed packages and then install them one by one.

I am aware of the following related question: https://stackoverflow.com/questions/28159181/how-to-copy-a-nix-profile But it's solution is not satisfactory to me, therefore I've created this question.

1 Answer 1

1

Create a "metapackge", a file like mypkgs.nix:

{ pkgs ? import <nixpkgs> {}, ... } :
pkgs.buildEnv {
  name = "mypkgs";
  paths = with pkgs; [ bat cowsay ];
}

nix-build mypkgs.nix will build the package and print its path, which you can use with nix-copy-closure and nix-env -i.

You don't need to copy mypkgs.nix to the remote host, since you can install a store path directly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .