How to export nix-shell dependency for deploy

i have a nix-shell script, and i want to export the nix-shell depdencies for deploy.

i think i need to copy the closure and channel to target offline server?

so what’s the way i should do?

[larluo@nixos-larluo:~/my-repo/datahub/contrib/metadata-ingestion]$ cat bin/datahub-producer.hs.nix
with import <nixpkgs> {} ;
let
in
mkShell {
  buildInputs = [
    (haskellPackages.ghcWithPackages ( p: 
      [ p.bytestring p.string-conversions
        p.exceptions 
        p.network-uri p.directory
        p.lens p.aeson p.lens-aeson p.avro p.hw-kafka-avro 
        p.hw-kafka-client 
        p.conduit p.hw-kafka-conduit
      ]
    ))
  ];
}

You can find a solution here : nix-shell command line option to print target derivation to stdout · Issue #711 · NixOS/nix · GitHub

I didn’t try it, but it may works…

1 Like

Take a read https://fzakaria.com/2020/08/11/caching-your-nix-shell.html

There’s also an open PR to make it work for multiple output derivations.
https://github.com/NixOS/nixpkgs/pull/95536

1 Like