1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-06 10:39:29 +03:00

Merge pull request #43511 from peterhoeg/m/firejail

firejail: add nixos module
This commit is contained in:
Peter Hoeg 2018-07-14 21:04:11 +08:00 committed by GitHub
commit 6e3ee65b44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 0 deletions

View file

@ -86,6 +86,7 @@
./programs/dconf.nix
./programs/digitalbitbox/default.nix
./programs/environment.nix
./programs/firejail.nix
./programs/fish.nix
./programs/freetds.nix
./programs/gnupg.nix

View file

@ -0,0 +1,48 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.firejail;
wrappedBins = pkgs.stdenv.mkDerivation rec {
name = "firejail-wrapped-binaries";
nativeBuildInputs = with pkgs; [ makeWrapper ];
buildCommand = ''
mkdir -p $out/bin
${lib.concatStringsSep "\n" (lib.mapAttrsToList (command: binary: ''
cat <<_EOF >$out/bin/${command}
#!${pkgs.stdenv.shell} -e
/run/wrappers/bin/firejail ${binary} "\$@"
_EOF
chmod 0755 $out/bin/${command}
'') cfg.wrappedBinaries)}
'';
};
in {
options.programs.firejail = {
enable = mkEnableOption "firejail";
wrappedBinaries = mkOption {
type = types.attrs;
default = {};
description = ''
Wrap the binaries in firejail and place them in the global path.
</para>
<para>
You will get file collisions if you put the actual application binary in
the global environment and applications started via .desktop files are
not wrapped if they specify the absolute path to the binary.
'';
};
};
config = mkIf cfg.enable {
security.wrappers.firejail.source = "${lib.getBin pkgs.firejail}/bin/firejail";
environment.systemPackages = [ wrappedBins ];
};
meta.maintainers = with maintainers; [ peterhoeg ];
}