base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / ni / nix-serve / package.nix
blob2ece72b66bf100dbd3ed9e794fba10aba1201195
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , bzip2
5 , nixVersions
6 , makeWrapper
7 , nixosTests
8 , fetchpatch
9 }:
11 let
12   rev = "77ffa33d83d2c7c6551c5e420e938e92d72fec24";
13   sha256 = "sha256-MJRdVO2pt7wjOu5Hk0eVeNbk5bK5+Uo/Gh9XfO4OlMY=";
14   nix = nixVersions.nix_2_24;
15   inherit (nix.perl-bindings) perl;
18 stdenv.mkDerivation {
19   pname = "nix-serve";
20   version = "0.2-${lib.substring 0 7 rev}";
22   src = fetchFromGitHub {
23     owner = "edolstra";
24     repo = "nix-serve";
25     inherit rev sha256;
26   };
28   patches = [
29     # Part of https://github.com/edolstra/nix-serve/pull/61
30     (fetchpatch {
31       url = "https://github.com/edolstra/nix-serve/commit/9e434fff4486afeb3cc3f631f6dc56492b204704.patch";
32       sha256 = "sha256-TxQ6q6UApTKsYIMdr/RyrkKSA3k47stV63bTbxchNTU=";
33     })
34   ];
36   nativeBuildInputs = [ makeWrapper ];
38   dontBuild = true;
40   installPhase = ''
41     install -Dm0755 nix-serve.psgi $out/libexec/nix-serve/nix-serve.psgi
43     makeWrapper ${perl.withPackages(p: [ p.DBDSQLite p.Plack p.Starman nix.perl-bindings ])}/bin/starman $out/bin/nix-serve \
44                 --prefix PATH : "${lib.makeBinPath [ bzip2 nix ]}" \
45                 --add-flags $out/libexec/nix-serve/nix-serve.psgi
46   '';
48   /** The nix package that nix-serve got its nix perl bindings from. */
49   passthru.nix = nix;
51   passthru.tests = {
52     nix-serve = nixosTests.nix-serve;
53     nix-serve-ssh = nixosTests.nix-serve-ssh;
54   };
56   meta = with lib; {
57     homepage = "https://github.com/edolstra/nix-serve";
58     description = "Utility for sharing a Nix store as a binary cache";
59     maintainers = [ maintainers.eelco ];
60     license = licenses.lgpl21;
61     # See https://github.com/edolstra/nix-serve/issues/57
62     broken = stdenv.isDarwin;
63     platforms = nix.meta.platforms;
64     mainProgram = "nix-serve";
65   };