units
Some checks failed
build liminix / build_vm_qemu_mips (pull_request) Successful in 33s
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 36s
build liminix / test_shell_customization (pull_request) Failing after 1m31s
build liminix / test_hostapd (pull_request) Failing after 10m59s

This commit is contained in:
catvayor 2024-10-05 11:50:12 +02:00
parent 14b59b5b62
commit 7705bc2a8e
Signed by: lbailly
GPG key ID: CE3E645251AC63F3
3 changed files with 133 additions and 38 deletions

View file

@ -25,7 +25,13 @@ let
eval = evalModules {
modules = [
{
({ lib, pkgs, ... }: {
_module.args = {
utils = import "${nixpkgs}/nixos/lib/utils.nix" {
inherit lib pkgs;
config.systemd.globalEnvironment = {};
};
};
nixpkgs = {
source = nixpkgs;
overlays = [ overlay ];
@ -33,7 +39,7 @@ let
"python-2.7.18.8"
];
};
}
})
device.module
liminix-config
];

View file

@ -2,7 +2,7 @@
## ============
{ lib, pkgs, config, ...}:
{ lib, pkgs, utils, config, ...}:
let
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr concatStringsSep mapAttrsToList;
inherit (pkgs.pseudofile) dir symlink;
@ -43,9 +43,15 @@ in {
'';
};
};
# deprecated
services = mkOption {
type = types.attrsOf type_service;
};
units = mkOption {
type = utils.systemdUtils.types.units;
};
system.callService = mkOption {
type = types.functionTo (types.functionTo types.anything);
};

View file

@ -1,41 +1,120 @@
{ pkgs, ... }:
{
pkgs,
lib,
config,
utils,
...
}:
let
inherit (lib)
mapAttrs'
nameValuePair
mkMerge
mapAttrsToList
;
inherit (pkgs.pseudofile) dir symlink;
"getty.service" = {
file =
let
login = pkgs.writeScript "login" ''
#!/bin/ash
exec /bin/ash
'';
in
''
[Unit]
Description="Serial shell"
inherit (utils.systemdUtils.lib)
targetToUnit
serviceToUnit
;
units-texts = mapAttrs' (
_: unit:
nameValuePair unit.name {
file = unit.text;
mode = "0644";
}
) config.units;
units-aliases = mkMerge (
mapAttrsToList (
_: unit:
mkMerge (
map (aka: {
${aka} = symlink "${unit.name}";
}) (unit.aliases or [ ])
)
) config.units
);
units-extraWants = mkMerge (
mapAttrsToList (
_: unit:
mkMerge (
map (unit2: {
"${unit2}.wants" = dir {
${unit.name} = symlink "../${unit.name}";
};
}) (unit.wantedBy or [ ])
)
) config.units
);
units-extraUpholds = mkMerge (
mapAttrsToList (
_: unit:
mkMerge (
map (unit2: {
"${unit2}.upholds" = dir {
${unit.name} = symlink "../${unit.name}";
};
}) (unit.upheldBy or [ ])
)
) config.units
);
units-extraRequires = mkMerge (
mapAttrsToList (
_: unit:
mkMerge (
map (unit2: {
"${unit2}.requires" = dir {
${unit.name} = symlink "../${unit.name}";
};
}) (unit.requiredBy or [ ])
)
) config.units
);
[Service]
ExecStart=${pkgs.util-linux}/bin/agetty --login-program ${login} ttyS0
'';
mode = "0644";
};
"default.target" = {
file = ''
[Unit]
Description="target to boot"
Wants=getty.service
After=getty.service
AllowIsolate=yes
'';
};
"sysinit.target" = {
file = ''
[Unit]
Description="sysinit.target"
'';
};
in
{
config = {
units = {
default-target = targetToUnit {
name = "default.target";
aliases = [];
wantedBy = [];
requiredBy = [];
upheldBy = [];
unitConfig.Description = "target to boot";
};
sysinit-target = targetToUnit {
name = "sysinit.target";
aliases = [];
wantedBy = [];
requiredBy = [];
upheldBy = [];
unitConfig.Description = "sysinit.target";
};
agetty = serviceToUnit {
name = "getty.service";
aliases = [];
wantedBy = [ "default.target" ];
requiredBy = [];
upheldBy = [];
environment = {};
unitConfig = {
Description = "Serial Shell";
Before = [ "default.target" ];
};
serviceConfig.ExecStart =
let
login = pkgs.writeScript "login" ''
#!/bin/ash
. /etc/profile
exec /bin/ash
'';
in
"${pkgs.util-linux}/bin/agetty --login-program ${login} ttyS0";
};
};
kernel.config = {
CGROUPS = "y";
DEVTMPFS = "y";
@ -55,9 +134,13 @@ in
filesystem = dir {
etc = dir {
systemd = dir {
system = dir {
inherit "default.target" "getty.service" "sysinit.target";
};
system = dir (mkMerge [
units-texts
units-aliases
units-extraWants
units-extraUpholds
units-extraRequires
]);
};
};
bin = dir {