summaryrefslogtreecommitdiffstats
path: root/systems/qi/firmware.nix
blob: f8a8b52477b20e45b5716710312975c827a4e59e (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
# Based on
# https://git.pavluk.org/chayleaf/dotfiles
#   ff839c3153ba2ed6547b2c8cf5ef1f8247f6fbcd
#   system/hardware/oneplus-enchilada/pkgs.nix and
#   system/hardware/oneplus-enchilada/default.nix

{ lib, pkgs, ... }: {
  nixpkgs.overlays = [(self: super: {
    oneplus-enchilada.firmware =
      self.stdenvNoCC.mkDerivation {
        name = "firmware-oneplus-sdm845";
        src = self.fetchFromGitLab {
          owner = "sdm845-mainline";
          repo = "firmware-oneplus-sdm845";
          rev = "176ca713448c5237a983fb1f158cf3a5c251d775";
          hash = "sha256-ZrBvYO+MY0tlamJngdwhCsI1qpA/2FXoyEys5FAYLj4=";
        };
        installPhase = ''
          cp -a . "$out"
          cd "$out/lib/firmware/postmarketos"
          find . -type f,l | xargs -i bash -c 'mkdir -p "$(dirname "../$1")" && mv "$1" "../$1"' -- {}
          cd "$out/usr"
          find . -type f,l | xargs -i bash -c 'mkdir -p "$(dirname "../$1")" && mv "$1" "../$1"' -- {}
          cd ..
          find "$out/lib/firmware/postmarketos" "$out/usr" | tac | xargs rmdir
        '';
        dontStrip = true;
        # not actually redistributable, but who cares
        meta.license = lib.licenses.unfreeRedistributableFirmware;
      };
  })];

  mobile.device.firmware =
    # Override ${inputs.mobile-nixos}/devices/oneplus-enchilada/default.nix
    lib.mkForce pkgs.oneplus-enchilada.firmware;
}