types,module,tests: run shellcheck on scripts before running them in NixOS tests

This commit is contained in:
Lily Foster 2023-01-30 15:36:51 -05:00 committed by lassulus
parent 9afae0ba36
commit 0accdf4e20
5 changed files with 38 additions and 25 deletions

View file

@ -193,6 +193,15 @@ rec {
description = "Mount script";
};
/* Writer for optionally checking bash scripts before writing them to the store
writeCheckedBash :: AttrSet -> str -> str -> derivation
*/
writeCheckedBash = { pkgs, checked ? false, noDeps ? false }: pkgs.writers.makeScriptWriter {
interpreter = if noDeps then "/usr/bin/env bash" else "${pkgs.bash}/bin/bash";
check = lib.optionalString checked "${pkgs.shellcheck}/bin/shellcheck";
};
/* Takes a disko device specification, returns an attrset with metadata