Curl | sh as flake

there is a common idiom to install software like this:

curl some.url/ | sh

I am aware of the security issues and general flaws.

Anyways, what is the best way to package such a software?
I am generally new to packaging things and would love to learn it for once.

Specifically, I want to package

You have to read the install script and create a package based on that

1 Like

For ollama, you can see from that it can be installed by downloading a binary and putting that binary in the right directory. So something like the derivation below should work for a quick trial. (But it’s probably better to try and build it from source.)

{ fetchurl, lib, stdenv, autoPatchelfHook }:

stdenv.mkDerivation rec {
  pname = "ollama";
  version = "0.1"; #Change this!
  src = fetchurl {
    url = "";
    hash = "sha256-WxRimPMHV2qbePUu9EVniApXy2NrLK97LsXO+Burdkk=";

  nativeBuildInputs = [

  dontUnpack = true;
  dontBuild = true;
  dontConfigure = true;

  installPhase = ''
    mkdir -p $out/bin
    install -m755 -D $src $out/bin/ollama

  meta = with lib; {
    homepage = "";
    description = "Enter Something Here";
    platforms = platforms.linux;

You may have to add some libraries to buildInputs, though. For packaging binaries, you can also consult this: Packaging/Binaries - NixOS Wiki


Thank you very much, I finally understand how the packaging works.

Sadly for this specific project someone else was faster to create a package for ollama.

It might still be useful to create an ollama-bin package, though! As you can see in this update request, it is sometimes difficult to build a project properly, which can delay updates. Having a binary package that doesn’t use nix to build the program but just ships the exact binary that the maintainer built can be useful as a workaround in such cases. Additionally, it can be helpful when debugging problems in the from-source package by comparing its behavior to the binary package.

So if you want to still have a go at this, feel free to do so!

1 Like

Thanks for the encouragement, this is the first thing I have contributed to nixpkgs. I have issued a PR for what I had (ollama-bin). Awaiting review.

Speaking of ollama, as I wanted to try this soon. I believe the binary package does not come with support for AMD ROCm built it. I think it would be nice, at least for me, to have an ollama-rocm version ready as well.

Edit: Could you @maixnor link your PR maybe?

1 Like