From 5339e045194c5ad482250c0271959a5fd9f97db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 2 Jan 2022 17:23:58 +0100 Subject: nios: Add sentinel module --- flake.nix | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 7 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 30f1a38..331bf79 100644 --- a/flake.nix +++ b/flake.nix @@ -1,13 +1,68 @@ { description = "Turris flake"; - inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11"; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachSystem flake-utils.lib.allSystems (system: rec { - packages = import ./pkgs { - nixlib = nixpkgs.lib; - nixpkgs = nixpkgs.legacyPackages.${system}; + outputs = { self, flake-utils, nixpkgs }: { + + overlays.default = final: prev: import ./pkgs { nixpkgs = prev; }; + overlay = self.overlays.default; # Backward compatibility + + nixosModules = import ./nixos; + nixosModule = { + imports = builtins.attrValues self.nixosModules; + nixpkgs.overlays = [ self.overlay ]; }; - }); + + lib = { + # The full NixOS system + nixturrisSystem = {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; + modules = [ + self.nixosModule + { turris.board = 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 = {modules, ...} @args: + self.lib.nixturrisSystem (args // { + modules = modules ++ [ ./nixos/nixos-modules-minfake.nix ]; + override = { + baseModules = import ./nixos/nixos-modules.nix nixpkgs; + }; + }); + }; + + } // flake-utils.lib.eachSystem (flake-utils.lib.defaultSystems ++ ["armv7l-linux"]) ( + system: { + packages = let + + createMedkit = board: (self.lib.nixturrisSystem { + board = board; + modules = [ (import ./medkit.nix board) ]; + }).config.system.build.tarball; + + in { + + medkit-mox = createMedkit "mox"; + medkit-omnia = createMedkit "omnia"; + + } // flake-utils.lib.filterPackages system (flake-utils.lib.flattenTree ( + import ./pkgs { nixpkgs = nixpkgs.legacyPackages."${system}"; } + )); + + # The legacyPackages imported as overlay allows us to use pkgsCross to + # cross-compile those packages. + legacyPackages = import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + crossOverlays = [ self.overlay ]; + }; + } + ); } -- cgit v1.2.3