aboutsummaryrefslogtreecommitdiff
path: root/lib/default.nix
blob: 211451ee9a8be81da10fa06664debf054e8c3a64 (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
{ self, nixpkgsDefault }: 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,
    nixpkgs ? nixpkgsDefault,
    system ? boardSystem.${board}.system,
    modules ? [],
    override ? {}
  }: nixpkgs.lib.nixosSystem ({
    system = system;
    modules = [
      self.nixosModules.default
      ({
        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,
    modules ? [],
    ...
  } @args: self.lib.nixturrisSystem (args // {
    nixpkgs = nixpkgs;
    modules = modules ++ [ ../nixos/nixos-modules-minfake.nix ];
    override = {
      baseModules = import ../nixos/nixos-modules.nix nixpkgs;
    };
  });

  nixturrisTarballSystem = {...} @args: (nixturrisSystem ({
      modules = [ (import ../tarball.nix args.board) ];
    } // args));

}