forked from Mic92/sops-nix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunit-tests.nix
29 lines (29 loc) · 848 Bytes
/
unit-tests.nix
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
{ pkgs ? import <nixpkgs> {}
, sudo ? "sudo"
}:
let
sopsPkgs = import ./. { inherit pkgs; };
in pkgs.stdenv.mkDerivation {
name = "env";
nativeBuildInputs = with pkgs; [
bashInteractive
gnupg
utillinux
nix
sopsPkgs.sops-pgp-hook-test
] ++ pkgs.lib.optional (pkgs.stdenv.isLinux) sopsPkgs.sops-install-secrets.unittest;
# allow to prefetch shell dependencies in build phase
dontUnpack = true;
installPhase = ''
echo $nativeBuildInputs > $out
'';
shellHook = ''
set -x
NIX_PATH=nixpkgs=${toString pkgs.path} TEST_ASSETS=$(realpath ./pkgs/sops-pgp-hook/test-assets) \
sops-pgp-hook.test
${pkgs.lib.optionalString (pkgs.stdenv.isLinux) ''
${sudo} TEST_ASSETS=$(realpath ./pkgs/sops-install-secrets/test-assets) \
unshare --mount --fork sops-install-secrets.test
''}
'';
}