move typeChecked into pkgs.liminix.lib

This commit is contained in:
Daniel Barlow 2023-07-14 20:22:29 +01:00
parent 69e6eb5a89
commit 682183a88d
4 changed files with 25 additions and 12 deletions

View file

@ -5,11 +5,7 @@ let
inherit (pkgs.liminix.networking) address interface; inherit (pkgs.liminix.networking) address interface;
inherit (pkgs.liminix.services) bundle; inherit (pkgs.liminix.services) bundle;
type_service = types.package // { type_service = pkgs.liminix.lib.types.service;
name = "service";
description = "s6-rc service";
check = x: isDerivation x && hasAttr "serviceType" x;
};
in { in {
options = { options = {

View file

@ -1,6 +1,8 @@
final: prev: final: prev:
let let
extraPkgs = import ./pkgs/default.nix { inherit (final) callPackage; }; extraPkgs = import ./pkgs/default.nix {
inherit (final) lib callPackage;
};
inherit (final) fetchpatch; inherit (final) fetchpatch;
lua_no_readline = prev.lua5_3.overrideAttrs(o: { lua_no_readline = prev.lua5_3.overrideAttrs(o: {
name = "lua-tty"; name = "lua-tty";

View file

@ -1,5 +1,6 @@
{ {
callPackage callPackage
, lib
}: }:
{ {
pseudofile = callPackage ./pseudofile {}; pseudofile = callPackage ./pseudofile {};
@ -10,6 +11,23 @@
squashfs = callPackage ./liminix-tools/builders/squashfs.nix {}; squashfs = callPackage ./liminix-tools/builders/squashfs.nix {};
kernel = callPackage ./kernel {}; kernel = callPackage ./kernel {};
}; };
lib = {
types = {
service =
let inherit (lib) types isDerivation hasAttr;
in types.package // {
name = "service";
description = "s6-rc service";
check = x: isDerivation x && hasAttr "serviceType" x;
};
};
typeChecked = caller: type: value:
let
inherit (lib) types mergeDefinitions;
defs = [{ file = caller; inherit value; }];
type' = types.submodule { options = type; };
in (mergeDefinitions [] type' defs).mergedValue;
};
}; };
writeFennelScript = callPackage ./write-fennel-script {}; writeFennelScript = callPackage ./write-fennel-script {};
writeAshScript = callPackage ./write-ash-script {}; writeAshScript = callPackage ./write-ash-script {};

View file

@ -8,26 +8,23 @@
} : } :
let let
inherit (liminix.services) longrun; inherit (liminix.services) longrun;
inherit (liminix.lib) typeChecked;
inherit (lib) inherit (lib)
mergeDefinitions mergeDefinitions
mkEnableOption mkOption isType types isDerivation hasAttr; mkEnableOption mkOption isType types isDerivation hasAttr;
t = { t = {
interface = mkOption { interface = mkOption {
type = types.package; # actually a service type = liminix.lib.types.service;
description = "ethernet interface to run PPPoE over"; description = "ethernet interface to run PPPoE over";
}; };
ppp-options = mkOption { ppp-options = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
}; };
}; };
t' = types.submodule { options = t; };
typeChecked = type: value:
let defs = [{ file = "pppoe.nix"; inherit value; }];
in (lib.mergeDefinitions [ ] type defs).mergedValue;
in in
params: params:
let let
inherit (typeChecked t' params) ppp-options interface; inherit (typeChecked "pppoe.nix" t params) ppp-options interface;
name = "${interface.device}.pppoe"; name = "${interface.device}.pppoe";
ip-up = writeAshScript "ip-up" {} '' ip-up = writeAshScript "ip-up" {} ''
. ${serviceFns} . ${serviceFns}