# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0

{ ... }@ch:
let nixpkgsConfig = {
  allowUnfree = true;
  permittedInsecurePackages = [
    "p7zip-16.02"
  ];
}; in
rec {
  inherit nixpkgsConfig;
  nixpkgs = import ./nixpkgs {
    config = nixpkgsConfig;
  };
  nixos = import ./nixpkgs/nixos;
  nixeval = import ./nixpkgs/nixos/lib/eval-config.nix;
  buildGo =
    let orig = import ./tvl/nix/buildGo { pkgs = nixpkgs; };
    in orig // {
      program = args:
        let
          origOut = orig.program args;
        in origOut // {
          dockerImage = nixpkgs.dockerTools.buildImage {
            name = args.name;
            config = {
              Cmd = [ "${origOut}/bin/${args.name}" ];
              Env = [
                "SSL_CERT_FILE=${nixpkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
              ];
            };
          };
        };
    };
  readTree = import ./tvl/nix/readTree {};
  gopkgs = readTree ch ./gopkgs;
}