summary refs log tree commit diff
path: root/pkgs/build-support/trivial-builders/test/writeShellApplication.nix
blob: 6ce6f0720fcf6a5691478fbcda2ee8f28bb8b8fc (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
/*
  Run with:

      cd nixpkgs
      nix-build -A tests.trivial-builders.writeShellApplication
*/

{ lib, writeShellApplication, runCommand }:
let
  pkg = writeShellApplication {
    name = "test-script";
    excludeShellChecks = [ "SC2016" ];
    text = ''
      echo -e '#!/usr/bin/env bash\n' \
       'echo "$SHELL"' > /tmp/something.sh  # this line would normally
                                            # ...cause shellcheck error
    '';
  };
in
  assert pkg.meta.mainProgram == "test-script";
  runCommand "test-writeShellApplication" { } ''

    echo Testing if writeShellApplication builds without shellcheck error...

    target=${lib.getExe pkg}

    touch $out
  ''