nixpkgs/pkgs/tools/security/doas/default.nix
Cole Helbling 82f897333a
doas: add NixOS binary dirs to safe PATH
I recently tried to give myself passwordless `doas` for `virsh` commands
(starting, stopping, and editing VMs), but `doas` was complaining that
it didn't know what `virsh` was.

This patch adds `/run/current-system/sw/{s,}bin` and `/run/wrappers/bin`
to the safe path, allowing system binaries to be discovered and executed
properly.
2020-05-27 08:11:30 -07:00

49 lines
1.1 KiB
Nix

{ stdenv
, lib
, fetchFromGitHub
, bison
, pam
, withTimestamp ? true
}:
stdenv.mkDerivation rec {
pname = "doas";
version = "6.6.1";
src = fetchFromGitHub {
owner = "Duncaen";
repo = "OpenDoas";
rev = "v${version}";
sha256 = "07kkc5729p654jrgfsc8zyhiwicgmq38yacmwfvay2b3gmy728zn";
};
# otherwise confuses ./configure
dontDisableStatic = true;
configureFlags = [
(lib.optionalString withTimestamp "--with-timestamp") # to allow the "persist" setting
"--pamdir=${placeholder "out"}/etc/pam.d"
];
patches = [
# Allow doas to discover binaries in /run/current-system/sw/{s,}bin and
# /run/wrappers/bin
./0001-add-NixOS-specific-dirs-to-safe-PATH.patch
];
postPatch = ''
sed -i '/\(chown\|chmod\)/d' bsd.prog.mk
'';
buildInputs = [ bison pam ];
meta = with lib; {
description = "Executes the given command as another user";
homepage = "https://github.com/Duncaen/OpenDoas";
license = licenses.isc;
platforms = platforms.linux;
maintainers = with maintainers; [ cole-h cstrahan ];
};
}