summaryrefslogtreecommitdiffstats
path: root/flake.nix
blob: 752d69451dfcda34cc2c86f2e043b7fbb9586893 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{
  description = "A basic example robotnix configuration";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05";
  inputs.robotnix.url = "github:danielfullmer/robotnix";

  outputs = { self, nixpkgs, robotnix }:
    let
      baseUrl = "https://ota.ahem.wtf";
      common = {
        apps = {
          bromite.enable = true;
          fdroid.enable = true;

          updater.enable = true;
        };

        microg.enable = true;

        /*
        webview.bromite = {
          enable = true;
          availableByDefault = true;
        };
        */

        # signing.enable = true;
        # signing.keyStorePath = "/var/secrets/android-keys"; # A _string_ of the path for the key store.

        # Build with ccache
        ccache.enable = true;
      };
    in
    {
      # "dailydriver" is an arbitrary user-chosen name for this particular
      # configuration.  Change it to something meaningful for you, perhaps just
      # the device name if you only have one of this kind of device.
      robotnixConfigurations.fp3 = robotnix.lib.robotnixSystem ({ config, pkgs, ... }: {
        imports = [ common ];

        device = "FP3";
        flavor = "lineageos";
        apps.updater.url = "${baseUrl}/fp3/";
      });

      robotnixConfigurations.fp2 = robotnix.lib.robotnixSystem ({ config, pkgs, ... }: {
        imports = [ common ];

        device = "FP2";
        flavor = "lineageos";
        apps.updater.url = "${baseUrl}/fp2/";
      });

      # This provides a convenient output which allows you to build the image by
      # simply running "nix build" on this flake.
      # Build other outputs with (for example): "nix build .#robotnixConfigurations.dailydriver.ota"
      defaultPackage.x86_64-linux = self.robotnixConfigurations.fp3.img;

      hydraJobs.robotnixConfigurations = with nixpkgs.legacyPackages.x86_64-linux; {
        fp3.otaDir = self.robotnixConfigurations.fp2.otaDir;
        fp3.products = with self.robotnixConfigurations.fp3;
          runCommandLocal
            "hydra-fp3-products-${config.buildNumber}"
            { }
            ''
              mkdir -p $out/nix-support

              cp "${bootImg}" $out/boot.img
              cp "${factoryImg}" $out/FP3-factory-${config.buildNumber}.zip
              cp "${img}" $out/FP3-img-${config.buildNumber}.zip
              cp "${ota}" $out/FP3-ota_update-${config.buildNumber}.zip

              echo "file bootImg $out/boot.img" >> $out/nix-support/hydra-build-products
              echo "file factoryImg $out/FP3-factory-${config.buildNumber}.zip" >> $out/nix-support/hydra-build-products
              echo "file img $out/FP3-img-${config.buildNumber}.zip" >> $out/nix-support/hydra-build-products
              echo "file ota $out/FP3-ota_update-${config.buildNumber}.zip" >> $out/nix-support/hydra-build-products
            '';

        fp2.otaDir = self.robotnixConfigurations.fp2.otaDir;
        fp2.products = with self.robotnixConfigurations.fp2;
          runCommandLocal
            "hydra-fp2-products-${config.buildNumber}"
            { }
            ''
              mkdir -p $out/nix-support

              cp "${bootImg}" $out/boot.img
              cp "${factoryImg}" $out/FP2-factory-${config.buildNumber}.zip
              cp "${img}" $out/FP2-img-${config.buildNumber}.zip
              cp "${ota}" $out/FP2-ota_update-${config.buildNumber}.zip

              echo "file bootImg $out/boot.img" >> $out/nix-support/hydra-build-products
              echo "file factoryImg $out/FP2-factory-${config.buildNumber}.zip" >> $out/nix-support/hydra-build-products
              echo "file img $out/FP2-img-${config.buildNumber}.zip" >> $out/nix-support/hydra-build-products
              echo "file ota $out/FP2-ota_update-${config.buildNumber}.zip" >> $out/nix-support/hydra-build-products
            '';
      };
    };
}