test(grafana): Use older nixpkgs for grafana on macOS

This speeds up build, because we no longer have to compile grafana locally and wait for eternity.

cf. https://github.com/NixOS/nixpkgs/issues/273998
This commit is contained in:
Sridhar Ratnakumar 2024-03-07 14:30:08 -05:00 committed by Sridhar Ratnakumar
parent 5a54b621ab
commit 31151df8e4
4 changed files with 27 additions and 37 deletions

View File

@ -34,6 +34,22 @@
"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",
@ -71,6 +87,7 @@
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"nixpkgs-grafana": "nixpkgs-grafana",
"process-compose-flake": "process-compose-flake",
"systems": "systems"
}

View File

@ -5,6 +5,10 @@
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; } {
@ -12,12 +16,12 @@
imports = [
inputs.process-compose-flake.flakeModule
];
perSystem = { self', pkgs, system, lib, ... }: {
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 lib; };
overlays = import ./overlays { inherit system inputs' lib; };
};
process-compose =
let

View File

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

View File

@ -1,33 +0,0 @@
(final: prev: {
# grafana is broken on aarch64-darwin: https://github.com/NixOS/nixpkgs/issues/273998
grafana = (prev.callPackage "${prev.path}/pkgs/servers/monitoring/grafana" {
buildGoModule = args: prev.buildGoModule (args // {
vendorHash = "sha256-Ig7Vj3HzMVOjT6Tn8aS4W000uKGoPOCFh2yIfyEWn78=";
proxyVendor = true;
offlineCache = args.offlineCache.overrideAttrs (oa: {
buildPhase = final.lib.replaceStrings
[ "yarn config set --json supportedArchitectures.os '[ \"linux\" ]'" ]
[ "yarn config set --json supportedArchitectures.os '[ \"linux\", \"darwin\" ]'" ]
oa.buildPhase;
outputHash =
if final.stdenv.isLinux then
"sha256-IlNe89T6cfXGy1WY73Yd+wg1bt9UuBCkKSDkrazybQM="
else
"sha256-pqInPfZEg2tcp8BXg1nnMddRZ1yyZ6KQa2flWd4IZSU=";
});
# exclude the package instead of `rm pkg/util/xorm/go.{mod,sum}`
# turns out, only removing the files is not enough, fails with:
# > pkg/services/sqlstore/migrator/dialect.go:9:2: module ./pkg/util/xorm: reading pkg/util/xorm/go.mod: open /build/source/pkg/util/xorm/go.mod: no such file or directory
# both excluding and removing (`go.mod`) is also not an option because excludedPackages expects a `go.mod`
excludedPackages = args.excludedPackages ++ [ "xorm" ];
postConfigure = final.lib.replaceStrings [ "rm pkg/util/xorm/go.{mod,sum}" ] [ "" ] args.postConfigure;
});
});
})