Commit Graph

172717 Commits

Author SHA1 Message Date
aszlig
ac64ce9945
nixos: Add 'chroot' options to systemd.services
Currently, if you want to properly chroot a systemd service, you could
do it using BindReadOnlyPaths=/nix/store (which is not what I'd call
"properly", because the whole store is still accessible) or use a
separate derivation that gathers the runtime closure of the service you
want to chroot. The former is the easier method and there is also a
method directly offered by systemd, called ProtectSystem, which still
leaves the whole store accessible. The latter however is a bit more
involved, because you need to bind-mount each store path of the runtime
closure of the service you want to chroot.

This can be achieved using pkgs.closureInfo and a small derivation that
packs everything into a systemd unit, which later can be added to
systemd.packages. That's also what I did several times[1][2] in the
past.

However, this process got a bit tedious, so I decided that it would be
generally useful for NixOS, so this very implementation was born.

Now if you want to chroot a systemd service, all you need to do is:

  {
    systemd.services.yourservice = {
      description = "My Shiny Service";
      wantedBy = [ "multi-user.target" ];

      chroot.enable = true;
      serviceConfig.ExecStart = "${pkgs.myservice}/bin/myservice";
    };
  }

If more than the dependencies for the ExecStart* and ExecStop* (which
btw. also includes "script" and {pre,post}Start) need to be in the
chroot, it can be specified using the chroot.packages option. By
default (which uses the "full-apivfs"[3] confinement mode), a user
namespace is set up as well and /proc, /sys and /dev are mounted
appropriately.

In addition - and by default - a /bin/sh executable is provided as well,
which is useful for most programs that use the system() C library call
to execute commands via shell. The shell providing /bin/sh is dash
instead of the default in NixOS (which is bash), because it's way more
lightweight and after all we're chrooting because we want to lower the
attack surface and it should be only used for "/bin/sh -c something".

Prior to submitting this here, I did a first implementation of this
outside[4] of nixpkgs, which duplicated the "pathSafeName" functionality
from systemd-lib.nix, just because it's only a single line.

However, I decided to just re-use the one from systemd here and
subsequently made it available when importing systemd-lib.nix, so that
the systemd-chroot implementation also benefits from fixes to that
functionality (which is now a proper function).

Unfortunately, we do have a few limitations as well. The first being
that DynamicUser doesn't work in conjunction with tmpfs, because it
already sets up a tmpfs in a different path and simply ignores the one
we define. We could probably solve this by detecting it and try to
bind-mount our paths to that different path whenever DynamicUser is
enabled.

The second limitation/issue is that RootDirectoryStartOnly doesn't work
right now, because it only affects the RootDirectory option and not the
individual bind mounts or our tmpfs. It would be helpful if systemd
would have a way to disable specific bind mounts as well or at least
have some way to ignore failures for the bind mounts/tmpfs setup.

Another quirk we do have right now is that systemd tries to create a
/usr directory within the chroot, which subsequently fails. Fortunately,
this is just an ugly error and not a hard failure.

[1]: https://github.com/headcounter/shabitica/blob/3bb01728a0237ad5e7/default.nix#L43-L62
[2]: https://github.com/aszlig/avonc/blob/dedf29e092481a33dc/nextcloud.nix#L103-L124
[3]: The reason this is called "full-apivfs" instead of just "full" is
     to make room for a *real* "full" confinement mode, which is more
     restrictive even.
[4]: https://github.com/aszlig/avonc/blob/92a20bece4df54625e/systemd-chroot.nix

Signed-off-by: aszlig <aszlig@nix.build>
2019-03-14 19:14:01 +01:00
Matthew Bauer
b703c4d998 plasma5: fix typo from pr #57037
Thanks @Yarny0
2019-03-14 14:09:13 -04:00
Robert Schütz
badca37c51
Merge pull request #57621 from dtzWill/update/pyxlib-0.25
pythonPackages.xlib: 0.17 -> 0.25, enable tests
2019-03-14 18:20:46 +01:00
Robert Schütz
ec95b91b30 plover.stable: add setuptools_scm to nativeBuildInputs 2019-03-14 18:17:34 +01:00
Will Dietz
5a302b2005 pythonPackages.xlib: 0.17 -> 0.25, enable tests
https://github.com/python-xlib/python-xlib/releases/tag/0.25

