summaryrefslogtreecommitdiff
path: root/flake.nix
blob: aced115888ad99ce1ba5d77909933e8ac72ffd46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
  description = "Toolchain for Actiontec's T3200 Series DSL Gateway";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

  outputs =
    { self, nixpkgs, ... }:
    let
      inherit (nixpkgs) lib;

      # Since we're building 32-bit linux packages, we can only (usually) run this on
      # systems that are x86{,-64} and Linux themselves. This should evaluate to
      # [ "x86_64-linux" "i686-linux" ]
      systems = lib.intersectLists lib.platforms.linux lib.platforms.x86;

      forAllSystems = lib.genAttrs systems;
      nixpkgsFor = forAllSystems (
        system:
        let
          native = nixpkgs.legacyPackages.${system};
        in
        {
          inherit native;
          cross = {
            i686 = native.pkgsi686Linux;
          };
        }
      );
    in
    {
      formatter = forAllSystems (system: nixpkgsFor.${system}.native.nixfmt-rfc-style);

      packages = forAllSystems (
        system:
        let
          nixpkgsFor' = nixpkgsFor.${system};
          pkgs = nixpkgsFor'.native;
          pkgsi686 = nixpkgsFor'.cross.i686;

          # https://opensource.actiontec.com/t3200.html
          #
          # some of these releases contain different toolchains
          # no idea if any of these are meaningful changes, but lets
          # support multiple for fun
          releases = [
            {
              version = "31.164l.32";
              hash = "sha256-SRS9N1dpmvAksF6zWudUUv6DWL2TQVCte3x1PL8d02g=";
            }
            {
              version = "31.164l.33";
              hash = "sha256-tN31mGv27vUoIncM6xadhyiMdal4pdtFgn5tu5oFtF4=";
            }
          ];

          releaseInfo = map (
            { version, hash }:
            {
              inherit version;
              src = pkgs.fetchzip {
                url = "https://opensource.actiontec.com/sourcecode/t3200x/bt_bcm963xx_t3200_${version}_gpl_consumer_release.tar.gz";
                inherit hash;
                stripRoot = false;
              };
            }
          ) releases;

          releasePackages = map (
            { src, version }:
            {
              name = "toolchain-" + version;
              value = pkgsi686.callPackage ./crosstools-arm-gcc.nix {
                sourceRelease = src;
                releaseVersion = version;
              };
            }
          ) releaseInfo;
        in
        lib.listToAttrs releasePackages // { default = self.packages.${system}."toolchain-31.164l.33"; }
      );
    };
}