Commit graph

167 commits

Author SHA1 Message Date
Nathan Zadoks 1904ef7f09 systemd: enable upstream systemd-binfmt.service
Since we don't restart sysinit.service in switch-to-configuration, this
additionally overrides systemd-binfmt.service to depend on
proc-sys-fs-binfmt_misc.automount, which is normally provided by
sysinit.service.
2016-03-02 21:00:47 +01:00
Nikolay Amiantov 148396c022 systemd service: add *.busname upstream units 2016-01-18 19:42:25 +03:00
Thomas Strobel a04a7272aa Add missing 'type', 'defaultText' and 'literalExample' in module definitions
- add missing types in module definitions
- add missing 'defaultText' in module definitions
- wrap example with 'literalExample' where necessary in module definitions
2016-01-17 19:41:23 +01:00
Evgeny Egorochkin 01130e502a systemd: backslashes are no longer allowed in script names 2016-01-10 11:31:38 +02:00
Gabriel Ebner f4c01fc004 systemd: enable timedated, hostnamed, localed. 2015-12-07 20:25:53 +01:00
Jaka Hudoklin b9291616a6 systemd module: Add OnFailure to systemd common unit options 2015-11-16 15:12:28 +01:00
Eelco Dolstra 81f6c62004 Merge remote-tracking branch 'origin/master' into systemd-219 2015-10-30 15:47:37 +01:00
Eelco Dolstra 5f077e2296 Factor out option renaming
Option aliases/deprecations can now be declared in any NixOS module,
not just in nixos/modules/rename.nix. This is more modular (since it
allows for example grub-related aliases to be declared in the grub
module), and allows aliases outside of NixOS (e.g. in NixOps modules).

The syntax is a bit funky. Ideally we'd have something like:

  options = {
    foo.bar.newOption = mkOption { ... };
    foo.bar.oldOption = mkAliasOption [ "foo" "bar" "newOption" ];
  };

but that's not possible because options cannot define values in
*other* options - you need to have a "config" for that. So instead we
have functions that return a *module*: mkRemovedOptionModule,
mkRenamedOptionModule and mkAliasOptionModule. These can be used via
"imports", e.g.

  imports = [
    (mkAliasOptionModule [ "foo" "bar" "oldOption" ] [ "foo" "bar" "newOption" ]);
  ];

As an added bonus, deprecation warnings now show the file name of the
offending module.

Fixes #10385.
2015-10-14 18:18:47 +02:00
Eelco Dolstra 73f0d83858 systemd: Update to 227 2015-10-07 22:01:21 +02:00
Eelco Dolstra b23038dd80 Merge remote-tracking branch 'origin/master' into systemd-219 2015-10-01 14:17:46 +02:00
Thomas Strobel 05c46bfc05 systemd module: add option to specify generators
Adding the configuration option 'systemd.generators' to
specify systemd system-generators. The option allows to
either add new system-generators to systemd, or to over-
ride or disable the system-generators provided by systemd.

Internally, the configuration option 'systemd.generators'
maps onto the 'environment.etc' configuration option.
Having a convenience wrapper around 'environment.etc' helps
to group the systemd system-generator configuration more
easily with other 'systemd...' configurations.
2015-09-29 11:53:25 +02:00
Eelco Dolstra 916793cf13 Merge branch 'master' into systemd-219
Conflicts:
	nixos/modules/system/boot/systemd.nix
	pkgs/applications/networking/p2p/transmission/default.nix
	pkgs/development/libraries/libseccomp/default.nix
	pkgs/os-specific/linux/systemd/default.nix
	pkgs/top-level/all-packages.nix
