about summary refs log tree commit diff
path: root/pkgs/os-specific/bsd/freebsd/pkgs/install.nix
blob: b8e59adb09c5fb5de99a92826c9475799be3da75 (plain) (blame)
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
59
60
61
62
63
64
65
66
67
{
  lib,
  stdenv,
  mkDerivation,
  writeShellScript,
  freebsd-lib,
  bsdSetupHook,
  freebsdSetupHook,
  makeMinimal,
  mandoc,
  groff,
  boot-install,
  install,
  compatIfNeeded,
  libmd,
  libnetbsd,
}:

# HACK: to ensure parent directories exist. This emulates GNU
# install’s -D option. No alternative seems to exist in BSD install.
let
  binstall = writeShellScript "binstall" (
    freebsd-lib.install-wrapper
    + ''

      @out@/bin/xinstall "''${args[@]}"
    ''
  );
in
mkDerivation {
  path = "usr.bin/xinstall";
  extraPaths = [ "contrib/mtree" ];
  nativeBuildInputs = [
    bsdSetupHook
    freebsdSetupHook
    makeMinimal
    mandoc
    groff
    (if stdenv.hostPlatform == stdenv.buildPlatform then boot-install else install)
  ];
  skipIncludesPhase = true;
  buildInputs = compatIfNeeded ++ [
    libmd
    libnetbsd
  ];
  makeFlags =
    [
      "STRIP=-s" # flag to install, not command
      "MK_WERROR=no"
      "TESTSDIR=${builtins.placeholder "test"}"
    ]
    ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [
      "BOOTSTRAPPING=1"
      "INSTALL=boot-install"
    ];
  postInstall = ''
    install -C -m 0550 ${binstall} $out/bin/binstall
    substituteInPlace $out/bin/binstall --subst-var out
    mv $out/bin/install $out/bin/xinstall
    ln -s ./binstall $out/bin/install
  '';
  outputs = [
    "out"
    "man"
    "test"
  ];
}