test: refactor, by factoring 'pkgs' in its own module

We don't need per-file package overlays, since we don't envision having too many of them. Whenever possible, get them from nixpkgs, to keep our tests nimble.
This commit is contained in:
Sridhar Ratnakumar 2024-03-07 14:46:57 -05:00 committed by Sridhar Ratnakumar
parent 31151df8e4
commit 3e849aa744
5 changed files with 30 additions and 46 deletions

View File

@ -34,22 +34,6 @@
"type": "github"
}
},
"nixpkgs-grafana": {
"locked": {
"lastModified": 1696630667,
"narHash": "sha256-kO67pYOeT/6m9BnPO+zNHWnC4eGiW87gIAJ+e8f3gwU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b604023e0a5549b65da3040a07d2beb29ac9fc63",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b604023e0a5549b65da3040a07d2beb29ac9fc63",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
@ -87,7 +71,6 @@
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"nixpkgs-grafana": "nixpkgs-grafana",
"process-compose-flake": "process-compose-flake",
"systems": "systems"
}

View File

@ -5,24 +5,15 @@
systems.url = "github:nix-systems/default";
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
services-flake = { };
# Deal with broken packages:
# grafana is broken on aarch64-darwin: https://github.com/NixOS/nixpkgs/issues/273998
nixpkgs-grafana.url = "github:nixos/nixpkgs/b604023e0a5549b65da3040a07d2beb29ac9fc63";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.process-compose-flake.flakeModule
./nix/pkgs.nix
];
perSystem = { self', inputs', pkgs, system, lib, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
# Required for elastic search
config.allowUnfree = true;
overlays = import ./overlays { inherit system inputs' lib; };
};
process-compose =
let
mkPackageFor = mod:

29
test/nix/pkgs.nix Normal file
View File

@ -0,0 +1,29 @@
{ inputs, ... }:
{
perSystem = { self', inputs', pkgs, system, lib, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
# Required for elastic search
config.allowUnfree = true;
overlays = [
(self: super: lib.optionalAttrs super.stdenv.isDarwin {
# grafana is broken on aarch64-darwin, but works on older nixpkgs:
# https://github.com/NixOS/nixpkgs/issues/273998
grafana = (builtins.getFlake "github:nixos/nixpkgs/b604023e0a5549b65da3040a07d2beb29ac9fc63").legacyPackages.${system}.grafana;
# Disable tests, because they are failing on darwin:
# https://github.com/NixOS/nixpkgs/issues/281214
pgadmin4 = super.pgadmin4.overrideAttrs (_: {
doInstallCheck =
false;
});
})
];
};
};
}

View File

@ -1,15 +0,0 @@
{ inputs', lib, system, ... }:
let
isDarwin = system == "x86_64-darwin" || system == "aarch64-darwin";
in
lib.optionals isDarwin [
(import ./pgadmin.nix)
(self: super: {
grafana = inputs'.nixpkgs-grafana.legacyPackages.grafana;
})
]
++
[
]

View File

@ -1,4 +0,0 @@
final: prev: {
# Because tests are failing on darwin: https://github.com/NixOS/nixpkgs/issues/281214
pgadmin4 = prev.pgadmin4.overrideAttrs (_: { doInstallCheck = false; });
}