about summary refs log tree commit diff
path: root/pkgs/tools/package-management/nix-bundle/default.nix
blob: a32f788bf4dca9db834bf6ea48fad60f2cfbfb94 (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
{ lib
, stdenv
, fetchFromGitHub
, bzip2
, coreutils
, gnutar
, gzip
, makeWrapper
, nix
}:

stdenv.mkDerivation rec {
  pname = "nix-bundle";
  version = "0.4.1";

  src = fetchFromGitHub {
    owner = "matthewbauer";
    repo = pname;
    rev = "v${version}";
    sha256 = "0js8spwjvw6kjxz1i072scd035fhiyazixvn84ibdnw8dx087gjv";
  };

  nativeBuildInputs = [ makeWrapper ];

  # coreutils, gnutar are needed by nix for bootstrap
  buildInputs = [
    bzip2
    coreutils
    gnutar
    gzip
    nix
  ];

  makeFlags = [ "PREFIX=$(out)" ];

  postInstall = ''
    mkdir -p $out/bin
    makeWrapper $out/share/nix-bundle/nix-bundle.sh $out/bin/nix-bundle \
      --prefix PATH : ${lib.makeBinPath buildInputs}
    ln -s $out/share/nix-bundle/nix-run.sh $out/bin/nix-run
  '';

  meta = with lib; {
    homepage = "https://github.com/matthewbauer/nix-bundle";
    description = "Create bundles from Nixpkgs attributes";
    longDescription = ''
      nix-bundle is a way to package Nix attributes into single-file
      executables.

      Benefits:
      - Single-file output
      - Can be run by non-root users
      - No runtime
      - Distro agnostic
      - No installation
    '';
    license = licenses.mit;
    maintainers = [ maintainers.matthewbauer ];
    platforms = platforms.all;
  };
}