forked from dan/liminix
1
0
Fork 0

inline lib/merge-modules.nix

it wasn't really adding value once I learned that evalModules
is at nixpkgs.lib

https://github.com/telent/liminix/compare/main...vesim987:liminix:main#diff-8ebcd005c04c8eddff72aa83f26a9ee6cfef3c04ce16b8f051aa6c6f4b0c9e73L1
This commit is contained in:
Daniel Barlow 2023-02-16 17:22:27 +00:00
parent 8915f828a5
commit b60ce985b7
7 changed files with 11 additions and 67 deletions

View File

@ -11,14 +11,17 @@ let
config = {allowUnsupportedSystem = true; };
});
config = (import ./lib/merge-modules.nix) [
./modules/base.nix
device.module
liminix-config
./modules/s6
./modules/users.nix
./modules/outputs.nix
] pkgs;
config = (pkgs.lib.evalModules {
modules = [
{ _module.args = { inherit pkgs; lib = pkgs.lib; }; }
./modules/base.nix
device.module
liminix-config
./modules/s6
./modules/users.nix
./modules/outputs.nix
];
}).config;
borderVm = ((import <nixpkgs/nixos/lib/eval-config.nix>) {
system = builtins.currentSystem;

View File

@ -1,8 +0,0 @@
modules : pkgs :
let evalModules = (import <nixpkgs/lib>).evalModules;
in (evalModules {
modules =
[
{ _module.args = { inherit pkgs; lib = pkgs.lib; }; }
] ++ modules;
}).config

View File

@ -1,10 +0,0 @@
{ config, pkgs, ... } :
{
imports = [ ./defs.nix ./module.nix ];
config = {
services.a.enable = true;
services.b.enable = true;
systemPackages = [ pkgs.hello ] ;
};
}

View File

@ -1,16 +0,0 @@
{ lib, ...}:
let inherit (lib) mkEnableOption mkOption types;
in {
options = {
services.a = {
enable = mkEnableOption "hello service";
};
services.b = {
enable = mkEnableOption "other service";
};
services.z = mkOption { };
systemPackages = mkOption {
type = types.listOf types.package;
};
};
}

View File

@ -1,6 +0,0 @@
{ config, pkgs, ... } :
{
services.z = pkgs.figlet;
systemPackages = [ pkgs.units ] ;
}

View File

@ -1,2 +0,0 @@
set -e
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build --arg device "import <liminix/devices/qemu>" test.nix

View File

@ -1,17 +0,0 @@
{ device }:
let
overlay = import <liminix/overlay.nix> ;
nixpkgs = import <nixpkgs> ( device.system // {overlays = [overlay]; });
inherit (nixpkgs) lib pkgs;
inherit (lib.asserts) assertMsg;
config =
(import <liminix/merge-modules.nix>) [./configuration.nix] pkgs;
res1 = assertMsg
# check we have packages from both modules
(config.systemPackages == ( with pkgs; [ units hello ])) "failed";
res2 = let s = config.services;
in assertMsg (s.a.enable && s.b.enable && (s.z != null) ) "failed";
in pkgs.writeText "foo" ''
${if res1 then "OK" else "not OK"}
${if res2 then "OK" else "not OK"}
''