From 7f9c72e4c39521c174216f6623778a7061fbeb61 Mon Sep 17 00:00:00 2001 From: Richard Palethorpe Date: Thu, 25 Jul 2024 15:23:47 +0100 Subject: [PATCH] nix: Add server wrapper that include runtime deps While we don't have various deps bundled in the exe or in the case of pipreqs we don't fetch it; use Nix to package them. --- distros/nix/server.nix | 20 ++++++++++++++++++++ flake.nix | 5 +++++ 2 files changed, 25 insertions(+) create mode 100644 distros/nix/server.nix diff --git a/distros/nix/server.nix b/distros/nix/server.nix new file mode 100644 index 0000000..835bb51 --- /dev/null +++ b/distros/nix/server.nix @@ -0,0 +1,20 @@ +{ + lib, stdenv, makeWrapper, version, buildkit, nerdctl, pipreqs, cli +}: +let + runtimeDeps = [ buildkit nerdctl pipreqs ]; +in + stdenv.mkDerivation { + pname = "ayup-server"; + meta.mainProgram = "ay"; + inherit version; + src = cli; + nativeBuildInputs = [ makeWrapper ]; + buildInputs = runtimeDeps; + installPhase = '' + mkdir -p $out/bin + cp $src/bin/ay $out/bin/ + wrapProgram $out/bin/ay \ + --prefix PATH : ${ lib.makeBinPath runtimeDeps } + ''; + } diff --git a/flake.nix b/flake.nix index 3199e3d..a15f1cd 100644 --- a/flake.nix +++ b/flake.nix @@ -54,6 +54,9 @@ GOOS = "linux"; GOARCH = "amd64"; }; + server = pkgs.callPackage ./distros/nix/server.nix { + inherit version cli; + }; in { devShells.${system}.default = pkgs.mkShell { @@ -67,6 +70,8 @@ packages.${system} = { inherit src; inherit cli cli-darwin-amd64 cli-darwin-arm64 cli-linux-arm64 cli-linux-amd64; + inherit server; + default = cli; dev = pkgs.stdenv.mkDerivation { pname = "dev";