mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
systemd: accept derivations as values for systemd options (#3974)
This commit is contained in:
parent
6be873663e
commit
d97e8f8861
2 changed files with 10 additions and 6 deletions
|
@ -51,7 +51,7 @@ let
|
||||||
|
|
||||||
unitType = unitKind:
|
unitType = unitKind:
|
||||||
with types;
|
with types;
|
||||||
let primitive = either bool (either int str);
|
let primitive = oneOf [ bool int str path ];
|
||||||
in attrsOf (attrsOf (attrsOf (either primitive (listOf primitive)))) // {
|
in attrsOf (attrsOf (attrsOf (either primitive (listOf primitive)))) // {
|
||||||
description = "systemd ${unitKind} unit configuration";
|
description = "systemd ${unitKind} unit configuration";
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
let
|
||||||
|
drvScript = pkgs.writeShellScript "drv-script.sh" ''
|
||||||
{
|
echo "Just a test"
|
||||||
|
'';
|
||||||
|
in {
|
||||||
config = {
|
config = {
|
||||||
systemd.user.services."test-service@" = {
|
systemd.user.services."test-service@" = {
|
||||||
Unit = { Description = "A basic test service"; };
|
Unit = { Description = "A basic test service"; };
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
Environment = [ "VAR1=1" "VAR2=2" ];
|
Environment = [ "VAR1=1" "VAR2=2" ];
|
||||||
|
ExecStartPre = drvScript;
|
||||||
ExecStart = ''/some/exec/start/command --with-arguments "%i"'';
|
ExecStart = ''/some/exec/start/command --with-arguments "%i"'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -18,11 +21,12 @@ with lib;
|
||||||
assertFileExists $serviceFile
|
assertFileExists $serviceFile
|
||||||
assertFileContent $serviceFile \
|
assertFileContent $serviceFile \
|
||||||
${
|
${
|
||||||
builtins.toFile "services-expected.conf" ''
|
pkgs.writeText "services-expected.conf" ''
|
||||||
[Service]
|
[Service]
|
||||||
Environment=VAR1=1
|
Environment=VAR1=1
|
||||||
Environment=VAR2=2
|
Environment=VAR2=2
|
||||||
ExecStart=/some/exec/start/command --with-arguments "%i"
|
ExecStart=/some/exec/start/command --with-arguments "%i"
|
||||||
|
ExecStartPre=${drvScript}
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=A basic test service
|
Description=A basic test service
|
||||||
|
|
Loading…
Reference in a new issue