Ninlives / relocatable.nix

A nix bundler that produces relocatable deployment script for nix store paths.
60 stars 2 forks source link

relocatable.nix

This flake provide a nix bundler to package nix derivations into a single script that can deploy the target derivation to (hopefully) any distro.

Benefits

Usage

Package

To package chromium:

nix bundle --bundler github:Ninlives/relocatable.nix nixpkgs#chromium

After build, the script should be available at ./chromium-<version>-deploy/bin/chromium-<version>.deploy.

Deploy

To deploy chromium on another machine, copy the script and execute the following on the target machine:

./chromium-<version>.deploy -d /path/to/target/directory

After a few seconds you should be able to run chromium by executing /path/to/target/directory/root/bin/chromium.

Deploy to Remote Server

Use the -s option to specify a ssh server as the target for deployment, i.e. :

./chromium-<version>.deploy -s <user>@<host> -o 'additional ssh options' -d /path/to/remote/target/directory

Update an Existing Deployment

Deployment will not overwrite existing files, by default they will produce error messages. And it will not try to replace existing symlink to the root path (which is /path/to/target/directory/root by default). However, if you are trying to update an existing deployment, specify a -u flag, i.e.:

./chromium-<version>.deploy -d /path/to/target/directory -u

The script will skip the existing files and replace the symlink to point to the new root path. This may increase the disk usage if some old paths are no longer used.

NOTE the new deployment may contain store paths that are different from the previous deployment but extracted to same paths, skip these paths may cause unknown problems. This is because the hash part in the store paths will be cut off according to the target directory in order to keep the length. In case of any problems, try delete all paths and perform fresh deployment again.

Verify Integrity

To verify the integrity of the above script, just run:

./chromium-<version>.deploy -v

This operation requires sha256sum command.

Requirement

The following commands are required to run the deployment operation, which should be available on most distros:

To deploy to a remote server, the following commands are required on the local machine:

The following commands are used on the remote server in addition to above commands:

The following commands are required for integrity verification: