|
| 1 | +{ pkgs, devshell, runTest }: |
| 2 | +let inherit (pkgs) lib; in |
| 3 | +{ |
| 4 | + normalizeCommandsNested = |
| 5 | + let |
| 6 | + commands = (import ../../nix/commands/examples.nix { inherit pkgs; }).nested; |
| 7 | + check = (import ../../nix/commands/lib.nix { inherit pkgs; }).normalizeCommandsNested commands == [ |
| 8 | + { |
| 9 | + category = "category 1"; |
| 10 | + command = null; |
| 11 | + expose = false; |
| 12 | + help = "[package] jq description"; |
| 13 | + name = "a.b.jq-1"; |
| 14 | + package = pkgs.jq; |
| 15 | + prefix = "nix run .#"; |
| 16 | + } |
| 17 | + { |
| 18 | + category = "category 1"; |
| 19 | + command = null; |
| 20 | + expose = false; |
| 21 | + help = "[package] yq description"; |
| 22 | + name = "a.b.yq-1"; |
| 23 | + package = pkgs.yq-go; |
| 24 | + prefix = "nix run ../#"; |
| 25 | + } |
| 26 | + { |
| 27 | + category = "category 1"; |
| 28 | + command = null; |
| 29 | + expose = false; |
| 30 | + help = "Portable command-line YAML processor"; |
| 31 | + name = "a.b.yq-2"; |
| 32 | + package = pkgs.yq-go; |
| 33 | + prefix = "nix run .#"; |
| 34 | + } |
| 35 | + { |
| 36 | + category = "category 1"; |
| 37 | + command = null; |
| 38 | + expose = false; |
| 39 | + help = "a package manager for JavaScript"; |
| 40 | + name = "npm"; |
| 41 | + package = pkgs.nodePackages.npm; |
| 42 | + prefix = "nix run .#"; |
| 43 | + } |
| 44 | + { |
| 45 | + category = "category 1"; |
| 46 | + command = null; |
| 47 | + expose = true; |
| 48 | + help = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system"; |
| 49 | + name = "a.b.findutils"; |
| 50 | + package = pkgs.findutils; |
| 51 | + prefix = ""; |
| 52 | + } |
| 53 | + { |
| 54 | + category = "category 1"; |
| 55 | + command = null; |
| 56 | + expose = false; |
| 57 | + help = "Command-line benchmarking tool"; |
| 58 | + name = "a.b.hyperfine"; |
| 59 | + package = pkgs.hyperfine; |
| 60 | + prefix = ""; |
| 61 | + } |
| 62 | + { |
| 63 | + category = "category 1"; |
| 64 | + command = "${lib.getExe pkgs.gawk} $@"; |
| 65 | + expose = false; |
| 66 | + help = "[command] run awk"; |
| 67 | + name = "a.b.awk"; |
| 68 | + package = null; |
| 69 | + prefix = ""; |
| 70 | + } |
| 71 | + { |
| 72 | + category = "category 1"; |
| 73 | + command = "${lib.getExe pkgs.jq} $@"; |
| 74 | + expose = false; |
| 75 | + help = "[command] run jq"; |
| 76 | + name = "a.b.jq-2"; |
| 77 | + package = null; |
| 78 | + prefix = ""; |
| 79 | + } |
| 80 | + { |
| 81 | + category = "category 1"; |
| 82 | + command = ''printf "hello\n"''; |
| 83 | + expose = false; |
| 84 | + help = ''[command] print "hello"''; |
| 85 | + name = "command with spaces"; |
| 86 | + package = null; |
| 87 | + prefix = ""; |
| 88 | + } |
| 89 | + { |
| 90 | + category = "category 1"; |
| 91 | + command = null; |
| 92 | + expose = true; |
| 93 | + help = null; |
| 94 | + name = pkgs.python3.name; |
| 95 | + package = pkgs.python3; |
| 96 | + prefix = ""; |
| 97 | + } |
| 98 | + { |
| 99 | + category = "category 1"; |
| 100 | + command = null; |
| 101 | + expose = true; |
| 102 | + help = "[package] vercel description"; |
| 103 | + name = pkgs.nodePackages.vercel.name; |
| 104 | + package = pkgs.nodePackages.vercel; |
| 105 | + prefix = ""; |
| 106 | + } |
| 107 | + { |
| 108 | + category = "category 1"; |
| 109 | + command = null; |
| 110 | + expose = true; |
| 111 | + help = null; |
| 112 | + name = pkgs.nodePackages.yarn.name; |
| 113 | + package = pkgs.nodePackages.yarn; |
| 114 | + prefix = ""; |
| 115 | + } |
| 116 | + { |
| 117 | + category = "category 1"; |
| 118 | + command = null; |
| 119 | + expose = true; |
| 120 | + help = null; |
| 121 | + name = null; |
| 122 | + package = pkgs.gnugrep; |
| 123 | + prefix = ""; |
| 124 | + } |
| 125 | + { |
| 126 | + category = "category 1"; |
| 127 | + command = null; |
| 128 | + expose = true; |
| 129 | + help = "run hello"; |
| 130 | + name = "run cowsay"; |
| 131 | + package = pkgs.cowsay; |
| 132 | + prefix = ""; |
| 133 | + } |
| 134 | + { |
| 135 | + category = "category 1"; |
| 136 | + command = "${lib.getExe pkgs.perl} $@"; |
| 137 | + expose = true; |
| 138 | + help = "run perl"; |
| 139 | + name = "run perl"; |
| 140 | + package = null; |
| 141 | + prefix = ""; |
| 142 | + } |
| 143 | + { |
| 144 | + category = "category 1"; |
| 145 | + command = null; |
| 146 | + expose = true; |
| 147 | + help = "format Nix files"; |
| 148 | + name = "nix fmt"; |
| 149 | + package = null; |
| 150 | + prefix = ""; |
| 151 | + } |
| 152 | + { |
| 153 | + category = "category-2"; |
| 154 | + command = null; |
| 155 | + expose = true; |
| 156 | + help = null; |
| 157 | + name = null; |
| 158 | + package = pkgs.go; |
| 159 | + prefix = ""; |
| 160 | + } |
| 161 | + { |
| 162 | + category = "category-2"; |
| 163 | + command = null; |
| 164 | + expose = true; |
| 165 | + help = "[package] run hello "; |
| 166 | + name = pkgs.hello.name; |
| 167 | + package = pkgs.hello; |
| 168 | + prefix = ""; |
| 169 | + } |
| 170 | + { |
| 171 | + category = "category-2"; |
| 172 | + command = null; |
| 173 | + expose = true; |
| 174 | + help = null; |
| 175 | + name = pkgs.nixpkgs-fmt.name; |
| 176 | + package = pkgs.nixpkgs-fmt; |
| 177 | + prefix = ""; |
| 178 | + } |
| 179 | + ]; |
| 180 | + in |
| 181 | + runTest "simple" { } '' |
| 182 | + ${ |
| 183 | + if check |
| 184 | + then ''printf "OK"'' |
| 185 | + else ''printf "Not OK"; exit 1'' |
| 186 | + } |
| 187 | + ''; |
| 188 | +} |
0 commit comments