about summary refs log tree commit diff
path: root/pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix')
-rw-r--r--pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix49
1 files changed, 49 insertions, 0 deletions
diff --git a/pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix b/pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix
new file mode 100644
index 0000000000000..991517ac2d486
--- /dev/null
+++ b/pkgs/os-specific/bsd/netbsd/pkgs/install/package.nix
@@ -0,0 +1,49 @@
+{ mkDerivation
+, writeShellScript
+, mtree, make
+, bsdSetupHook, netbsdSetupHook
+, makeMinimal
+, mandoc, groff, rsync
+, compatIfNeeded, fts
+
+}:
+
+# 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" ''
+    set -eu
+    for last in "$@"; do true; done
+    mkdir -p $(dirname $last)
+    @out@/bin/xinstall "$@"
+  '';
+in
+  mkDerivation {
+    path = "usr.bin/xinstall";
+    version = "9.2";
+    sha256 = "1f6pbz3qv1qcrchdxif8p5lbmnwl8b9nq615hsd3cyl4avd5bfqj";
+    extraPaths = [ mtree.src make.src ];
+    nativeBuildInputs = [
+      bsdSetupHook netbsdSetupHook
+      makeMinimal
+      mandoc groff rsync
+    ];
+    skipIncludesPhase = true;
+    buildInputs = compatIfNeeded
+      # fts header is needed. glibc already has this header, but musl doesn't,
+      # so make sure pkgsMusl.netbsd.install still builds in case you want to
+      # remove it!
+      ++ [ fts ];
+    installPhase = ''
+      runHook preInstall
+
+      install -D install.1 $out/share/man/man1/install.1
+      install -D xinstall $out/bin/xinstall
+      install -D -m 0550 ${binstall} $out/bin/binstall
+      substituteInPlace $out/bin/binstall --subst-var out
+      ln -s $out/bin/binstall $out/bin/install
+
+      runHook postInstall
+    '';
+    setupHook = ./install-setup-hook.sh;
+  }