I am trying to implement a fully defined and reproducible repo that depends on ollama. ollama depends on it’s service running. I have defined the service in my Flake but nix develop does not start the service. nix flake check does not flag the Flake as being malformed. When I aam reviewing documentation for Flakes, I do not immediately see mention of services.
{
description = "Define development dependencies.";
inputs = {
# Which Nix upstream package branch to track
nixpkgs.url = "nixpkgs/nixos-unstable";
};
# What results we're going to expose
outputs = { self, nixpkgs }:
let
# What packages and system functions we'll use
pkgs = import nixpkgs { system = "x86_64-linux"; };
python_name = "python3.12";
python = pkgs.python312;
in {
devShells.x86_64-linux.default = pkgs.mkShell rec {
packages = with pkgs; [
python3Full
(poetry.override { python3 = python; })
direnv
gcc-unwrapped
stdenv
ruff
ollama-rocm
# NOTE: Put additional packages you need in this array. Packages may be found by looking them up in
# https://search.nixos.org/packages
];
# Getting the library paths needed for Python to be put into
# LD_LIBRARY_PATH
pythonldlibpath = "${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.stdenv.cc.cc.lib.outPath}/lib:${pkgs.lib.makeLibraryPath packages}";
# Run the following on the shell, which builds up LD_LIBRARY_PATH.
shellHook = ''
export LD_LIBRARY_PATH="${pythonldlibpath}"
'';
};
services.ollama = {
enable = true;
acceleration = "rocm";
environmentVariables = {
HCC_AMDGPU_TARGET = "gfx1100";
HSA_OVERRIDE_GFX_VERSION = "11.0.0";
};
rocmOverrideGfx = "11.0.0";
};
};
}
I am testing this by simply running ollama run deepseek-r1.
If you are going to use service in nix develop which is flakes shell.
You have to look into devenv.sh
I found this one, which uses nix flakes, devenv for basic ollama.
Hope this help in progressing further.
I’m also looking into making a devenv for Ollama looking into nixos service.ollama.enable config code.
It is little difficult for me to understand all the config.
You can create your own config similar to nixos Ollama using devenv.
These really emphasized a use of flakes to specify a service and not packages. I’m still new, so it took some time to chew threw. The links helped but did not solve my issue. I did ultimately get something close enough.