about summary refs log tree commit diff
path: root/nixos/modules/installer/tools/nixos-typecheck.sh
blob: f9557be0c50e10392054a120aa0f6fc9ff0b8ccd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /bin/sh
#! @shell@

if [ -x "@shell@" ]; then export SHELL="@shell@"; fi;

set -e

showSyntax() {
cat >&1 << EOF
nixos-typecheck
usage:
  nixos-typecheck [action] [args]
where:
  action = silent | printAll | printUnspecified | getSpecs
    with default action: printUnspecified
  args = any argument supported by nix-build
EOF
}


# Parse the command line.
extraArgs=()
action=printUnspecified

while [ "$#" -gt 0 ]; do
    i="$1"; shift 1
    case "$i" in
      --help)
        showSyntax
        ;;
      silent|printAll|printUnspecified|getSpecs)
        action="$i"
        ;;
      *)
        extraArgs="$extraArgs $i"
        ;;
    esac
done


if [ "$action" = silent ]; then
    nix-build --no-out-link '<nixpkgs/nixos>' -A typechecker.silent $extraArgs
elif [ "$action" = printAll ]; then
    nix-build --no-out-link '<nixpkgs/nixos>' -A typechecker.printAll $extraArgs
elif [ "$action" = printUnspecified ]; then
    nix-build --no-out-link '<nixpkgs/nixos>' -A typechecker.printUnspecified $extraArgs
elif [ "$action" = getSpecs ]; then
    ln -s $(nix-build --no-out-link '<nixpkgs/nixos>' -A typechecker.specifications $extraArgs)/share/doc/nixos/options-specs.json specifications.json
else
    showSyntax
    exit 1
fi