(and the releases along the way)
2019-03-14 18:17:28 +01:00
Jörg Thalheim
8f9e283f92
Merge pull request #56959 from ck3d/ghidra
initial ghidra-9.0
2019-03-14 15:54:30 +00:00
Ryan Mulligan
8c0abe74f0
Merge pull request #57366 from r-ryantm/auto-update/pius
pius: 2.2.6 -> 2.2.7
2019-03-14 07:41:32 -07:00
Tim Steinbach
c22922e251
linux: 5.0.1 -> 5.0.2 2019-03-14 09:13:17 -04:00
Tim Steinbach
ef53c6dd07
linux: 4.20.15 -> 4.20.16 2019-03-14 09:13:07 -04:00
Tim Steinbach
82d6e57943
linux: 4.19.28 -> 4.19.29 2019-03-14 09:12:51 -04:00
Tim Steinbach
85924d84fc
linux: 4.14.105 -> 4.14.106 2019-03-14 09:12:37 -04:00
Tim Steinbach
c130cb7374
linux: 4.9.162 -> 4.9.163 2019-03-14 09:12:19 -04:00
Andreas Rammhold
a050cb9dc9
Merge pull request #57526 from xantoz/qtwebengine-fix-CVE-2019-5785
qt512: patch qtwebengine against CVE-2019-5786
2019-03-14 13:56:22 +01:00
Michael Weiss
871cd756c8
python.pkgs.distro: Re-enable the package for now
Most tests are fine (only 20 out of 173 fail, 10 because lsb_release is
not available or returns exit code 3 and the other 10 might also fail
due to the sandboxed build environment).
Manual tests show that distro works as intended in a normal environment.

