Skip to content

Instantly share code, notes, and snippets.

@k0001
Created February 27, 2017 17:14
Show Gist options
  • Save k0001/8d0ec9bfcf03aa4d28b8009c0c771338 to your computer and use it in GitHub Desktop.
Save k0001/8d0ec9bfcf03aa4d28b8009c0c771338 to your computer and use it in GitHub Desktop.
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/d2c451f967e344df14e63985963e57fb64a6c58d.tar.gz
#! nix-shell -i bash -p xz
# Outputs a xz tarball of all run-time and build-time dependencies
# of the given nix store paths that are provided as arguments.
function fexport()
{
set -x
nix-store --export $(nix-store -qR --include-outputs $(nix-store -qd "$@")) \
| xz -z -c -0
}
# Inputs `fexport`'s output.
function fimport()
{
set -x
xz -d -c | nix-store --import
}
case "$1" in
import) shift; fimport $@;;
export) shift; fexport $@;;
*) echo "USAGE: $0 (import|export [NIX-STORE-PATH ...] )"; exit 1 ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment