move all nix expressions to pkgs

This commit is contained in:
Jörg Thalheim 2022-05-15 07:48:48 +02:00
parent 0c20c6257b
commit 150afcb240
No known key found for this signature in database
6 changed files with 48 additions and 34 deletions

14
pkgs/cross-build.nix Normal file
View file

@ -0,0 +1,14 @@
{ sops-install-secrets, gox }:
sops-install-secrets.overrideAttrs (old: {
name = "cross-build";
nativeBuildInputs = old.nativeBuildInputs ++ [ gox ];
buildPhase = ''
(cd pkgs/sops-install-secrets && gox -os linux)
'';
doCheck = false;
installPhase = ''
touch $out $unittest
'';
fixupPhase = ":";
})

13
pkgs/lint.nix Normal file
View file

@ -0,0 +1,13 @@
{ sops-install-secrets, golangci-lint }:
sops-install-secrets.overrideAttrs (old: {
name = "golangci-lint";
nativeBuildInputs = old.nativeBuildInputs ++ [ golangci-lint ];
buildPhase = ''
HOME=$TMPDIR golangci-lint run --timeout 360s
'';
doCheck = false;
installPhase = ''
touch $out $unittest
'';
fixupPhase = ":";
})

View file

@ -0,0 +1,11 @@
{ buildGoModule, vendorSha256 }:
buildGoModule {
name = "sops-pgp-hook-test";
src = ../.;
inherit vendorSha256;
buildPhase = ''
go test -c ./pkgs/sops-pgp-hook
install -D sops-pgp-hook.test $out/bin/sops-pgp-hook.test
'';
}

28
pkgs/unit-tests.nix Normal file
View file

@ -0,0 +1,28 @@
{ pkgs ? import <nixpkgs> {}
}:
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
''}
'';
}