add(nix): docker for darwin

This commit is contained in:
Léana 江 2024-03-03 21:16:13 +01:00 committed by Léana 江
parent 191d01a209
commit 8a260ee62e
6 changed files with 127 additions and 61 deletions

View file

@ -0,0 +1,61 @@
{
pkgs,
lib,
config,
...
}: {
environment.systemPackages = lib.lists.optionals config.docker.enable (
let
darwinPkgs = lib.lists.optionals pkgs.stdenv.isDarwin [pkgs.colima];
in
[
pkgs.docker
pkgs.docker-compose
]
++ darwinPkgs
);
environment.userLaunchAgents = let
path =
builtins.concatStringsSep ":"
(map (p: "${p}/bin") [
pkgs.docker
pkgs.docker-compose
]);
defaultPath = "/usr/bin:/bin:/usr/sbin:/sbin";
in {
"colima.plist" = {
# https://github.com/abiosoft/colima/issues/490
# Doesn't work at the moment
enable = false;
# make sure docker and docker-compose is in the path, otherwise `colima` won't launch
text = ''
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key> <string>org.nix.colima</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>${path}:${defaultPath}</string>
</dict>
<key>ProgramArguments</key>
<array>
<string>${pkgs.colima}/bin/colima</string>
<string>start</string>
</array>
<key>RunAtLoad</key> <true/>
<key>KeepAlive</key> <true/>
<key>ThrottleInterval</key> <integer>60</integer>
</dict>
</plist>
'';
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./llama-cpp.nix
./colima.nix
];
}

View file

@ -0,0 +1,29 @@
{llama-cpp, ...}: {
environment.userLaunchAgents = {
"llama-server.plist" = {
enable = false;
text = ''
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key> <string>org.nix.llama-server</string>
<key>ProgramArguments</key>
<array>
<string>${llama-cpp}/bin/llama-server</string>
<string>--model</string>
<string>/Users/leana/llm/mistral_7B-Q4_K_M.gguf</string>
</array>
<key>RunAtLoad</key> <true/>
<key>KeepAlive</key> <true/>
<key>ThrottleInterval</key> <integer>60</integer>
</dict>
</plist>
'';
};
};
}