summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/di/dinit/package.nix
blob: 4b18d93ce663971d907b915d4fffd614610686d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
  lib,
  stdenv,
  fetchFromGitHub,
  m4,
  installShellFiles,
  util-linuxMinimal,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "dinit";
  version = "0.22.1";

  src = fetchFromGitHub {
    owner = "davmac314";
    repo = "dinit";
    rev = "v${finalAttrs.version}";
    # fix for case-insensitive filesystems
    postFetch = ''
      [ -f "$out/BUILD" ] && rm "$out/BUILD"
    '';
    hash = "sha256-LerUex/P8UYFWG0TK8LAFPlFBNIVIH2cZfBxe6AD7Sc=";
  };

  postPatch = ''
    substituteInPlace src/shutdown.cc \
      --replace-fail '"/bin/umount"' '"${util-linuxMinimal}/bin/umount"' \
      --replace-fail '"/sbin/swapoff"' '"${util-linuxMinimal}/bin/swapoff"'
  '';

  nativeBuildInputs = [
    m4
    installShellFiles
  ];

  configureFlags = [
    "--prefix=${placeholder "out"}"
    "--sbindir=${placeholder "out"}/bin"
  ];

  postInstall = ''
    installShellCompletion --cmd dinitctl \
      --bash contrib/shell-completion/bash/dinitctl \
      --fish contrib/shell-completion/fish/dinitctl.fish \
      --zsh contrib/shell-completion/zsh/_dinit
  '';

  meta = {
    description = "Service manager / supervision system, which can (on Linux) also function as a system manager and init";
    homepage = "https://davmac.org/projects/dinit";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      aanderse
      lillecarl
    ];
    platforms = lib.platforms.unix;
  };
})