See 9382d2ea76
2019-03-14 13:14:52 +01:00
Michael Weiss
0e0a00bb6f
gns3Packages.{server,gui}Preview: 2.2.0a1 -> 2.2.0a2 2019-03-14 12:54:11 +01:00
Jörg Thalheim
e66a47263f
Merge pull request #57544 from kim0/xmr-stak-2.10.1
xmr-stak: 2.8.3 -> 2.10.1
2019-03-14 11:44:29 +00:00
Jörg Thalheim
4d2fe32784
Merge pull request #57635 from Mic92/engineio
python3.pkgs.python-engineio: 3.0.0 -> 3.4.3
2019-03-14 11:28:24 +00:00
Jörg Thalheim
42bc96105f
python3.pkgs.engineio: limit to linux
probably has never build on macOS.
2019-03-14 11:23:14 +00:00
Nathan van Doorn
512833807d pythonPackages.cbor2: init at 4.1.2 (#57507) 2019-03-14 12:22:29 +01:00
Robert Schütz
aacd06eb5a
Merge pull request #57594 from nyanloutre/electron-cash-update
Electron cash update
2019-03-14 12:15:45 +01:00
Jörg Thalheim
f94dc01e75
python3.pkgs.python-engineio: 3.0.0 -> 3.4.3
fixes build of python-socketio
2019-03-14 11:14:43 +00:00
Michael Weiss
c4c37f3414
tdesktopPackages.preview: 1.5.15 -> 1.5.17 2019-03-14 12:00:08 +01:00
nyanloutre
32c205789e electron-cash: 3.3.2 -> 3.3.6
Missing dependency and cleanup of the build process
2019-03-14 11:54:38 +01:00
nyanloutre
9b9f4d9005 pythonPackages.qdarkstyle: init at 2.6.5 2019-03-14 11:54:38 +01:00
Gabriel Ebner
be261a1ede isabelle: refactor
Fixes #33337
2019-03-14 11:48:30 +01:00
Gabriel Ebner
308456a7a7
Merge pull request #57567 from gebner/isabelle-2018
isabelle: 2017 -> 2018
2019-03-14 11:25:02 +01:00
Robert Schütz
5ee0125268
python.pkgs.shapely: fix tests on Darwin (#57630) 2019-03-14 10:28:43 +01:00
Ihar Hrachyshka
4730466366 xscreensaver: Enable perl modules needed for RSS image fetch (#57629) 2019-03-14 08:20:51 +00:00
Will Dietz
4a7a9d1650 ethtool: 4.19 -> 5.0 2019-03-14 08:17:48 +01:00
Elis Hirwing
894eee60a7
Merge pull request #57245 from Izorkin/php-options
php: add custom options
2019-03-14 08:13:22 +01:00
Matthew Bauer
92ec809473
Merge pull request #56686 from r-ryantm/auto-update/gorm
gnustep.gorm: 1.2.23 -> 1.2.24
2019-03-14 00:18:28 -04:00
Ryan Mulligan
d5c6f5fd03
Merge pull request #57612 from dywedir/tiled
tiled: 1.2.2 -> 1.2.3
2019-03-13 20:54:16 -07:00
Ryan Mulligan
e20ee8a710
Merge pull request #57386 from kierdavis/pius-fix-dependencies
pius: fix dependencies
2019-03-13 19:44:26 -07:00
worldofpeace
44298e76d5 lightdm: disable writing dmrc files to home
Can cause issues where lightdm prefers the last saved session in .dmrc
even if it doesn't exist anymore, preventing people from logging in to
a session.
2019-03-13 21:19:23 -04:00
Edmund Wu
ecc6ee8f1d vscode: 1.32.1 -> 1.32.2 2019-03-13 20:42:33 -04:00
Robert Schütz
40d96815a1 home-assistant: 0.89.1 -> 0.89.2 2019-03-14 00:52:17 +01:00
dywedir
92ea2c2ffd
tiled: 1.2.2 -> 1.2.3 2019-03-14 01:41:25 +02:00
R. RyanTM
0a8d74d957 pywal: 3.2.1 -> 3.3.0 (#54685)
Semi-automatic update generated by
https://github.com/ryantm/nixpkgs-update tools. This update was made
based on information from
https://repology.org/metapackage/pywal/versions
2019-03-14 00:15:51 +01:00
Robert Schütz
098cb9f63a
Merge pull request #56082 from Ma27/fix-pyopencl
python3Packages.pyopencl: fix build
2019-03-14 00:11:22 +01:00
R. RyanTM
39789683d0 tgt: 1.0.74 -> 1.0.75 (#57489)
Semi-automatic update generated by
https://github.com/ryantm/nixpkgs-update tools. This update was made
based on information from
https://repology.org/metapackage/tgt/versions
2019-03-14 00:09:50 +01:00
R. RyanTM
ca713ac877 worker: 3.15.3 -> 3.15.4 (#57506)
Semi-automatic update generated by
https://github.com/ryantm/nixpkgs-update tools. This update was made
based on information from
https://repology.org/metapackage/worker/versions
2019-03-14 00:08:37 +01:00
R. RyanTM
c2d40b8790 xosview2: 2.3.0 -> 2.3.1 (#57515)
Semi-automatic update generated by
https://github.com/ryantm/nixpkgs-update tools. This update was made
based on information from
https://repology.org/metapackage/xosview2/versions
2019-03-14 00:07:02 +01:00
jD91mZM2
b9887d9fd1 xidlehook: v0.6.1 -> v0.6.2 (#57599) 2019-03-13 23:59:39 +01:00
Will Dietz
4d82af0250 inter-ui: 3.1 -> 3.3 (#57605)
FWIW new name but not sure worth renaming attribute
(to 'inter' or maybe 'inter-font'?)

https://github.com/rsms/inter/releases/tag/v3.3
https://github.com/rsms/inter/releases/tag/v3.2
2019-03-13 23:59:03 +01:00
Ethan Glasser-Camp
2556b7bfad virtualenv: Update patch for 16.2.0 (#57533) 2019-03-13 23:58:52 +01:00
Mario Rodas
da7d91017c pgmetrics: 1.5.0 -> 1.6.1 (#57575) 2019-03-13 23:49:53 +01:00
Robert Schütz
f721655455 python.pkgs.cairosvg1: remove
Make python2.pkgs.cairosvg refer to what previously was cairosvg1 instead.
2019-03-13 23:49:35 +01:00
Robert Schütz
22877838fa python.pkgs.cssselect2: add pytest to checkInputs 2019-03-13 23:49:35 +01:00
Robert Schütz
fca2c15ca6 python.pkgs.tinycss2: add pytest to checkInputs 2019-03-13 23:49:35 +01:00
Robert Schütz
fe633fb1be python.pkgs.pytest-isort: 0.2.1 -> 0.3.1 2019-03-13 23:49:35 +01:00