2015-09-07 21:28:33 +02:00
Eelco Dolstra 6ab7e0de29 Create /var/log/journal
Fixes #9614.
2015-09-03 11:35:47 +02:00
Anders Papitto 57f7798b51 also generate startAt timers for systemd user units 2015-08-20 23:46:08 -07:00
Tuomas Tynkkynen 5d02c02a9b systemd: Use upstream tmpfiles.d rules
This fixes a failing assert in systemd-timesyncd (issue #5913) as it
expects the directory /run/systemd/netif/links/ to exist, and nothing in
NixOS currently creates it.

Also we get a net reduction in our code as rules for /run/utmp and
/var/log/journal are also provided by the same upstream file.

(cherry picked from commit a278a9224a)
2015-07-22 12:27:05 +02:00
Eelco Dolstra 925e1f91c5 Set up /etc/machine-id before starting systemd
Otherwise, systemd will try to populate /etc, which we don't want.

(cherry picked from commit c8501a4218)
2015-07-22 12:24:32 +02:00
Eelco Dolstra 6bd4e0b8cd Create systemd-{network,resolve} user/group unconditionally
This shuts up this error from dbus:

May 11 13:52:16 machine dbus-daemon[259]: Unknown username "systemd-network" in message bus configuration file
May 11 13:52:16 machine dbus-daemon[259]: Unknown username "systemd-resolve" in message bus configuration file

which happens because the D-Bus config for networkd/resolved is
enabled unconditionally, and we don't have an easy way to turn it off.

(cherry picked from commit f19b58fb6a)
2015-07-22 12:23:45 +02:00
Eelco Dolstra 65700b435c Use ConditionVirtualization to disable some services in containers
(cherry picked from commit c52a983806)
2015-07-22 12:23:40 +02:00
Eelco Dolstra bc1773fe16 Merge remote-tracking branch 'origin/staging' into systemd-219
Conflicts:
	pkgs/os-specific/linux/kernel/linux-3.4.nix
	pkgs/os-specific/linux/systemd/default.nix
2015-07-20 22:57:23 +02:00
Eelco Dolstra 19ffa212af types.uniq types.int -> types.int
types.int already implies uniqueness.
2015-06-15 18:11:32 +02:00
Tuomas Tynkkynen a278a9224a systemd: Use upstream tmpfiles.d rules
This fixes a failing assert in systemd-timesyncd (issue #5913) as it
expects the directory /run/systemd/netif/links/ to exist, and nothing in
NixOS currently creates it.

Also we get a net reduction in our code as rules for /run/utmp and
/var/log/journal are also provided by the same upstream file.
2015-06-03 10:49:01 +02:00
Eelco Dolstra 588b92a7d2 systemd: Update to 220 2015-05-22 15:34:08 +02:00
Eelco Dolstra c8501a4218 Set up /etc/machine-id before starting systemd
Otherwise, systemd will try to populate /etc, which we don't want.
2015-05-18 11:35:00 +02:00
Eelco Dolstra 76055df52d Allow systemd-journald to be restarted
With systemd 219, this is fine because systemd will cause the new
journald to re-use the file descriptors of the old one. So existing
connections to the journal are unaffected.
2015-05-11 18:18:36 +02:00
Eelco Dolstra f19b58fb6a Create systemd-{network,resolve} user/group unconditionally
This shuts up this error from dbus:

May 11 13:52:16 machine dbus-daemon[259]: Unknown username "systemd-network" in message bus configuration file
May 11 13:52:16 machine dbus-daemon[259]: Unknown username "systemd-resolve" in message bus configuration file

which happens because the D-Bus config for networkd/resolved is
enabled unconditionally, and we don't have an easy way to turn it off.
2015-05-11 18:18:36 +02:00
Eelco Dolstra c52a983806 Use ConditionVirtualization to disable some services in containers 2015-05-11 18:18:35 +02:00
Eelco Dolstra fe952a42a7 systemd: Update to 219 2015-05-11 18:18:35 +02:00
Eelco Dolstra 492471b453 Apply some overrides to upstream systemd units
This removes the need for the following patches:

9a6cade993
9f7e832c90
2015-05-11 12:43:35 +02:00
aszlig 4cdb4a4fef
networkd: Fix evaluation of systemd.network units.
During the refactor of the networkd stuff in f8dbe5f, a lot of the
options are now needed by systemd.nix as well as networkd.nix but
weren't moved by that commit as well.

For now, this fixes all networkd VM tests except for the macvlan one and
thus it should fix #7505 for at least DHCP-based configuration.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2015-04-30 06:49:10 +02:00
Eelco Dolstra 56f66dad97 Fix #7476 2015-04-20 11:32:29 +02:00
Eelco Dolstra c87977e97d Don't include networkd units unless enabled
Otherwise, the enabled -> disabled transition won't be handled
correctly (switch-to-configuration currently assumes that if a unit is
running and exists, it should be restarted).
2015-04-19 22:06:45 +02:00
Eelco Dolstra f8dbe5f376 systemd: Move networkd into separate modules
The systemd module was getting rather bloated.
2015-04-19 22:06:45 +02:00
Nicolas B. Pierron 6de931a0f8 Merge rename.nix changes. 2015-04-03 23:12:12 +02:00
Guillaume Maudoux 6ca7fb8f73 nixos/systemd: Also escape ':' characters 2015-03-25 22:11:35 +01:00
Shea Levy e4a06f35b1 nixos: Don't evaluate twice to get the value of config.nixpkgs 2015-03-12 23:42:57 +01:00
Jaka Hudoklin 769fb8a141 Merge pull request #5486 from matejc/fixgatewayd
systemd-journal-gatewayd: add systemd-journal group
2015-02-07 14:52:31 +00:00
Eelco Dolstra e62cb5585d Merge pull request #5507 from DamienCassou/systemd-user-timers
Add systemd.user.timers
2014-12-30 15:40:43 +01:00
Damien Cassou dcc93abe74 Add systemd.user.timers 2014-12-30 05:46:36 +01:00
Tobias Geerinckx-Rice c64257b8e5 Fix user-facing typos (mainly in descriptions) 2014-12-30 03:31:03 +01:00
Matej Cotman 9eb24c72ff systemd: fix permissions on /var/log/journal 2014-12-28 22:37:50 +01:00
Jaka Hudoklin 8bb6fdc4f9 nixos/systemd: ignore null environment options 2014-12-07 21:44:20 +01:00
William A. Kennington III 8a94c06595 nixos: Add network-pre.target and adjust firewall start ordering 2014-12-01 17:19:44 -08:00
William A. Kennington III 2b06a92c2a nixos/nfs: Fix dependency ordering 2014-12-01 17:19:44 -08:00
William A. Kennington III 1c04e69bce nixos/networking: Fix more harmless errors 2014-12-01 01:18:32 -08:00
William A. Kennington III 7ecb084b77 nixos/networking: More fixes 2014-11-29 22:35:03 -08:00
William A. Kennington III 1860ee27b0 nixos/networking: Fixes 2014-11-26 16:29:24 -08:00
William A. Kennington III 0626c1ecf0 nixos/systemd: ip-up and network-online targets should come after networkd-wait-online 2014-11-26 11:22:02 -08:00
William A. Kennington III 59f512ef7d nixos/network-interfaces: Provide a networkd implementation 2014-11-26 11:22:02 -08:00
William A. Kennington III a332c4eac5 systemd: Enable more network services 2014-11-26 11:22:02 -08:00
William A. Kennington III 08e74f2791 systemd: Add ability to define networks 2014-11-26 11:22:02 -08:00
Vladimír Čunát 2cf17b0802 Merge recent master into staging
Hydra nixpkgs: ?compare=1156478
2014-10-23 17:40:41 +02:00
William A. Kennington III f020a26164 nixos/systemd: Also escape \ characters 2014-10-19 16:34:53 -07:00
Domen Kožar 2fa662c957 systemd: replace @ when generating unit command name 2014-10-19 17:20:37 +02:00
Domen Kožar 0854836fd2 systemd: include name of the unit when generating nix store path 2014-10-19 15:49:55 +02:00
Eelco Dolstra a85dcf4a00 Merge remote-tracking branch 'origin/master' into staging
Conflicts:
	pkgs/development/libraries/libav/default.nix
	pkgs/shells/bash/bash-4.2-patches.nix
	pkgs/stdenv/generic/default.nix
2014-10-07 00:09:37 +02:00
Eelco Dolstra 97220c973f Replace hasAttr/getAttr calls with the ? and . operators
For NixOS evaluation, this gives a ~21% reduction in the number of
values allocated and a ~4% speedup. It's also more readable.
2014-10-05 01:11:06 +02:00
Eelco Dolstra 91ec6e0d90 Merge remote-tracking branch 'origin/master' into staging 2014-09-18 22:28:35 +02:00
William A. Kennington III 4d193b7262 systemd: Support reload scripts 2014-09-15 20:04:49 -07:00
Eelco Dolstra c23bf4ec74 systemd: Update to 216 2014-08-23 23:28:03 +02:00
Eelco Dolstra 7c4591d010 Don't barf if /var/log doesn't support ACLs
http://hydra.nixos.org/build/13462892
2014-08-18 14:21:45 +02:00
Emery Hemingway 63d259df32 nixos: tmp on tmpfs option
/tmp cleaning is done by systemd rather than stage-2-init
enableEmergencyMode moved from systemd to seperate module
new option to mount tmp on tmpfs
new option to enable additional units shipped with systemd
2014-07-30 16:19:26 +02:00
Eelco Dolstra 9956b97b2f Check for systemd environment variables that are too long
Issue #3403. For the case of $PATH being too long, we could call
buildEnv automatically.
2014-07-30 10:28:05 +02:00
Eelco Dolstra 1a1442db74 Don't restart systemd-journal-flush
It only needs to be started during boot. Starting it at other times
shouldn't hurt, except that if systemd-journald is restarting at the
same time, the latter might not have a SIGUSR1 signal handler
installed yet, so it might be killed by systemd-journal-flush. (At
least that's my theory about the dead systemd-journald instances in
the build farm...)
2014-07-17 21:01:25 +02:00
Eelco Dolstra 3b2609deec Don't restart systemd-remount-fs
It's only needed during early boot (in fact, it's probably not needed
at all on NixOS). Restarting it is expensive because it does a sync()
of the root file system.
2014-07-11 23:34:58 +02:00
Paul Colomiets 11e25f1a3e Implement per-user socket units 2014-06-20 17:41:14 -04:00
Evgeny Egorochkin b415876bdb systemd service: fix issues with escaping when unit name contains '-'
systemd escaping rules translate this into a string containing '\'
which is treated by some code paths as quoted, and by others as unquoted
causing the affected units to fail.
2014-06-11 04:08:13 +03:00
Eelco Dolstra bddd10d75c switch-to-configuration: Don't restart instances of user@.service
Restarting user@ instances is bad because it causes all user services
(such as ssh-agent.service) to be restarted. Maybe one day we can have
switch-to-configuration restart user units in a fine-grained way, but
for now we should just ignore user systemd instances.

Backport: 14.04
2014-05-20 11:12:56 +02:00
Eelco Dolstra 728d3476ba systemd: Require some more kernel features 2014-04-30 13:53:12 +02:00
Eelco Dolstra d621300665 Revert "Don't mount /sys/fs/fuse/connections and /sys/kernel/config"
This reverts commit 6eaced3582. Doesn't
work very well, e.g. if you actually have the FUSE module loaded. And
in any case it's already fixed in NixOps.
2014-04-28 09:19:01 +02:00
Eelco Dolstra 6eaced3582 Don't mount /sys/fs/fuse/connections and /sys/kernel/config
These fail to mount if you don't have the appropriate kernel support,
and this confuses NixOps' ‘check’ command. We should teach NixOps not
to complain about non-essential mount points, but in the meantime it's
better to turn them off.
2014-04-28 08:16:27 +02:00
Eelco Dolstra da444ff26f Turn assertion about oneshot services into a warning 2014-04-22 23:53:21 +02:00
Eelco Dolstra fa3826dcf4 Ignore *.wants in systemd.packages for now 2014-04-22 17:38:53 +02:00
Mathijs Kwik bf841cd892 Revert "systemd: oneshot units should be allowed to restart on failure/abort"
This reverts commit c1e638abb6.

As pointed out by wkennington, upstream disallows all cases as of v207
2014-04-18 21:42:22 +02:00
Eelco Dolstra febb15f722 systemd: Enable keeping backlight / rfkill state across reboots 2014-04-18 19:37:15 +02:00
Eelco Dolstra 1e540af43b Fix broken upstream user unit symlinks 2014-04-18 17:38:06 +02:00
Eelco Dolstra 64b968f81f Remove debug line 2014-04-18 02:31:10 +02:00
Eelco Dolstra 12f06ae499 Doh 2014-04-18 01:36:43 +02:00
Eelco Dolstra e34a1589fe Add support for user units
With ‘systemd.user.units’ and ‘systemd.user.services’, you can specify
units used by per-user systemd instances.  For example,

  systemd.user.services.foo =
    { description = "foo";
      wantedBy = [ "default.target" ];
      serviceConfig.ExecStart = "${pkgs.foo}/bin/foo";
    };

declares a unit ‘foo.service’ that gets started automatically when the
user systemd instance starts, and is stopped when the user systemd
instance stops.

Note that there is at most one systemd instance per user: it's created
when a user logs in and there is no systemd instance for that user
yet, and it's removed when the user fully logs out (i.e. has no
sessions anymore). So if you're simultaneously logged in via X11 and a
virtual console, you get only one copy of foo.
2014-04-18 00:38:40 +02:00
Eelco Dolstra 073351a5cf Refactor unit option declarations
This gets rid of some duplication.
2014-04-17 23:35:05 +02:00
Eelco Dolstra 2ad6933a22 Remove special handling of systemd-journal-gatewayd 2014-04-17 19:05:29 +02:00
Eelco Dolstra 179acfb664 Allow upstream systemd units to be extended
If you define a unit, and either systemd or a package in
systemd.packages already provides that unit, then we now generate a
file /etc/systemd/system/<unit>.d/overrides.conf. This makes it
possible to use upstream units, while allowing them to be customised
from the NixOS configuration. For instance, the module nix-daemon.nix
now uses the units provided by the Nix package. And all unit
definitions that duplicated upstream systemd units are finally gone.

