From c2219a58525f02be455480bbd63c14455345c352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 12 Apr 2022 14:46:33 +0200 Subject: flake: allow cross compilation of tarballs --- flake.nix | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index 850c6c9..739ba9e 100644 --- a/flake.nix +++ b/flake.nix @@ -14,23 +14,45 @@ nixpkgs.overlays = [ self.overlay ]; }; - lib = { - # The full NixOS system - nixturrisSystem = {nixpkgs ? nixpkgs-stable, board, modules ? [], override ? {}}: let - pkgs = if board == "omnia" - then nixpkgs.legacyPackages.armv7l-linux - else nixpkgs.legacyPackages.aarch64-linux; - in nixpkgs.lib.nixosSystem ({ - system = pkgs.system; + lib = rec { + # Mapping of board name to the appropriate system + boardSystem = { + omnia = { + config = "armv7l-unknown-linux-gnueabihf"; + system = "armv7l-linux"; + }; + mox = { + config = "aarch64-unknown-linux-gnu"; + system = "aarch64-linux"; + }; + }; + + # NixOS system for specific Turris board + nixturrisSystem = { + board, + system ? boardSystem.${board}.system, + nixpkgs ? nixpkgs-stable, + modules ? [], + override ? {} + }: nixpkgs.lib.nixosSystem ({ + system = system; modules = [ self.nixosModule - { turris.board = board; } + ({ + turris.board = board; + } // nixpkgs.lib.optionalAttrs (system != boardSystem.${board}.system) { + nixpkgs.crossSystem = boardSystem.${board}; + }) ] ++ modules; } // override); + # The minimalized system to decrease amount of ram needed for rebuild # TODO this does not work right now as it requires just load of work to do - nixturrisMinSystem = {nixpkgs ? nixpkgs-stable, modules, ...} @args: - self.lib.nixturrisSystem (args // { + nixturrisMinSystem = { + nixpkgs ? nixpkgs-stable, + modules, + ... + } @args: self.lib.nixturrisSystem (args // { nixpkgs = nixpkgs; modules = modules ++ [ ./nixos/nixos-modules-minfake.nix ]; override = { @@ -44,6 +66,7 @@ packages = let createTarball = board: (self.lib.nixturrisSystem { + system = system; board = board; modules = [ (import ./tarball.nix board) ]; }).config.system.build.tarball; -- cgit v1.2.3