File tree Expand file tree Collapse file tree 6 files changed +86
-1
lines changed Expand file tree Collapse file tree 6 files changed +86
-1
lines changed Original file line number Diff line number Diff line change 1+ { }
Original file line number Diff line number Diff line change 1+ { }
Original file line number Diff line number Diff line change 1+ { }
Original file line number Diff line number Diff line change 1+ { }
Original file line number Diff line number Diff line change 1+ {
2+ nixpkgs ,
3+ self ,
4+ system ,
5+ } : let
6+ inherit
7+ ( self . packages . ${ system } )
8+ nixos-generate
9+ ;
10+
11+ pkgs = nixpkgs . legacyPackages . ${ system } ;
12+ in
13+ pkgs . runCommand "test-format-search-path" { } ''
14+ rc=$?
15+
16+ fail() {
17+ rc="$?"
18+
19+ if (( "$#" > 0 )); then
20+ printf 1>&2 -- "$@"
21+ else
22+ printf 1>&2 -- 'unknown error\n'
23+ fi
24+ }
25+
26+ run() {
27+ ${ nixos-generate } /bin/nixos-generate "$@"
28+ }
29+
30+ showFormatSearchPath() {
31+ run --show-format-search-path "$@"
32+ }
33+
34+ list() {
35+ run --list "$@"
36+ }
37+
38+ fixtures="${ self } /checks/fixtures/formats"
39+ builtin="${ nixos-generate } /share/nixos-generator/formats"
40+
41+ path="$(showFormatSearchPath)" || fail 'error running nixos-generate\n'
42+
43+ expected="$builtin"
44+
45+ [[ "$path" == "$expected" ]] \
46+ || fail 'expected format search path to contain:\n%s\ngot:\n%s\n' "$expected" "$path"
47+
48+ export NIXOS_GENERATORS_FORMAT_SEARCH_PATH="'' ${fixtures}/c:'' ${fixtures}/d"
49+
50+ path="$(showFormatSearchPath --format-search-path "'' ${fixtures}/b" --format-search-path "'' ${fixtures}/a")" \
51+ || fail 'error running nixos-generate\n'
52+
53+ expected="\
54+ '' ${fixtures}/a
55+ '' ${fixtures}/b
56+ '' ${fixtures}/c
57+ '' ${fixtures}/d
58+ $builtin"
59+
60+ [[ "$path" == "$expected" ]] \
61+ || fail 'expected format search path to contain:\n%s\ngot:\n%s\n' "$expected" "$path"
62+
63+ declare -A formats
64+ while read -r format; do
65+ formats["$format"]=1
66+ done < <(list --format-search-path "'' ${fixtures}/b" --format-search-path "'' ${fixtures}/a")
67+
68+ for format in foo bar baz quux; do
69+ [[ -n "'' ${formats["$format"]:-}" ]] \
70+ || fail 'expected formats to include %s\n' "$format"
71+ done
72+
73+ if (( rc == 0 )); then
74+ touch "$out"
75+ fi
76+
77+ exit "$rc"
78+ ''
Original file line number Diff line number Diff line change 151151 test-customize-format = import ./checks/test-customize-format.nix {
152152 inherit nixpkgs system ;
153153 } ;
154+ test-format-search-path = import ./checks/test-format-search-path.nix {
155+ inherit nixpkgs self system ;
156+ } ;
154157 in
155158 lib . mapAttrs makeLazyDrv (
156159 {
159162 nixos-generate
160163 ;
161164
162- inherit test-customize-format ;
165+ inherit test-customize-format test-format-search-path ;
163166
164167 is-formatted = import ./checks/is-formatted.nix {
165168 pkgs = nixpkgs . legacyPackages . ${ system } ;
You can’t perform that action at this time.
0 commit comments