1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-02 21:13:33 +02:00
Commit Graph

69 Commits

Author SHA1 Message Date
Pol Dellaiera
fa8c16e245
systemd: add enable option 2024-04-16 21:12:47 +02:00
Olli Helenius
e27be9db7b
systemd: avoid creating an empty user.conf
Due to the defaults in `systemd.user.settings`, the default value when
there are no settings explicitly set is `{ Manager = { }; }`. This
means an empty file is created even when `systemd.user.settings` is
never used in home-manager configuration. Since user’s `user.conf` is
preferred to the global `/etc/systemd/user.conf`, this can cause any
values set in the latter to be discarded.
2023-11-11 00:51:53 +01:00
Olli Helenius
6a8444467c
systemd: add settings option (#4276)
The `systemd.user.extraConfig` provides a way to generate a
`systemd-user.conf(5)` file for the user.

This is the home-manager equivalent of NixOS’s option of the same
name, with the difference that NixOS’s option generates a `user.conf`
file that is shared between all users.
2023-11-07 07:55:17 -07:00
Emily
9f9e277b60 treewide: remove now-redundant lib.mdDoc calls
These (and the `*MD` functions apart from `literalMD`) are now no-ops
in nixpkgs and serve no purpose other than to add additional noise and
potentially mislead people into thinking unmarked DocBook documentation
will still be accepted.

Note that if backporting changes including documentation to 23.05,
the `mdDoc` calls will need to be re-added.

To reproduce this commit, run:

    $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
      nix shell nixpkgs#coreutils \
      -c find . -name '*.nix' \
      -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
      --strip {} +
    $ ./format
2023-07-17 18:49:09 +01:00
Emily
36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00
Emily
21c700d14b treewide: convert options with lists to Markdown
`nix-doc-munge` can't handle these, which is understandable as I can
barely handle them either. There are a few infelicities here: the
current processor can't handle multiple terms to one description in
a description list so they get comma-separated in one case, and one
case that should ideally render as a `<figure>` with a `<figcaption>`
in HTML is reduced to a paragraph with some `<strong>` text. (Which, in
fairness, is how it rendered in practice with the DocBook anyway.) The
docs generator has since been updated to handle figures, but we can't
use it until moving off DocBook output.
2023-07-17 16:49:35 +01:00
Emily
3222c99a91 treewide: convert parameterized docs to Markdown
Parameterized documentation generators like this can't be converted
automatically.
2023-07-17 16:49:35 +01:00
Ramses
d97e8f8861
systemd: accept derivations as values for systemd options (#3974) 2023-05-11 15:50:37 +02:00
midchildan
edb3645383
systemd: remove platform assertion
Allow modules to define systemd services on macOS. It won't actually
have any effect, but it would allow modules to define both systemd
services and launchd agents without boilerplate conditionals.

As a consequence of this change, each module would have to check for
compatibility with the OS target instead.
2023-02-07 21:54:25 +01:00
1sixth
3f0d04aeca
treewide: replace replaceChars with replaceStrings
replaceChars is a deprecated alias, see
05a2dfd674
for details.
2022-12-16 16:34:59 +01:00
Robert Helgesson
d67776563e
systemd: fix systemctlPath default text 2022-11-07 15:09:35 +01:00
ralismark
9fcae11ff2 systemd: name slice unit correctly 2022-10-07 16:07:53 +11:00
arcnmx
2e41a1bab3
systemd: handle Install.RequiredBy
Units with

    Install.RequiredBy = [ target ]

set will now be linked in the

    ${target}.requires

directory. Similar to how `Install.WantedBy` already causes a link in
the

    ${target}.wants

directory.
2022-09-08 10:39:57 +02:00
André Silva
66ffa7a0a6
systemd: fix creation of user service unit files (#2867)
* systemd: fix creation of user service unit files

* helix: fix failing test due to file output format change

Co-authored-by: Nicolas Berbiche <nicolas@normie.dev>
2022-04-07 02:38:20 -04:00
Tobias Happ
c2aa831491
systemd: do not install systemd files when user is root (#2454)
For the user root, there are no user services provided by systemd.
Therefore, these files will never be used.
2021-11-23 01:06:43 -05:00
Naïm Favier
bd11e2c5e6
Replace usage of literalExample
Instead use the new function `literalExpression`. See

  https://github.com/NixOS/nixpkgs/pull/136909
2021-10-13 00:16:10 +02:00
Robert Helgesson
41903a14b0
Remove a few format exceptions 2021-07-18 23:34:50 +02:00
bb010g
1375fd4a03
systemd: add automounts option 2021-06-14 23:10:21 +02:00
bb010g
b6613a8544
systemd: bring more in line with upstream 2021-06-14 23:10:20 +02:00
Tad Fisher
01ec2aaefe
systemd: revert systemd-environment-generator usage for environment variables (#2001) 2021-05-16 17:43:50 -04:00
Tad Fisher
23769994e8
xdg.systemDirs: init module (#1797)
There is a need to manage XDG Base Directory system directory
environment variables in Home Manager modules. There is an existing
mechanism in `targets.genericLinux.extraXdgDataDirs', but this does not
apply to NixOS systems.

Furthermore, it is important that `XDG_CONFIG_DIRS' and `XDG_DATA_DIRS'
are set in both login shells (to support getty and SSH sessions) as well
as the systemd user manager (to propagate them to user services and
desktop environments).

The first need is addressed by adding the `xdg.systemDirs' module, which
configures lists of directory names for both `config' and `data'
directories. These are then set in
`$XDG_CONFIG_DIR/environment.d/10-home-manager.conf' and picked up by
the systemd user manager.

To make these, and other variables set in
`systemd.user.sessionVariables', available in login shells, an
additional step is added to `etc/profile.d/hm-session-vars.sh' which
exports the result of
`user-environment-generators/30-systemd-environment-d-generator' which
is shipped with systemd. The effect of this generator is to print
variables set on the systemd user manager such that shells can import
these into their environment.
2021-05-10 20:14:42 -04:00
Robert Helgesson
708cb61e82
systemd: support sd-switch
This adds support for sd-switch, a tool to perform systemd generation
switches. It can be activated by setting

    systemd.startServices = "sd-switch";
2020-12-13 22:00:30 +01:00
Vojtěch Káně
b6ed605d4a
systemd: support mount units 2020-12-10 23:16:51 +01:00
Sandro Jäckel
275d1b5212
systemd: allow creating slices 2020-12-05 09:18:17 +01:00
Sandro
aaa5329d39
systemd: Fix example (#1639)
missing `;`
2020-12-04 18:39:05 +01:00
Robert Helgesson
28eb093a1e
systemd: use listsAsDuplicateKeys
This causes list values to be emitted as a list of key-value pairs
instead of a single key-value pair where the value is space separated.

This is useful, e.g., for socket units that would like to specify more
than one `ListenStream=` address.
2020-10-25 22:55:06 +01:00
Niclas
4ebb7d1715
systemd: fix systemd spelling (#1373)
Systemdaemons are lowercased and get suffixed with a d
2020-09-06 11:28:40 +02:00
Robert Helgesson
223e3c38a1
Revert "systemd: use sd-switch"
This reverts commit 9c0fe3957b.
2020-08-04 19:38:14 +02:00
Robert Helgesson
9c0fe3957b
systemd: use sd-switch
This makes the systemd module use the sd-switch application to perform
the unit switch during a generation activation.

Since the closure of sd-switch is relatively lightweight we
unconditionally pull it in as a dependency. We simultaneously remove
the `systemd.user.startServices` option and perform the switch action
automatically.

PR #1388
2020-08-04 01:01:10 +02:00
Cole Helbling
8369624512
systemd: don't page failed user units
Otherwise, the pager (typically `less`) pauses execution of
`home-manager switch` until the pager is dismissed, if the content is
larger than would fit on the screen.

PR #1175
2020-04-23 23:40:58 +02:00
Robert Helgesson
6e4b9af080
Switch to extended Nixpkg's lib
This change makes use of the `extend` function inside `lib` to inject
a new `hm` field containing the Home Manager library functions. This
simplifies use of the Home Manager library in the modules and reduces
the risk of accidental infinite recursion.

PR #994
2020-01-21 20:47:04 +01:00
arcnmx
8abaa025ec systemd: fix degraded warning 2019-12-15 14:58:43 -08:00
Robert Helgesson
9781f3766d
systemd: perform reload even in degraded state
This fixes #355, fixes #798, and fixes #909.
2019-11-24 18:55:01 +01:00
Robert Helgesson
875eea1330
systemd: fix unit examples
Closes #823
2019-08-29 19:12:39 +02:00
Robert Helgesson
12cb82af91
systemd: make the unit option type more robust
This should allow more sensible merging behavior. In particular, with
this change it is possible to use, for example, `mkForce` for greater
control of merging.

Fixes #543
2019-04-12 01:02:12 +02:00
Olli Helenius
1fdb16866b
systemd: add support for session variables
Via environment.d(5).
2019-03-24 17:23:50 +01:00
Douglas Wilson
74811679b7
systemd: sanitize unit derivation names
To allow a few special characters such as "@".

This is taken from

    c414e5bd08/nixos/modules/system/boot/systemd-lib.nix (L14)
2019-02-19 23:43:47 +01:00
Alex Brandt
7575e119d6
systemd: add more detail to user unit documentation
The current documentation does not provide guidance to users on how
systemd units are defined in Home Manager. A user may expect the
configuration to be similar to NixOS, when it actually differs.

Fixes #418
2018-10-18 23:39:28 +02:00
Olli Helenius
299e01722f
Add support for systemd path units 2018-07-01 18:04:06 +02:00
Cornelius Mika
73b8aa8bcc
systemd: merge unit definitions recursively
This removes the need for monolithic unit definitions and allows
users to modify existing units.

Example:
```
{
  systemd.user.services.owncloud-client.Unit.OnFailure = "my-notify-service";
}
```
2018-05-10 20:13:58 +02:00
Robert Helgesson
e307ceeee7
systemd: replace use of who command
Curiously the `who` command sometimes does not list logged-in users,
resulting in systemd not being reloaded. Instead we use

    systemctl --user is-system-running

to more directly detect whether systemd is running.
2018-02-20 22:04:29 +01:00
Robert Helgesson
1bc59f7290
allow Home Manager to be used as a NixOS module
This is a NixOS module that is intended to be imported into a NixOS
system configuration. It allows the system users to be set up directly
from the system configuration.

The actual profile switch is performed by a oneshot systemd unit per
configured user that acts much like the regular `home-manager switch`
command.

With this implementation, the NixOS module does not work properly with
the `nixos-rebuild build-vm` command. This can be solved by using the
`users.users.<name?>.packages` option to install packages but this
does not work flawlessly with certain Nixpkgs packages. In particular,
for programs using the Qt libraries.
2018-02-07 20:50:01 +01:00
Robert Helgesson
f0d207f380
Add dag library to config.lib
Also replace all imports of `dag.nix` by the entry in `config.lib`.
2017-12-26 17:27:21 +01:00
Silvan Mosberger
8d360c5a57
systemd: remove filename hack 2017-12-12 18:05:04 +01:00
Cornelius Mika
8759a5a63e
systemd: add option to automatically start services 2017-12-11 18:25:49 +01:00
Cornelius Mika
52bdbc42bb
systemd: move activation script to separate file
This makes the following commit more readable.
2017-12-11 18:08:33 +01:00
Robert Helgesson
2ff09158f3
systemd: fix systemctl command
The command's path should be taken from the configuration, not be
assumed to be in `PATH`.
2017-12-11 16:58:50 +01:00
Robert Helgesson
bc2f2ad546
systemd: honor RefuseManualStart and RefuseManualStop
Fixes https://github.com/rycee/home-manager/issues/140
2017-11-16 15:37:53 +01:00
Robert Helgesson
7a9c873093
files: add special handling of systemd files
Unfortunately systemd derives nonsensical unit names when the unit
file is a link to a link to a file. This commit ensures that any file
whose target path matches the pattern `*/systemd/user/*` will be
reachable with only one link hop.

This also reverts f52ec0df7c, which
contained a temporary fix. This commit is an improvements in that it
is more explicit and also handles unit files given directly as a home
file source.
2017-11-12 00:56:34 +01:00
Robert Helgesson
f52ec0df7c
systemd: force copying of unit files
This is done by exploiting the fact that home files will be copied if
the executable bit of the source file and the target file is
different. This should be considered a hack until some nicer solution
is found.
2017-11-09 17:14:37 +01:00