Nix Package Offline Install

Hi,

I am new to Nix, but so far I am finding it very useful. I’d like to know if I can copy/tar a package installed by Nix from one computer to another that is not connected to the Internet.

I have a RHEL 7 workstation that is connected to the Internet and I was able to install podman version 3.1.0 via Nix. I have a bunch of RHEL 7 boxes that is not connected to the Internet. I’d like to know, in addition to install Nix on those offline boxes, what do I need to do so I could copy podman and all of the other dependencies packages/libraries over?

Thanks in advance!

1 Like

Hi, Welcome!

If you can access the second machine (without internet) from the first one at some point in thime, you can use nix copy to propate the config (you will need to nix build the configuration/packages before).

If you can only reach the second machine with a disk/usbstick, you can still ! :tada: :

On the first machine:

$ nix build your-config
# Create a binary cache
$ nix copy your-config file:///path/to/usbstick/folder

On the second:

# Load from binary cache
$ nix copy file:///path/to/usbstick/folder your-config

Hi,

Thanks for your reply!
I ran the command and got this error …

[htony@localhost nix]$ nix build podman-config
error: attribute ‘podman-config’ in selection path ‘podman-config’ not found

I have to transfer the files via CD/DVD.

Thanks again!!!

–Tony

Then follow the usbstick path

What is podman-config ?

Hi,

I got the same error even with “your-config”.

htony@localhost nix]$ nix build your-config
error: attribute ‘your-config’ in selection path ‘podman-config’ not found

Am I supposed to substitute your-config with something else?

Thanks!!

Tony

Oh yes, it is the thing you want to build, a package, en environment or a full nixos configuration ?

If you just want podman, then your-config is just podman.

If you want podman and extra tools, you could write an expression like this default.nix:

{pkgs ? import <nixpkgs> {} }:
{
  podman-config = pkgs.buildEnv {
    inherit ((import <nixpkgs/nixos> {}).config.system.path)
      pathsToLink ignoreCollisions postBuild;
   name = "podman-shell";
    paths = with pkgs; [ podman ];
  };
  #... other configurations go there ...
}

You will have to copy this file too and to use it on the other machine, just run nix build podman-config, and you will get a result link in your directory to access it.

1 Like