Add module to use kmscon instead of linux-console for VTs

This required some changes to systemd unit handling:

* Add an option to specify that a unit is just a symlink
* Allow specified units to overwrite systemd-provided ones
* Have gettys.target require autovt@1.service instead of getty@1.service

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy
2014-01-15 08:17:19 -05:00
parent e5c34ddb55
commit 48daf624c5
3 changed files with 80 additions and 7 deletions
+15 -7
View File
@@ -11,13 +11,16 @@ let
systemd = cfg.package;
makeUnit = name: unit:
pkgs.runCommand "unit" { inherit (unit) text; preferLocalBuild = true; }
(if unit.enable then ''
mkdir -p $out
echo -n "$text" > $out/${name}
'' else ''
pkgs.runCommand "unit" ({ preferLocalBuild = true; } // optionalAttrs (unit.linkTarget == null) { inherit (unit) text; })
(if !unit.enable then ''
mkdir -p $out
ln -s /dev/null $out/${name}
'' else if unit.linkTarget != null then ''
mkdir -p $out
ln -s ${unit.linkTarget} $out/${name}
'' else ''
mkdir -p $out
echo -n "$text" > $out/${name}
'');
upstreamUnits =
@@ -338,7 +341,7 @@ let
done
for i in ${toString (mapAttrsToList (n: v: v.unit) cfg.units)}; do
ln -s $i/* $out/
ln -fs $i/* $out/
done
for i in ${toString cfg.packages}; do
@@ -362,7 +365,7 @@ let
ln -s rescue.target $out/kbrequest.target
mkdir -p $out/getty.target.wants/
ln -s ../getty@tty1.service $out/getty.target.wants/
ln -s ../autovt@tty1.service $out/getty.target.wants/
ln -s ../local-fs.target ../remote-fs.target ../network.target ../nss-lookup.target \
../nss-user-lookup.target ../swap.target $out/multi-user.target.wants/
@@ -416,6 +419,11 @@ in
internal = true;
description = "The generated unit.";
};
linkTarget = mkOption {
default = null;
description = "The file to symlink this target to.";
type = types.nullOr types.path;
};
};
config = {
unit = makeUnit name config;