summary refs log tree commit diff
path: root/pkgs/build-support/upstream-updater/attrset-to-dir.sh
blob: 2d99ef110a1c5edb42793ed38e320f8f001cb449 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/sh

[ -n "$2" ] && NIXPKGS_ALL="$2";
[ -z "$NIXPKGS_ALL" ] && [ -d "/etc/nixos/nixpkgs" ] && NIXPKGS_ALL="/etc/nixos/nixpkgs";
[ -z "$NIXPKGS_ALL" ] && [ -d "$HOME/nixpkgs" ] && NIXPKGS_ALL="$HOME/nixpkgs";
[ -z "$NIXPKGS_ALL" ] && {
  echo "Cannot find Nixpkgs source. Please specify it via NIXPKGS_ALL or second command line argument"
  exit 1
};

derivation="$(nix-instantiate --show-trace - << EOF
let 
  pkgs = import "${NIXPKGS_ALL}" {};
  attrSet = import "${1}";
in
  pkgs.attrSetToDir attrSet
EOF
)"
echo "Derivation is: $derivation" >&2
output="$(nix-store -r "$derivation")"
echo "$output/attributes"