This makes the baseUnit option unnecessary, so I've removed it.
2014-04-17 18:52:31 +02:00
Eelco Dolstra 560a1103ad Add option ‘systemd.tmpfiles.rules’
This allows specifying rules for systemd-tmpfiles.

Also, enable systemd-tmpfiles-clean.timer so that stuff is cleaned up
automatically 15 minutes after boot and every day, *if* you have the
appropriate cleanup rules (which we don't have by default).
2014-04-17 16:14:56 +02:00
Mathijs Kwik c1e638abb6 systemd: oneshot units should be allowed to restart on failure/abort 2014-04-17 15:20:39 +02:00
Eelco Dolstra 317a81ada2 Enable systemd-tmpfiles 2014-04-17 13:23:06 +02:00
Eelco Dolstra 518f710547 Fix module loading in systemd-udevd 2014-04-17 12:26:12 +02:00
Eelco Dolstra 89155dbc01 systemd: Enable user systemd instances 2014-04-17 12:03:04 +02:00
Eelco Dolstra e8af68d2dc Make machinectl work 2014-04-16 10:48:14 +02:00
Eelco Dolstra 2fc520d699 Simplify assertion 2014-04-16 01:08:14 +02:00
William A. Kennington III eda854d50f systemd: Add an assertion to guarantee oneshot units do not have restart set
This prevents insidious errors once systemd begins handling the unit. If
the unit is loaded at boot, any errors of this nature are logged to the
console before the journal service is running. This makes it very hard
to diagnose the issue. Therefore, this assertion helps guarantee the
mistake is not made.
2014-04-16 01:05:56 +02:00
Eelco Dolstra ee9c068b0c systemd: Update to 212
Note that systemd no longer depends on dbus, so we're rid of the
cyclic dependency problem between systemd and dbus.

This commit incorporates from wkennington's systemd branch
(203dcff45002a63f6be75c65f1017021318cc839,
1f842558a95947261ece66f707bfa24faf5a9d88).
2014-04-16 00:59:26 +02:00
Eelco Dolstra 29027fd1e1 Rewrite ‘with pkgs.lib’ -> ‘with lib’
Using pkgs.lib on the spine of module evaluation is problematic
because the pkgs argument depends on the result of module
evaluation. To prevent an infinite recursion, pkgs and some of the
modules are evaluated twice, which is inefficient. Using ‘with lib’
prevents this problem.
2014-04-14 16:26:48 +02:00
Eelco Dolstra d2155649af Merge branch 'containers'
Fixes #2105.
2014-04-10 15:55:51 +02:00
aszlig 9d8a8126e9
systemd: Add support for path units.
This allows to define systemd.path(5) units, for example like this:

{
  systemd = let
    description = "Set Key Permissions for xyz.key";
  in {
    paths.set-key-perms = {
      inherit description;
      before = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      pathConfig.PathChanged = "/run/keys/xyz.key";
    };

    services.set-key-perms = {
      inherit description;
      serviceConfig.Type = "oneshot";
      script = "chown myspecialkeyuser /run/keys/xyz.key";
    };
  };
}

The example here is actually useful in order to set permissions for the
NixOps keys target to ensure those permisisons aren't reset whenever the
key file is reuploaded.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2014-03-31 12:33:25 +02:00
Eelco Dolstra 511b86d22d Add an option to reload rather than restart changed units 2014-03-17 15:02:53 +01:00
Shea Levy 0c12dd3ded Merge branch 'pkgs/systemd/journald_http_gateway' of git://github.com/offlinehacker/nixpkgs
systemd: python support & journal http gateway

Conflicts:
	nixos/modules/misc/ids.nix
2014-03-14 19:16:59 -04:00
Shea Levy 59a060523e Don't override the baseUnit's PATH by default 2014-03-12 20:03:14 -04:00
Eelco Dolstra e1984f029d autovt@.service really has to be a symlink 2014-03-13 00:19:10 +01:00
Eelco Dolstra f198c40608 Don't depend on the text of disabled units
This prevents pulling in unnecessary dependencies.
2014-03-12 18:52:11 +01:00
Eelco Dolstra 207c881df9 Don't include superfluous lines in generated units 2014-03-12 18:52:11 +01:00
Eelco Dolstra 691c0cd72e systemd: Allow customisation of upstream units
You can now say:

  systemd.services.foo.baseUnit = "${pkgs.foo}/.../foo.service";

This will cause NixOS' generated foo.service file to include
foo.service from the foo package.  You can then apply local
customization in the usual way:

  systemd.services.foo.serviceConfig.MemoryLimit = "512M";

Note however that overriding options in the original unit may not
work.  For instance, you cannot override ExecStart.

It's also possible to customize instances of template units:

  systemd.services."getty@tty4" =
    { baseUnit = "/etc/systemd/system/getty@.service";
      serviceConfig.MemoryLimit = "512M";
    };

This replaces the unit options linkTarget (which didn't allow
customisation) and extraConfig (which did allow customisation, but in
a non-standard way).
2014-03-12 18:52:10 +01:00