Commit Graph
175090 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
Wael M. Nasreddine d45408bd48 mod: init at 0.2.0 2019-03-14 11:03:47 -07:00
Janne Heß 531171e1c9 tt-rss-theme-feedly: Package additional themes 2019-03-14 19:01:32 +01:00
Aria Edmonds 2a2fe2bea4 obs-studio: 22.0.3 -> 23.0.2 2019-03-15 04:38:20 +11:00
Wael M. Nasreddine 8f8e71c0a1 hetzner-kube: set the version via ldflags 2019-03-14 10:31:20 -07:00
Wael M. Nasreddine 8f5b40591d hetzner-kube: 0.3.2rc1 -> 0.4.1 using buildGoModule 2019-03-14 10:31:19 -07:00
Wael M. Nasreddine 554406b510 todoist: use buildGoModule instead of buildGoPackage 2019-03-14 10:31:18 -07:00
Wael M. Nasreddine a7586b3055 terminal-parrot: 1.1.0 -> 1.1.1 using buildGoModule 2019-03-14 10:31:17 -07:00
Wael M. Nasreddine cfbe152ae8 terminal-parrot: indent and use version when fetching dependencies 2019-03-14 10:31:16 -07:00
Wael M. Nasreddine 6ee0d3604e gotools: use buildGoModule instead of buildGoPackage 2019-03-14 10:31:15 -07:00
Wael M. Nasreddine 1a4cccd561 gotools: 2019-02-11 -> 2019-03-05 2019-03-14 10:31:14 -07:00
Wael M. Nasreddine 3c7f228e49 hugo: use buildGoModule instead of buildGoPackage 2019-03-14 10:31:13 -07:00
Wael M. Nasreddine ff110364a4 pet: use buildGoModule instead of buildGoPackage 2019-03-14 10:31:12 -07:00
Wael M. Nasreddine a51627585f jx: use buildGoModule instead of buildGoPackage 2019-03-14 10:31:11 -07:00
Wael M. Nasreddine 28435e47b1 buildGoModule: function for packaging Go modules
The function buildGoModule builds Go programs managed with Go modules. It builds
a Go module through a two phase build:

- An intermediate fetcher derivation. This derivation will be used to
  fetch all of the dependencies of the Go module.
- A final derivation will use the output of the intermediate derivation
  to build the binaries and produce the final output.
2019-03-14 10:31:02 -07: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
worldofpeace 72679615a1 pythonPackages.weboob: add pyqt5 as native input
Didn't notice it wasn't there. This should make it so we
don't have to set the environment variable anymore.
2019-03-14 13:13:00 -04:00
Dmitry Kalinkin ec4bdc860e nsis: use zlib outputs directly 2019-03-14 12:59:38 -04:00
Dmitry Kalinkin f929120b1b nsis: don't disable stripping 2019-03-14 12:56:03 -04:00
Dmitry Kalinkin dc04edc6ae nsis: refactor to use scons setup-hook 2019-03-14 12:53:36 -04:00
Vincent Demeester f73f0e5e2e kail: 0.7.0 -> 0.8.0
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2019-03-14 17:24:26 +01:00
Vincent Demeester 115dde6d33 containerd: 1.2.4 -> 1.2.5
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2019-03-14 17:05:29 +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
marius851000 2d03ed2f8d openmw: force the need of qt5 2019-03-14 15:53:34 +01: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
Jan Malakhovski 2bc525350a treewide: stdenv.config -> config
That attribute does not exist.
2019-03-14 14:01:21 +00:00
Jan Malakhovski 67a7b42167 pkgs/stdenv/booter.nix: fix a typo 2019-03-14 14:01:20 +00: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 https://github.com/NixOS/nixpkgs/commit/9382d2ea762302c7a7a5c970679e4fca14256eca
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
Pedro Pombeiro f875b1c6f2 nsis: init at 3.04 2019-03-14 10:34:31 +01:00