From b3071a310f72bcb001786dc83bc1eda7af75efbf Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Sat, 29 Oct 2022 17:09:27 +0200 Subject: [PATCH] Trying to build new android host with CI --- .github/workflows/build.yaml | 27 ++++++++ flake.lock | 122 ++++++++++++++++++++++++++++++++++- flake.nix | 19 +++++- utils/default.nix | 42 ++++++++++-- 4 files changed, 201 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 06fa21c..0dc0b3c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -110,3 +110,30 @@ jobs: authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - run: nix --print-build-logs --verbose build --allow-import-from-derivation --option system aarch64-linux --option sandbox false --extra-platforms aarch64-linux .#nixosConfigurations.pbp.config.system.build.toplevel + + build-oneplus5t: + if: ${{ always() }} + needs: check + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v17 + with: + extra_nix_config: | + max-jobs = 10 + + - run: | + DEBIAN_FRONTEND=noninteractive + sudo apt-get update -q -y && sudo apt-get install -q -y qemu-system-aarch64 qemu-efi binfmt-support qemu-user-static + mkdir -p ~/.config/nix + sudo bash -c "echo system-features = aarch64-linux arm-linux >> /etc/nix/nix.conf" + + - uses: cachix/cachix-action@v10 + with: + name: aciceri-fleet + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + + - run: nix --print-build-logs --verbose build --allow-import-from-derivation --option system aarch64-linux --option sandbox false --extra-platforms aarch64-linux .#oneplus5t + - run: readlink result diff --git a/flake.lock b/flake.lock index cfbcaf1..7454aab 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,27 @@ "type": "github" } }, + "androidPkgs": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1638562808, + "narHash": "sha256-nnGyBugMQo9WweTgpfPbJu0fHnRtxvsPQ9el2D3wPrY=", + "owner": "tadfisher", + "repo": "android-nixpkgs", + "rev": "a191ab6adb019b09d3bb919bb98dca31d83519d5", + "type": "github" + }, + "original": { + "owner": "tadfisher", + "ref": "stable", + "repo": "android-nixpkgs", + "type": "github" + } + }, "comma": { "inputs": { "flake-compat": "flake-compat", @@ -39,6 +60,21 @@ "type": "github" } }, + "devshell": { + "locked": { + "lastModified": 1637575296, + "narHash": "sha256-ZY8YR5u8aglZPe27+AJMnPTG6645WuavB+w0xmhTarw=", + "owner": "numtide", + "repo": "devshell", + "rev": "0e56ef21ba1a717169953122c7415fa6a8cd2618", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "doom-emacs": { "flake": false, "locked": { @@ -306,6 +342,21 @@ "type": "github" } }, + "flake-utils_3": { + "locked": { + "lastModified": 1638122382, + "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "format-all": { "flake": false, "locked": { @@ -445,6 +496,22 @@ "type": "github" } }, + "nixpkgsUnstable_2": { + "locked": { + "lastModified": 1638376152, + "narHash": "sha256-ucgLpVqhFnClH7YRUHBHnmiOd82RZdFR3XJt36ks5fE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6daa4a5c045d40e6eae60a3b6e427e8700f1c07f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1663235518, @@ -490,6 +557,38 @@ "type": "indirect" } }, + "nixpkgs_5": { + "locked": { + "lastModified": 1637841632, + "narHash": "sha256-QYqiKHdda0EOnLGQCHE+GluD/Lq2EJj4hVTooPM55Ic=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "73369f8d0864854d1acfa7f1e6217f7d6b6e3fa1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { + "locked": { + "lastModified": 1638371214, + "narHash": "sha256-0kE6KhgH7n0vyuX4aUoGsGIQOqjIx2fJavpCWtn73rc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a640d8394f34714578f3e6335fc767d0755d78f9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-21.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nose": { "flake": false, "locked": { @@ -621,6 +720,26 @@ "type": "github" } }, + "robotnix": { + "inputs": { + "androidPkgs": "androidPkgs", + "nixpkgs": "nixpkgs_6", + "nixpkgsUnstable": "nixpkgsUnstable_2" + }, + "locked": { + "lastModified": 1665032132, + "narHash": "sha256-3TtIR7JXGewZmvN4TknmVPzZkPptxJUxDvlfxks46tA=", + "owner": "danielfullmer", + "repo": "robotnix", + "rev": "2bcd6a106fd73e5f6454a4e3afc2d29cb78a2793", + "type": "github" + }, + "original": { + "owner": "danielfullmer", + "repo": "robotnix", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", @@ -630,7 +749,8 @@ "nixosHardware": "nixosHardware", "nixpkgsStable": "nixpkgsStable", "nixpkgsUnstable": "nixpkgsUnstable", - "preCommitHooks": "preCommitHooks" + "preCommitHooks": "preCommitHooks", + "robotnix": "robotnix" } }, "rotate-text": { diff --git a/flake.nix b/flake.nix index c49e895..fea47a0 100644 --- a/flake.nix +++ b/flake.nix @@ -13,13 +13,26 @@ agenix.url = github:ryantm/agenix; doomEmacs.url = github:nix-community/nix-doom-emacs; comma.url = github:nix-community/comma; + robotnix.url = github:danielfullmer/robotnix; }; outputs = {self, ...} @ inputs: let - utils = (import ./utils) inputs; - inherit (utils) lib mkConfigurations mkVmApps checkFormatting formatter formatApp mkDevShell; + utils = import ./utils inputs; + inherit + (utils) + androidImages + checkFormatting + formatApp + formatter + lib + mkDevShell + mkVmApps + nixosConfigurations + ; in { - nixosConfigurations = mkConfigurations; + inherit nixosConfigurations; + + packages = androidImages; apps = lib.recursiveUpdate (mkVmApps self.nixosConfigurations) formatApp; diff --git a/utils/default.nix b/utils/default.nix index 8341b21..c758825 100644 --- a/utils/default.nix +++ b/utils/default.nix @@ -6,6 +6,7 @@ doomEmacs, agenix, comma, + robotnix, ... }: let supportedSystems = { @@ -15,9 +16,11 @@ pkgsFor = lib.genAttrs (lib.attrValues supportedSystems) (system: nixpkgsUnstable.legacyPackages.${system}); - lib = nixpkgsUnstable.lib.extend (self: super: { - perSystem = super.genAttrs (super.attrValues supportedSystems); - }); + lib = nixpkgsUnstable.lib.extend (self: super: + { + perSystem = super.genAttrs (super.attrValues supportedSystems); + } + // robotnix.lib); mkConfiguration = { name, @@ -49,7 +52,7 @@ }; }; - mkConfigurations = { + nixosConfigurations = { thinkpad = mkConfiguration { name = "thinkpad"; system = supportedSystems.x86_64-linux; @@ -70,6 +73,25 @@ }; }; + mkAndroidConfiguration = { + name, + device, + flavor, + }: + lib.robotnixSystem { + inherit device flavor; + }; + + androidConfigurations = { + oneplus5t = mkAndroidConfiguration { + name = "oneplus5t"; + device = "dumpling"; + flavor = "lineageos"; + }; + }; + + androidImages = lib.perSystem (system: builtins.mapAttrs (name: conf: conf.img) androidConfigurations); + mkVmApp = system: configuration: let shellScript = pkgsFor.${system}.writeShellScript "run-vm" '' ${configuration.config.system.build.vm}/bin/run-${configuration.config.networking.hostName}-vm @@ -131,5 +153,15 @@ }; }); in { - inherit lib mkConfigurations mkVmApps supportedSystems formatApp formatter mkDevShell checkFormatting; + inherit + androidImages + checkFormatting + formatApp + formatter + lib + mkDevShell + mkVmApps + nixosConfigurations + supportedSystems + ; }