Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, fetchFromGitHub
4, runCommand
5, asciidoctor
6, coreutils
7, gawk
8, glibc
9, util-linux
10, bash
11, makeBinaryWrapper
12, doas-sudo-shim
13}:
14
15stdenv.mkDerivation rec {
16 pname = "doas-sudo-shim";
17 version = "0.1.1";
18
19 src = fetchFromGitHub {
20 owner = "jirutka";
21 repo = "doas-sudo-shim";
22 rev = "v${version}";
23 sha256 = "QYVqGxeWC7Tiz8aNY/LukwG4EW0km/RunGEfkzY/A38=";
24 };
25
26 nativeBuildInputs = [ asciidoctor makeBinaryWrapper ];
27 buildInputs = [ bash coreutils gawk glibc util-linux ];
28
29 dontConfigure = true;
30 dontBuild = true;
31
32 installFlags = [ "DESTDIR=$(out)" "PREFIX=\"\"" ];
33
34 postInstall = ''
35 wrapProgram $out/bin/sudo \
36 --prefix PATH : ${lib.makeBinPath [ bash coreutils gawk glibc util-linux ]}
37 '';
38
39 passthru.tests = {
40 helpTest = runCommand "${pname}-helpTest" {} ''
41 ${doas-sudo-shim}/bin/sudo -h > $out
42 grep -q "Execute a command as another user using doas(1)" $out
43 '';
44 };
45
46 meta = with lib; {
47 description = "A shim for the sudo command that utilizes doas";
48 homepage = "https://github.com/jirutka/doas-sudo-shim";
49 license = licenses.isc;
50 mainProgram = "sudo";
51 maintainers = with maintainers; [ dsuetin ];
52 platforms = platforms.linux;
53 };
54}