merge-modules accepts >1 module
This commit is contained in:
parent
887a4ff966
commit
c6e56b1637
5 changed files with 32 additions and 20 deletions
13
default.nix
13
default.nix
|
@ -4,15 +4,10 @@
|
||||||
let
|
let
|
||||||
overlay = import ./overlay.nix;
|
overlay = import ./overlay.nix;
|
||||||
nixpkgs = import <nixpkgs> ( device.system // {overlays = [overlay]; });
|
nixpkgs = import <nixpkgs> ( device.system // {overlays = [overlay]; });
|
||||||
baseConfig = {
|
config = (import ./merge-modules.nix) [
|
||||||
systemPackages = [];
|
(import ./modules/base.nix { inherit device; })
|
||||||
services = {};
|
<liminix-config>
|
||||||
kernel = device.kernel;
|
] nixpkgs.pkgs;
|
||||||
};
|
|
||||||
config = baseConfig // (import <liminix-config>) {
|
|
||||||
config = baseConfig;
|
|
||||||
inherit (nixpkgs) pkgs;
|
|
||||||
};
|
|
||||||
finalConfig = config // {
|
finalConfig = config // {
|
||||||
packages = (with nixpkgs.pkgs; [ s6-rc ]) ++
|
packages = (with nixpkgs.pkgs; [ s6-rc ]) ++
|
||||||
config.systemPackages ++
|
config.systemPackages ++
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
module : initial : pkgs :
|
modules : pkgs :
|
||||||
let evalModules = (import <nixpkgs/lib>).evalModules;
|
let evalModules = (import <nixpkgs/lib>).evalModules;
|
||||||
in evalModules {
|
in (evalModules {
|
||||||
modules = [
|
modules =
|
||||||
{ _module.args = { inherit pkgs; }; }
|
[
|
||||||
module
|
{ _module.args = { inherit pkgs; lib = pkgs.lib; }; }
|
||||||
];
|
] ++ modules;
|
||||||
}
|
}).config
|
||||||
|
|
17
modules/base.nix
Normal file
17
modules/base.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{ device } :
|
||||||
|
{ lib, ...}:
|
||||||
|
let inherit (lib) mkEnableOption mkOption types;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
systemPackages = mkOption {
|
||||||
|
type = types.listOf types.package;
|
||||||
|
};
|
||||||
|
services = mkOption {
|
||||||
|
type = types.anything;
|
||||||
|
};
|
||||||
|
kernel = mkOption {
|
||||||
|
type = types.anything;
|
||||||
|
default = { inherit (device.kernel) config checkedConfig; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -5,11 +5,11 @@ let
|
||||||
inherit (nixpkgs) lib pkgs;
|
inherit (nixpkgs) lib pkgs;
|
||||||
inherit (lib.asserts) assertMsg;
|
inherit (lib.asserts) assertMsg;
|
||||||
config =
|
config =
|
||||||
(import <liminix/merge-modules.nix>) ./configuration.nix {} pkgs;
|
(import <liminix/merge-modules.nix>) [./configuration.nix] pkgs;
|
||||||
res1 = assertMsg
|
res1 = assertMsg
|
||||||
# check we have packages from both modules
|
# check we have packages from both modules
|
||||||
(config.config.systemPackages == ( with pkgs; [ units hello ])) "failed";
|
(config.systemPackages == ( with pkgs; [ units hello ])) "failed";
|
||||||
res2 = let s = config.config.services;
|
res2 = let s = config.services;
|
||||||
in assertMsg (s.a.enable && s.b.enable && (s.z != null) ) "failed";
|
in assertMsg (s.a.enable && s.b.enable && (s.z != null) ) "failed";
|
||||||
in pkgs.writeText "foo" ''
|
in pkgs.writeText "foo" ''
|
||||||
${if res1 then "OK" else "not OK"}
|
${if res1 then "OK" else "not OK"}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, pkgs } :
|
{ config, pkgs, ... } :
|
||||||
let
|
let
|
||||||
inherit (pkgs.liminix.networking) interface address udhcpc odhcpc;
|
inherit (pkgs.liminix.networking) interface address udhcpc odhcpc;
|
||||||
inherit (pkgs.liminix.services) oneshot longrun bundle target output;
|
inherit (pkgs.liminix.services) oneshot longrun bundle target output;
|
||||||
|
|
Loading…
Reference in a new issue