personal-effectivity-applic.../flake.nix

75 lines
2.3 KiB
Nix

{
description = "Personal Effectivity Application, version 2";
inputs = {
haskellNix.url = "github:input-output-hk/haskell.nix";
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, haskellNix }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
overlays = [
haskellNix.overlay
(final: prev: {
peaProject = final.haskell-nix.project' {
src = ./.;
compiler-nix-name = "ghc8107";
shell.tools = {
cabal = { };
hlint = { };
haskell-language-server = { };
};
};
})
];
pkgs = import nixpkgs {
inherit system overlays;
inherit (haskellNix) config;
};
flake = pkgs.peaProject.flake { };
in flake // {
checks.integration-test = let
sharedModule = { virtualisation.graphics = false; };
username = "authenticator";
pea-port = 8081;
in pkgs.nixosTest {
nodes = {
server = { config, pkgs, ... }: {
imports = [ sharedModule ];
networking.firewall.allowedTCPPorts = [ pea-port ];
users = {
mutableUsers = false;
users = {
root.password = "";
"${username}" = {
isSystemUser = true;
group = "${username}";
};
};
};
systemd.services.pea-srv = {
wantedBy = [ "multi-user.target" ];
after = [ "networking.target" ];
script = "${self.packages.${system}.default}/bin/pea-srv";
serviceConfig.User = username;
};
};
client = { config, pkgs, ... }: { imports = [ sharedModule ]; };
};
testScript = ''
server.wait_for_unit("pea-srv.service")
client.succeed(
"${pkgs.curl}/bin/curl http://server:${toString pea-port}/tasks"
)
'';
};
packages.default = flake.packages."PEA:exe:pea-srv";
devShells.default = flake.devShell;
});
}