Compare commits

...

10 commits

Author SHA1 Message Date
1ffbc5166c
Merge branch 'master' of https://github.com/nix-community/home-manager
Some checks failed
GitHub Pages / publish (ubuntu-latest) (push) Has been cancelled
2025-01-15 12:45:58 +01:00
1faf0d76a9
user activation 2025-01-15 12:45:49 +01:00
Linus Heckemann
fc52a210b6
network-manager-applet: changed nm-applet description (#6311)
This makes it a bit easier to find.
2025-01-13 17:27:56 +01:00
greenpsi
0da8b6bae9
sway: allow sway specific hideEdgeBorders options (#6304)
* add `smart_no_gaps` option
* allow using `--i3` for hideEdgeBorders:

See e.g. https://man.archlinux.org/man/sway.5#Config_or_runtime_commands:

The --i3 option enables i3-compatible behavior to hide the title bar on tabbed and stacked containers with one child.
Co-authored-by: greenpsi <git@psinet.dev>
2025-01-13 17:26:51 +01:00
Sebastián Zavala Villagómez
9616d81f98
mangohud: make false values actually disable (#6299)
Currently the following, will produce `some_opt=false` in the
rendered config:

```nix
programs.mangohud.settings = {
  some_opt = false;
};
```

With the intention being to disable the option, this would be
incorrect, as per the following stated at:
<0575c8eb1f/data/MangoHud.conf (L3C5-L4C1)>

> Use some_parameter=0 to disable a parameter (only works with on/off
> parameters)

As such, I changed the rendering to follow this.
This will be output instead: `some_opt=0`
2025-01-13 16:20:04 +01:00
Terje Larsen
2532b500c3
ollama: add module (#5735) 2025-01-10 12:31:03 +01:00
Kilian Mio
d4aebb947a
todoman: add todoman module (#5252)
* todoman: add todoman module

Adds Mikilio as maintainer for new module for todoman a standards-based
task manager based on iCalendar

Apply suggestions from code review

Co-authored-by: Robert Helgesson <robert@rycee.net>

Update modules/programs/todoman.nix

Co-authored-by: Robert Helgesson <robert@rycee.net>

* fix: correct config name

* chore: add test

---------

Co-authored-by: Robert Helgesson <robert@rycee.net>
2025-01-09 12:25:50 +01:00
Shay Eclipse K. Stage
01f40d52d6
zsh/prezto: add package option (#5938)
Allow setting a custom package for `programs.zsh.prezto`.
2025-01-09 12:04:34 +01:00
home-manager-bot
7e00856596
flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/6df24922a1400241dae323af55f30e4318a6ca65?narHash=sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk%3D' (2025-01-02)
  → 'github:NixOS/nixpkgs/8f3e1f807051e32d8c95cd12b9b421623850a34d?narHash=sha256-/qlNWm/IEVVH7GfgAIyP6EsVZI6zjAx1cV5zNyrs%2BrI%3D' (2025-01-04)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-01-08 21:01:05 +01:00
Hoang Nguyen
54b330ac06
go: add telemetry options 2025-01-08 09:39:32 -07:00
23 changed files with 451 additions and 65 deletions

6
flake.lock generated
View file

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1735834308,
"narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=",
"lastModified": 1736012469,
"narHash": "sha256-/qlNWm/IEVVH7GfgAIyP6EsVZI6zjAx1cV5zNyrs+rI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6df24922a1400241dae323af55f30e4318a6ca65",
"rev": "8f3e1f807051e32d8c95cd12b9b421623850a34d",
"type": "github"
},
"original": {

View file

@ -478,6 +478,12 @@
github = "mainrs";
githubId = 5113257;
};
mikilio = {
name = "mikilio";
email = "official.mikilio+dev@gmail.com";
github = "mikilio";
githubId = 86004375;
};
kmaasrud = {
name = "Knut Magnus Aasrud";
email = "km@aasrud.com";

View file

@ -246,6 +246,7 @@ let
./programs/tmate.nix
./programs/tmux.nix
./programs/tofi.nix
./programs/todoman.nix
./programs/topgrade.nix
./programs/translate-shell.nix
./programs/urxvt.nix
@ -345,6 +346,7 @@ let
./services/nextcloud-client.nix
./services/nix-gc.nix
./services/notify-osd.nix
./services/ollama.nix
./services/opensnitch-ui.nix
./services/osmscout-server.nix
./services/owncloud-client.nix

View file

@ -6,6 +6,8 @@ let
cfg = config.programs.go;
modeFileContent = "${cfg.telemetry.mode} ${cfg.telemetry.date}";
in {
meta.maintainers = [ maintainers.rvolosatovs ];
@ -71,6 +73,31 @@ in {
or checksum database.
'';
};
telemetry = mkOption {
type = types.submodule {
options = {
mode = mkOption {
type = with types; nullOr (enum [ "off" "local" "on" ]);
default = null;
description = "Go telemetry mode to be set.";
};
date = mkOption {
type = types.str;
default = "1970-01-01";
description = ''
The date indicating the date at which the modefile
was updated, in YYYY-MM-DD format. It's used to
reset the timeout before the next telemetry report
is uploaded when telemetry mode is set to "on".
'';
};
};
};
default = { };
description = "Options to configure Go telemetry mode.";
};
};
};
@ -98,5 +125,17 @@ in {
(mkIf (cfg.goPrivate != [ ]) {
home.sessionVariables.GOPRIVATE = concatStringsSep "," cfg.goPrivate;
})
(mkIf (cfg.telemetry.mode != null) {
home.file."Library/Application Support/go/telemetry/mode" = {
enable = pkgs.stdenv.hostPlatform.isDarwin;
text = modeFileContent;
};
xdg.configFile."go/telemetry/mode" = {
enable = !pkgs.stdenv.hostPlatform.isDarwin;
text = modeFileContent;
};
})
]);
}

View file

@ -13,7 +13,7 @@ let
int = toString option;
float = int;
path = int;
bool = "false";
bool = "0"; # "on/off" opts are disabled with `=0`
string = option;
list = concatStringsSep "," (lists.forEach option (x: toString x));
}.${builtins.typeOf option};

View file

@ -493,6 +493,23 @@ in {
for more information.
'';
};
configPath = mkOption {
type = types.path;
internal = true;
description = ''
Path to the ssh configuration.
'';
};
internallyManaged = mkOption {
type = types.bool;
default = true;
internal = true;
description = ''
Whether to link .ssh/config to programs.ssh.configPath
'';
};
};
config = mkIf cfg.enable {
@ -518,14 +535,14 @@ in {
home.packages = optional (cfg.package != null) cfg.package;
home.file.".ssh/config".text = let
home.file.".ssh/config".source = mkIf cfg.internallyManaged cfg.configPath;
programs.ssh.configPath = let
sortedMatchBlocks = hm.dag.topoSort cfg.matchBlocks;
sortedMatchBlocksStr = builtins.toJSON sortedMatchBlocks;
matchBlocks = if sortedMatchBlocks ? result then
sortedMatchBlocks.result
else
abort "Dependency cycle in SSH match blocks: ${sortedMatchBlocksStr}";
in ''
matchBlocks = sortedMatchBlocks.result or (abort
"Dependency cycle in SSH match blocks: ${sortedMatchBlocksStr}");
in pkgs.writeText "ssh_config" ''
${concatStringsSep "\n"
((mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)
++ (optional (cfg.includes != [ ]) ''

View file

@ -0,0 +1,62 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.todoman;
format = pkgs.formats.keyValue { };
in {
meta.maintainers = [ hm.maintainers.mikilio ];
options.programs.todoman = {
enable = lib.mkEnableOption "todoman";
glob = mkOption {
type = types.str;
default = "*";
description = ''
The glob expansion which matches all directories relevant.
'';
example = "*/*";
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Text for configuration of todoman.
The syntax is Python.
See [docs](`https://todoman.readthedocs.io/en/stable/man.html#id5`).
for the full list of options.
'';
example = ''
date_format = "%Y-%m-%d";
time_format = "%H:%M";
default_list = "Personal";
default_due = 48;
'';
};
};
config = mkIf cfg.enable {
assertions = [{
assertion = config.accounts.calendar ? basePath;
message = ''
A base directory for calendars must be specified via
`accounts.calendar.basePath` to generate config for todoman
'';
}];
home.packages = [ pkgs.todoman ];
xdg.configFile."todoman/config.py".text = lib.concatLines [
''path = "${config.accounts.calendar.basePath}/${cfg.glob}"''
cfg.extraConfig
];
};
}

View file

@ -671,7 +671,7 @@ in
''
${optionalString cfg.prezto.enable
(builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zshrc")}
(builtins.readFile "${cfg.prezto.package}/share/zsh-prezto/runcoms/zshrc")}
${concatStrings (map (plugin: ''
if [[ -f "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" ]]; then

View file

@ -14,6 +14,8 @@ let
options = {
enable = mkEnableOption "prezto";
package = mkPackageOption pkgs "prezto" { default = "zsh-prezto"; };
caseSensitive = mkOption {
type = types.nullOr types.bool;
# See <https://github.com/nix-community/home-manager/issues/2255>.
@ -379,15 +381,15 @@ in {
};
config = mkIf cfg.enable (mkMerge [{
home.file."${relToDotDir ".zprofile"}".text =
builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zprofile";
builtins.readFile "${cfg.package}/share/zsh-prezto/runcoms/zprofile";
home.file."${relToDotDir ".zlogin"}".text =
builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zlogin";
builtins.readFile "${cfg.package}/share/zsh-prezto/runcoms/zlogin";
home.file."${relToDotDir ".zlogout"}".text =
builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zlogout";
home.packages = with pkgs; [ zsh-prezto ];
builtins.readFile "${cfg.package}/share/zsh-prezto/runcoms/zlogout";
home.packages = [ cfg.package ];
home.file."${relToDotDir ".zshenv"}".text =
builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zshenv";
builtins.readFile "${cfg.package}/share/zsh-prezto/runcoms/zshenv";
home.file."${relToDotDir ".zpreztorc"}".text = ''
# Generated by Nix
${optionalString (cfg.caseSensitive != null) ''

View file

@ -11,7 +11,7 @@ in {
options = {
services.network-manager-applet = {
enable = mkEnableOption "the Network Manager applet";
enable = mkEnableOption "the Network Manager applet (nm-applet)";
};
};

View file

@ -0,0 +1,97 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.ollama;
ollamaPackage = if cfg.acceleration == null then
cfg.package
else
cfg.package.override { inherit (cfg) acceleration; };
in {
meta.maintainers = [ maintainers.terlar ];
options = {
services.ollama = {
enable = mkEnableOption "ollama server for local large language models";
package = mkPackageOption pkgs "ollama" { };
host = mkOption {
type = types.str;
default = "127.0.0.1";
example = "[::]";
description = ''
The host address which the ollama server HTTP interface listens to.
'';
};
port = mkOption {
type = types.port;
default = 11434;
example = 11111;
description = ''
Which port the ollama server listens to.
'';
};
acceleration = mkOption {
type = types.nullOr (types.enum [ false "rocm" "cuda" ]);
default = null;
example = "rocm";
description = ''
What interface to use for hardware acceleration.
- `null`: default behavior
- if `nixpkgs.config.rocmSupport` is enabled, uses `"rocm"`
- if `nixpkgs.config.cudaSupport` is enabled, uses `"cuda"`
- otherwise defaults to `false`
- `false`: disable GPU, only use CPU
- `"rocm"`: supported by most modern AMD GPUs
- may require overriding gpu type with `services.ollama.rocmOverrideGfx`
if rocm doesn't detect your AMD gpu
- `"cuda"`: supported by most modern NVIDIA GPUs
'';
};
environmentVariables = mkOption {
type = types.attrsOf types.str;
default = { };
example = {
OLLAMA_LLM_LIBRARY = "cpu";
HIP_VISIBLE_DEVICES = "0,1";
};
description = ''
Set arbitrary environment variables for the ollama service.
Be aware that these are only seen by the ollama server (systemd service),
not normal invocations like `ollama run`.
Since `ollama run` is mostly a shell around the ollama server, this is usually sufficient.
'';
};
};
};
config = mkIf cfg.enable {
systemd.user.services.ollama = {
Unit = {
Description = "Server for local large language models";
After = [ "network.target" ];
};
Service = {
ExecStart = "${getExe ollamaPackage} serve";
Environment =
(mapAttrsToList (n: v: "${n}=${v}") cfg.environmentVariables)
++ [ "OLLAMA_HOST=${cfg.host}:${toString cfg.port}" ];
};
Install = { WantedBy = [ "default.target" ]; };
};
home.packages = [ ollamaPackage ];
};
}

View file

@ -421,7 +421,13 @@ in {
};
hideEdgeBorders = mkOption {
type = types.enum [ "none" "vertical" "horizontal" "both" "smart" ];
type = let
i3Options = [ "none" "vertical" "horizontal" "both" "smart" ];
swayOptions = i3Options ++ [ "smart_no_gaps" ];
in if isI3 then
types.enum i3Options
else
types.enum (swayOptions ++ (map (e: "--i3 ${e}") swayOptions));
default = "none";
description = "Hide window borders adjacent to the screen edges.";
};

View file

@ -5,14 +5,28 @@ with lib;
let
cfg = config.home-manager;
serviceEnvironment = optionalAttrs (cfg.backupFileExtension != null) {
HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension;
} // optionalAttrs cfg.verbose { VERBOSE = "1"; };
baseService = username: {
Type = "oneshot";
RemainAfterExit = "yes";
TimeoutStartSec = "5m";
SyslogIdentifier = "hm-activate-${username}";
};
baseUnit = username: {
description = "Home Manager environment for ${username}";
stopIfChanged = false;
environment = optionalAttrs (cfg.backupFileExtension != null) {
HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension;
} // optionalAttrs cfg.verbose { VERBOSE = "1"; };
serviceConfig = baseService username;
};
# we use a service separated from nixos-activation
# to keep the logs separate
hmDropIn = "/share/systemd/user/home-manager.service.d";
in {
imports = [ ./common.nix ];
options.home-manager.useUserService = mkEnableOption
"activation on each user login instead of every user together on system boot";
config = mkMerge [
{
home-manager = {
@ -26,66 +40,115 @@ in {
# fontconfig by default.
fonts.fontconfig.enable = lib.mkDefault
(cfg.useUserPackages && config.fonts.fontconfig.enable);
# Inherit glibcLocales setting from NixOS.
i18n.glibcLocales = lib.mkDefault config.i18n.glibcLocales;
# .ssh/config needs to exists before login to let ssh login as that user
programs.ssh.internallyManaged =
lib.mkDefault (!cfg.useUserService);
};
}];
};
systemd.services = mapAttrs' (_:
{ home, programs, ... }:
let inherit (home) username homeDirectory;
in nameValuePair "ssh_config-${utils.escapeSystemdPath username}" {
enable = with programs.ssh; enable && !internallyManaged;
description = "Linking ${username}' ssh config";
wantedBy = [ "multi-user.target" ];
before = [ "systemd-user-sessions.service" ];
unitConfig.RequiresMountsFor = homeDirectory;
stopIfChanged = false;
serviceConfig = (baseService username) // {
User = username;
ExecStart = [
"${pkgs.coreutils}/bin/mkdir -p ${homeDirectory}/.ssh"
"${pkgs.coreutils}/bin/ln -s ${programs.ssh.configPath} ${homeDirectory}/.ssh/config"
];
};
}) cfg.users;
}
(mkIf (cfg.users != { }) {
(mkIf (cfg.users != { } && !cfg.useUserService) {
systemd.services = mapAttrs' (_: usercfg:
let username = usercfg.home.username;
in nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
description = "Home Manager environment for ${username}";
let inherit (usercfg.home) username homeDirectory activationPackage;
in nameValuePair "home-manager-${utils.escapeSystemdPath username}"
(attrsets.recursiveUpdate (baseUnit username) {
wantedBy = [ "multi-user.target" ];
wants = [ "nix-daemon.socket" ];
after = [ "nix-daemon.socket" ];
before = [ "systemd-user-sessions.service" ];
environment = serviceEnvironment;
unitConfig.RequiresMountsFor = homeDirectory;
unitConfig = { RequiresMountsFor = usercfg.home.homeDirectory; };
serviceConfig.User = username;
serviceConfig.ExecStart = let
systemctl =
"XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$UID} systemctl";
stopIfChanged = false;
sed = "${pkgs.gnused}/bin/sed";
exportedSystemdVariables = concatStringsSep "|" [
"DBUS_SESSION_BUS_ADDRESS"
"DISPLAY"
"WAYLAND_DISPLAY"
"XAUTHORITY"
"XDG_RUNTIME_DIR"
];
setupEnv = pkgs.writeScript "hm-setup-env" ''
#! ${pkgs.runtimeShell} -el
serviceConfig = {
User = usercfg.home.username;
Type = "oneshot";
TimeoutStartSec = "5m";
SyslogIdentifier = "hm-activate-${username}";
# The activation script is run by a login shell to make sure
# that the user is given a sane environment.
# If the user is logged in, import variables from their current
# session environment.
eval "$(
${systemctl} --user show-environment 2> /dev/null \
| ${sed} -En '/^(${exportedSystemdVariables})=/s/^/export /p'
)"
ExecStart = let
systemctl =
"XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$UID} systemctl";
exec "$1/activate"
'';
in "${setupEnv} ${activationPackage}";
})) cfg.users;
})
(mkIf (cfg.users != { } && cfg.useUserService) {
systemd.user.services.home-manager = (baseUnit "%u") // {
# user units cannot depend on system units
# TODO: Insert in the script logic for waiting on the nix socket via dbus
# like https://github.com/mogorman/systemd-lock-handler
# wants = [ "nix-daemon.socket" ];
# after = [ "nix-daemon.socket" ];
sed = "${pkgs.gnused}/bin/sed";
unitConfig.RequiresMountsFor = "%h";
# no ExecStart= is defined for any user that has not defined
# config.home-manager.users.${username}
# this will be overridden by the below drop-in
};
exportedSystemdVariables = concatStringsSep "|" [
"DBUS_SESSION_BUS_ADDRESS"
"DISPLAY"
"WAYLAND_DISPLAY"
"XAUTHORITY"
"XDG_RUNTIME_DIR"
];
setupEnv = pkgs.writeScript "hm-setup-env" ''
#! ${pkgs.runtimeShell} -el
# The activation script is run by a login shell to make sure
# that the user is given a sane environment.
# If the user is logged in, import variables from their current
# session environment.
eval "$(
${systemctl} --user show-environment 2> /dev/null \
| ${sed} -En '/^(${exportedSystemdVariables})=/s/^/export /p'
)"
exec "$1/activate"
'';
in "${setupEnv} ${usercfg.home.activationPackage}";
};
users.users = mapAttrs (_:
{ home, ... }: {
# unit files are taken from $XDG_DATA_DIRS too
# but are loaded after units from /etc
# we write a drop in so that it will take precedence
# over the above unit declaration
packages = [
(pkgs.writeTextDir "${hmDropIn}/10-user-activation.conf" ''
[Service]
ExecStart=${home.activationPackage}/activate
'')
];
}) cfg.users;
environment.pathsToLink = [ hmDropIn ];
# Without this will not reload home conf
# of logged user on system activation
# it will also start the unit on startup
system.userActivationScripts.home-manager = {
text = "${pkgs.systemd}/bin/systemctl --user restart home-manager";
deps = [ ];
};
})
];
}

View file

@ -83,6 +83,7 @@ in import nmtSrc {
./modules/programs/git
./modules/programs/git-cliff
./modules/programs/git-credential-oauth
./modules/programs/go
./modules/programs/gpg
./modules/programs/gradle
./modules/programs/granted
@ -269,6 +270,7 @@ in import nmtSrc {
./modules/services/mpd-mpris
./modules/services/mpdris2
./modules/services/nix-gc
./modules/services/ollama
./modules/services/osmscout-server
./modules/services/pantalaimon
./modules/services/parcellite

View file

@ -0,0 +1 @@
{ go-telemetry = ./go-telemetry.nix; }

View file

@ -0,0 +1,25 @@
{ pkgs, ... }:
{
programs.go = {
enable = true;
telemetry = {
mode = "on";
date = "2006-01-02";
};
};
test.stubs.go = { };
nm.script = let
modeFileDir = if !pkgs.stdenv.isDarwin then
".config/go/telemetry"
else
"Library/Application Support/go/telemetry";
in ''
assertFileExists "home-files/${modeFileDir}/mode"
assertFileContent \
"home-files/${modeFileDir}/mode" \
"on 2006-01-02"
'';
}

View file

@ -6,7 +6,7 @@ cpu_stats
cpu_temp
cpu_text=CPU
fps_limit=30,60
legacy_layout=false
legacy_layout=0
media_player_name=spotify
media_player_order=title,artist,album
output_folder=/home/user/Documents/mangohud

View file

@ -0,0 +1,21 @@
{
programs.todoman = {
enable = true;
glob = "*/*";
extraConfig = ''
date_format = "%d.%m.%Y"
default_list = "test"
'';
};
accounts.calendar.basePath = "base/path/calendar";
test.stubs = { todoman = { }; };
nmt.script = ''
configFile=home-files/.config/todoman/config.py
assertFileExists $configFile
assertFileContent $configFile ${./todoman-config-expected}
'';
}

View file

@ -0,0 +1 @@
{ todoman-config = ./config.nix; }

View file

@ -0,0 +1,3 @@
path = "/home/hm-user/base/path/calendar/*/*"
date_format = "%d.%m.%Y"
default_list = "test"

View file

@ -0,0 +1,13 @@
{
config = {
services.ollama.enable = true;
test.stubs.ollama = { };
nmt.script = ''
serviceFile="home-files/.config/systemd/user/ollama.service"
assertFileRegex "$serviceFile" 'After=network\.target'
assertFileRegex "$serviceFile" 'Environment=OLLAMA_HOST=127.0.0.1:11434'
'';
};
}

View file

@ -0,0 +1,4 @@
{
ollama-basic = ./basic.nix;
ollama-set-environment-variables = ./set-environment-variables.nix;
}

View file

@ -0,0 +1,22 @@
{
config = {
services.ollama = {
enable = true;
host = "localhost";
port = 11111;
environmentVariables = {
OLLAMA_LLM_LIBRARY = "cpu";
HIP_VISIBLE_DEVICES = "0,1";
};
};
test.stubs.ollama = { };
nmt.script = ''
serviceFile="home-files/.config/systemd/user/ollama.service"
assertFileRegex "$serviceFile" 'Environment=OLLAMA_HOST=localhost:11111'
assertFileRegex "$serviceFile" 'Environment=OLLAMA_LLM_LIBRARY=cpu'
assertFileRegex "$serviceFile" 'Environment=HIP_VISIBLE_DEVICES=0,1'
'';
};
}