Ctrl K
ComunidadGuías…

flake.nix

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
{
  description = "Grafana Loki";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs =
    { self
    , nixpkgs
    , nixpkgs-unstable
    , flake-utils
    ,
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        # The go version in nixpkgs often trails behind the latest by a few
        # days. Overlay to pin to the exact version go.mod expects.
        goOverlay = final: prev: {
          go_1_27 = prev.go_1_27.overrideAttrs (old: rec {
            version = "1.27.3";
            src = prev.fetchurl {
              url = "https://go.dev/dl/go${version}.src.tar.gz";
              hash = "sha256-bndJA1zzYPBrJXXRYup535/ajvZxiJ5cN1+OUHd/Jrs=";
            };
          });
        };

        base = import nixpkgs {
          inherit system;
          config = {
            allowUnfree = true;
          };
          overlays = [ goOverlay ];
        };
        unstable = import nixpkgs-unstable {
          inherit system;
          config = {
            allowUnfree = true;
          };
          overlays = [ goOverlay ];
        };

        pkgs = base // {
          inherit (unstable) go_1_27;
          buildGoModule = unstable.buildGo127Module;
        };
      in
      rec {
        packages = import ./nix {
          inherit self pkgs;
          inherit (pkgs) lib;
        };

        defaultPackage = packages.loki;

        apps = {
          lint = {
            type = "app";
            program =
              with pkgs;
              "${(writeShellScriptBin "lint.sh" ''
                ${nixpkgs-fmt}/bin/nixpkgs-fmt --check ${self}/flake.nix ${self}/nix/*.nix
                ${statix}/bin/statix check ${self}
              '')}/bin/lint.sh";
          };
        };

        devShell = pkgs.mkShell {
          nativeBuildInputs =
            with pkgs;
            [
              (pkgs.callPackage ./nix/packages/chart-releaser.nix {
                inherit pkgs;
                inherit (pkgs) buildGoModule fetchFromGitHub;
              })

              chart-testing
              gcc
              go_1_27
              golangci-lint
              gotools
              helm-docs
              nettools
              nixpkgs-fmt
              statix
              yamllint
            ]
            # Docker image archives cannot be sourced as shell build inputs.
            ++ (builtins.attrValues (builtins.removeAttrs packages [ "loki-helm-test-docker" ]));
        };
      }
    );
}