12 stdenv.mkDerivation rec {
16 src = fetchFromGitHub {
20 sha256 = "sha256-XAlb6SSyY2S1iWDaulIlghQ16OGvT/wBCog95/nxkog=";
37 # Adds the /nix directory when using an overlay.
38 # Required to run any programs under this mode.
39 ./mount-nix-dir-on-overlay.patch
41 # By default fbuilder hardcodes the firejail binary to the install path.
42 # On NixOS the firejail binary is a setuid wrapper available in $PATH.
43 ./fbuilder-call-firejail-on-path.patch
47 # Fix the path to 'xdg-dbus-proxy' hardcoded in the 'common.h' file
48 substituteInPlace src/include/common.h \
49 --replace '/usr/bin/xdg-dbus-proxy' '${xdg-dbus-proxy}/bin/xdg-dbus-proxy'
51 # Workaround for regression introduced in 0.9.72 preventing usage of
52 # end-of-options indicator "--"
53 # See https://github.com/netblue30/firejail/issues/5659
54 substituteInPlace src/firejail/sandbox.c \
55 --replace " && !arg_doubledash" ""
59 sed -e 's@/bin/bash@${stdenv.shell}@g' -i $( grep -lr /bin/bash .)
60 sed -e "s@/bin/cp@$(which cp)@g" -i $( grep -lr /bin/cp .)
64 sed -e "s@/etc/@$out/etc/@g" -e "/chmod u+s/d" -i Makefile
67 # The profile files provided with the firejail distribution include `.local`
68 # profile files using relative paths. The way firejail works when it comes to
69 # handling includes is by looking target files up in `~/.config/firejail`
70 # first, and then trying `SYSCONFDIR`. The latter normally points to
71 # `/etc/filejail`, but in the case of nixos points to the nix store. This
72 # makes it effectively impossible to place any profile files in
75 # The workaround applied below is by creating a set of `.local` files which
76 # only contain respective includes to `/etc/firejail`. This way
77 # `~/.config/firejail` still takes precedence, but `/etc/firejail` will also
78 # be searched in second order. This replicates the behaviour from
79 # non-nixos platforms.
81 # See https://github.com/netblue30/firejail/blob/e4cb6b42743ad18bd11d07fd32b51e8576239318/src/firejail/profile.c#L68-L83
82 # for the profile file lookup implementation.
84 for local in $(grep -Eh '^include.*local$' $out/etc/firejail/*{.inc,.profile} | awk '{print $2}' | sort | uniq)
86 echo "include /etc/firejail/$local" >$out/etc/firejail/$local
90 # At high parallelism, the build sometimes fails with:
91 # bash: src/fsec-optimize/fsec-optimize: No such file or directory
92 enableParallelBuilding = false;
94 passthru.tests = nixosTests.firejail;
97 description = "Namespace-based sandboxing tool for Linux";
98 license = lib.licenses.gpl2Plus;
99 maintainers = [ lib.maintainers.raskin ];
100 platforms = lib.platforms.linux;
101 homepage = "https://firejail.wordpress.com/";