Personal Nix setup

Merge branch 'irnbru'

+6
flake.nix
···
hostname = "fanta";
};
nixosConfigurations."pepper" = mkSystem {
inherit overlays;
system = "x86_64-linux";
···
hostname = "fanta";
};
+
darwinConfigurations."irnbru" = mkSystem {
+
inherit overlays;
+
system = "aarch64-darwin";
+
hostname = "irnbru";
+
};
+
nixosConfigurations."pepper" = mkSystem {
inherit overlays;
system = "x86_64-linux";
+34 -4
home/apps/ollama.nix
···
OLLAMA_FLASH_ATTENTION = if cfg.ollama.flashAttention then "1" else "0";
OLLAMA_SCHED_SPREAD = if cfg.ollama.schedSpread then "1" else "0";
OLLAMA_INTEL_GPU = if cfg.ollama.intelGpu then "1" else "0";
};
in {
options.modules.apps.ollama = {
···
type = types.bool;
};
package = mkOption {
default = pkgs.ollama;
type = types.package;
···
default = "http://0.0.0.0:11434";
description = "Determines the host and port to listen on";
type = types.str;
};
flashAttention = mkOption {
-
default = false;
description = ''
-
Enables experimental flash att ention feature.
Effect: Activates an experimental optimization for attention mechanisms.
Scenario: Can potentially improve performance on compatible hardware but may introduce instability.
'';
type = types.bool;
};
schedSpread = mkOption {
default = false;
description = ''
···
}
(helpers.mkIfLinux {
-
systemd.user.services.ollama = {
Unit = {
Description = "Ollama";
Documentation = "https://github.com/jmorganca/ollama";
···
})
(helpers.mkIfDarwin {
-
launchd.agents.ollama = {
enable = true;
config = {
EnvironmentVariables = env;
···
OLLAMA_FLASH_ATTENTION = if cfg.ollama.flashAttention then "1" else "0";
OLLAMA_SCHED_SPREAD = if cfg.ollama.schedSpread then "1" else "0";
OLLAMA_INTEL_GPU = if cfg.ollama.intelGpu then "1" else "0";
+
OLLAMA_KV_CACHE_TYPE = cfg.ollama.kvCacheType;
+
OLLAMA_CONTEXT_LENGTH = toString cfg.ollama.defaultContextLength;
+
OLLAMA_MAX_LOADED_MODELS = toString cfg.ollama.maxLoadedModels;
};
in {
options.modules.apps.ollama = {
···
type = types.bool;
};
+
enableServer = mkOption {
+
default = true;
+
description = "Whether to enable Ollama's server.";
+
type = types.bool;
+
};
+
package = mkOption {
default = pkgs.ollama;
type = types.package;
···
default = "http://0.0.0.0:11434";
description = "Determines the host and port to listen on";
type = types.str;
+
};
+
+
maxLoadedModels = mkOption {
+
default = 3;
+
type = types.int;
+
};
+
+
defaultContextLength = mkOption {
+
default = 32768;
+
type = types.int;
};
flashAttention = mkOption {
+
default = true;
description = ''
+
Enables experimental flash attention feature.
Effect: Activates an experimental optimization for attention mechanisms.
Scenario: Can potentially improve performance on compatible hardware but may introduce instability.
'';
type = types.bool;
};
+
kvCacheType = mkOption {
+
default = "q8_0";
+
type = types.enum [ "f16" "q8_0" "q4_0" ];
+
description = ''
+
Determines the K/V cache quantization type
+
Effect: Activates quantization of the K/V cache reducing memory usage with flash attention.
+
Scenario: Can lead to reduced VRAM usage at the cost of accuracy.
+
Models with a higher Grouped Query Attention (GQA) count (e.g. Qwen 2) will see a larger negative impact.
+
'';
+
};
+
schedSpread = mkOption {
default = false;
description = ''
···
}
(helpers.mkIfLinux {
+
systemd.user.services.ollama = mkIf cfg.ollama.enableServer {
Unit = {
Description = "Ollama";
Documentation = "https://github.com/jmorganca/ollama";
···
})
(helpers.mkIfDarwin {
+
launchd.agents.ollama = mkIf cfg.ollama.enableServer{
enable = true;
config = {
EnvironmentVariables = env;
+13
machines/irnbru/configuration.nix
···
···
+
{ pkgs, ... }:
+
+
{
+
imports = [ ];
+
+
modules = {
+
server = {
+
enable = true;
+
sshd.enable = true;
+
tailscale.enable = true;
+
};
+
};
+
}
+11
machines/irnbru/home.nix
···
···
+
{ ... }:
+
+
{
+
modules = {
+
apps = {
+
enable = true;
+
ollama.enable = true;
+
ghostty.enable = true;
+
};
+
};
+
}
+1
machines/ramune/configuration.nix
···
{ macAddress = "98:ed:7e:c6:57:b2"; ipAddress = "10.0.0.102"; } # eero router
{ macAddress = "c4:f1:74:51:4c:f2"; ipAddress = "10.0.0.124"; } # eero router
{ macAddress = "5c:61:99:7a:16:40"; ipAddress = "10.0.0.103"; } # brother printer
];
nftables.blockForward = [
"ec:e5:12:1d:23:40" # tado
···
{ macAddress = "98:ed:7e:c6:57:b2"; ipAddress = "10.0.0.102"; } # eero router
{ macAddress = "c4:f1:74:51:4c:f2"; ipAddress = "10.0.0.124"; } # eero router
{ macAddress = "5c:61:99:7a:16:40"; ipAddress = "10.0.0.103"; } # brother printer
+
{ macAddress = "1c:1d:d3:de:4b:06"; ipAddress = "10.0.0.35"; } # irnbru
];
nftables.blockForward = [
"ec:e5:12:1d:23:40" # tado
+1
machines/sodacream/home.nix
···
};
apps = {
enable = true;
ghostty.enable = true;
zen-browser.enable = true;
discord.enable = true;
···
};
apps = {
enable = true;
+
ollama.enable = true;
ghostty.enable = true;
zen-browser.enable = true;
discord.enable = true;
+18
modules/base/macos.nix
···
system = {
primaryUser = "${user}";
keyboard = {
enableKeyMapping = true;
remapCapsLockToControl = true;
···
tilesize = 46;
mru-spaces = false;
};
NSGlobalDomain = {
AppleShowAllExtensions = true;
InitialKeyRepeat = 10;
KeyRepeat = 2;
···
"com.apple.swipescrolldirection" = false;
};
spaces.spans-displays = false;
};
};
}
···
system = {
primaryUser = "${user}";
+
activationScripts.postActivation.text = ''
+
# disable spotlight
+
launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist >/dev/null 2>&1 || true
+
# disable fseventsd on /nix volume
+
mkdir -p /nix/.fseventsd
+
test -e /nix/.fseventsd/no_log || touch /nix/.fseventsd/no_log
+
'';
+
keyboard = {
enableKeyMapping = true;
remapCapsLockToControl = true;
···
tilesize = 46;
mru-spaces = false;
};
+
LaunchServices.LSQuarantine = false;
NSGlobalDomain = {
+
AppleMeasurementUnits = "Centimeters";
+
AppleMetricUnits = 1;
+
AppleTemperatureUnit = "Celsius";
AppleShowAllExtensions = true;
InitialKeyRepeat = 10;
KeyRepeat = 2;
···
"com.apple.swipescrolldirection" = false;
};
spaces.spans-displays = false;
+
+
CustomSystemPreferences = {
+
"com.apple.TimeMachine".DoNotOfferNewDisksForBackup = true;
+
"com.apple.ImageCapture".disableHotPlug = true;
+
"com.apple.gamed".Disabled = true;
+
};
};
};
}
+4 -3
modules/base/nix-config.nix
···
-
{ lib, pkgs, inputs, helpers, config, ... }:
with lib; mkMerge [
{
···
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
trusted-users = [ "root" "@wheel" ];
# on Apple Silicon, Rosetta 2 allows for this
extra-platforms = mkIf (helpers.system == "aarch64-darwin") [ helpers.system "x86_64-darwin" ];
};
···
};
}
(helpers.darwinAttrs {
-
system.stateVersion = 5;
-
ids.gids.nixbld = 30000;
})
]
···
+
{ lib, pkgs, inputs, helpers, user, config, ... }:
with lib; mkMerge [
{
···
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
trusted-users = [ "root" "@wheel" ];
+
allowed-users = [ "root" "@wheel" "${user}" ];
+
extra-trusted-users = [ "${user}" ];
# on Apple Silicon, Rosetta 2 allows for this
extra-platforms = mkIf (helpers.system == "aarch64-darwin") [ helpers.system "x86_64-darwin" ];
};
···
};
}
(helpers.darwinAttrs {
+
system.stateVersion = 6;
})
]
+2 -2
modules/server/caddy.nix
···
-
{ lib, config, hostname, ... }:
with lib;
let
···
}
'') cfg.caddy.exposeFolders;
in strings.concatStringsSep "\n\n" configs;
-
in {
options.modules.server.caddy = {
enable = mkOption {
default = false;
···
+
{ lib, config, hostname, helpers, ... }:
with lib;
let
···
}
'') cfg.caddy.exposeFolders;
in strings.concatStringsSep "\n\n" configs;
+
in helpers.linuxAttrs {
options.modules.server.caddy = {
enable = mkOption {
default = false;
+1 -4
modules/server/default.nix
···
};
};
-
config.modules.server = {
-
enable = if helpers.isLinux then (mkDefault false) else (mkForce false);
-
};
-
} // helpers.linuxAttrs {
imports = [
./sshd.nix
./tailscale.nix
···
./jellyfin.nix
./home-assistant.nix
./podman.nix
];
}
···
};
};
imports = [
./sshd.nix
./tailscale.nix
···
./jellyfin.nix
./home-assistant.nix
./podman.nix
+
./macos.nix
];
}
+2 -2
modules/server/hd-idle.nix
···
-
{ lib, config, pkgs, ... }:
with lib;
let
cfgRoot = config.modules.server;
cfg = config.modules.server.hd-idle;
-
in {
options.modules.server.hd-idle = {
enable = mkOption {
default = false;
···
+
{ lib, config, pkgs, helpers, ... }:
with lib;
let
cfgRoot = config.modules.server;
cfg = config.modules.server.hd-idle;
+
in helpers.linuxAttrs {
options.modules.server.hd-idle = {
enable = mkOption {
default = false;
+2 -2
modules/server/home-assistant.nix
···
-
{ lib, config, pkgs, ... }:
with lib;
let
···
containerImage = if stdenv.isAarch64
then "ghcr.io/home-assistant/aarch64-homeassistant:${cfg.revision}"
else "ghcr.io/home-assistant/home-assistant:${cfg.revision}";
-
in {
options.modules.server.home-assistant = {
enable = mkOption {
default = false;
···
+
{ lib, config, pkgs, helpers, ... }:
with lib;
let
···
containerImage = if stdenv.isAarch64
then "ghcr.io/home-assistant/aarch64-homeassistant:${cfg.revision}"
else "ghcr.io/home-assistant/home-assistant:${cfg.revision}";
+
in helpers.linuxAttrs {
options.modules.server.home-assistant = {
enable = mkOption {
default = false;
+2 -2
modules/server/jellyfin.nix
···
-
{ lib, config, pkgs, user, ... }:
with lib;
let
···
cfg = config.modules.server.jellyfin;
group = "share";
-
in {
options.modules.server.jellyfin = {
enable = mkOption {
default = false;
···
+
{ lib, config, pkgs, user, helpers, ... }:
with lib;
let
···
cfg = config.modules.server.jellyfin;
group = "share";
+
in helpers.linuxAttrs {
options.modules.server.jellyfin = {
enable = mkOption {
default = false;
+35
modules/server/macos.nix
···
···
+
{ lib, config, user, helpers, ... }:
+
+
with lib;
+
let
+
cfg = config.modules.server;
+
in helpers.darwinAttrs {
+
options.modules.server = {
+
disableSleep = mkOption {
+
default = cfg.enable;
+
example = true;
+
description = "Whether to disable sleep";
+
type = types.bool;
+
};
+
};
+
+
config = mkIf cfg.disableSleep {
+
system.activationScripts.postActivation.text = ''
+
defaults write com.apple.screensaver idleTime 0
+
pmset -a powernap 0
+
pmset -a sms 0
+
pmset -a sleep 0
+
pmset -a hibernatemode 0
+
pmset -a disablesleep 1
+
'';
+
+
power = {
+
restartAfterFreeze = true;
+
restartAfterPowerFailure = true;
+
sleep = {
+
allowSleepByPowerButton = false;
+
computer = "never";
+
};
+
};
+
};
+
}
+2 -2
modules/server/podman.nix
···
-
{ lib, config, user, pkgs, ... }:
with lib;
let
cfgRoot = config.modules.server;
cfg = config.modules.server.podman;
-
in {
options.modules.server.podman = {
enable = mkOption {
default = false;
···
+
{ lib, config, user, pkgs, helpers, ... }:
with lib;
let
cfgRoot = config.modules.server;
cfg = config.modules.server.podman;
+
in helpers.linuxAttrs {
options.modules.server.podman = {
enable = mkOption {
default = false;
+2 -1
modules/server/sshd.nix
···
-
{ lib, config, user, ... }:
with lib;
let
···
services.openssh = {
enable = true;
openFirewall = mkDefault (!config.modules.router.enable);
};
};
···
+
{ lib, config, user, helpers, ... }:
with lib;
let
···
services.openssh = {
enable = true;
+
} // helpers.linuxAttrs {
openFirewall = mkDefault (!config.modules.router.enable);
};
};
+10 -3
modules/server/tailscale.nix
···
-
{ lib, config, pkgs, user, hostname, ... }:
with lib;
let
···
};
};
-
config = mkIf (cfg.enable && cfgRoot.enable) {
networking = {
domain = mkIf cfgRouter.enable "fable-pancake.ts.net";
search = [ "fable-pancake.ts.net" ];
···
systemd.services.tailscaled.serviceConfig.Environment = [ "TS_DEBUG_DISABLE_PORTLIST=true" ];
environment.systemPackages = mkIf config.modules.desktop.enable [ pkgs.tail-tray ];
-
};
}
···
+
{ lib, config, pkgs, user, helpers, hostname, ... }:
with lib;
let
···
};
};
+
config = mkIf (cfg.enable && cfgRoot.enable) (helpers.linuxAttrs {
networking = {
domain = mkIf cfgRouter.enable "fable-pancake.ts.net";
search = [ "fable-pancake.ts.net" ];
···
systemd.services.tailscaled.serviceConfig.Environment = [ "TS_DEBUG_DISABLE_PORTLIST=true" ];
environment.systemPackages = mkIf config.modules.desktop.enable [ pkgs.tail-tray ];
+
} // helpers.darwinAttrs {
+
networking.search = [ "fable-pancake.ts.net" ];
+
+
services.tailscale = {
+
enable = true;
+
overrideLocalDns = true;
+
};
+
});
}
+2 -2
modules/server/vaultwarden.nix
···
-
{ lib, config, hostname, ... }:
with lib;
let
address = config.modules.router.adress;
cfg = config.modules.server;
-
in {
options.modules.server.vaultwarden = {
enable = mkOption {
default = false;
···
+
{ lib, config, hostname, helpers, ... }:
with lib;
let
address = config.modules.router.adress;
cfg = config.modules.server;
+
in helpers.linuxAttrs {
options.modules.server.vaultwarden = {
enable = mkOption {
default = false;