Compare commits
10 commits
fcc4259cdb
...
1ffbc5166c
Author | SHA1 | Date | |
---|---|---|---|
1ffbc5166c | |||
1faf0d76a9 | |||
![]() |
fc52a210b6 | ||
![]() |
0da8b6bae9 | ||
![]() |
9616d81f98 | ||
![]() |
2532b500c3 | ||
![]() |
d4aebb947a | ||
![]() |
01f40d52d6 | ||
![]() |
7e00856596 | ||
![]() |
54b330ac06 |
23 changed files with 451 additions and 65 deletions
6
flake.lock
generated
6
flake.lock
generated
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735834308,
|
"lastModified": 1736012469,
|
||||||
"narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=",
|
"narHash": "sha256-/qlNWm/IEVVH7GfgAIyP6EsVZI6zjAx1cV5zNyrs+rI=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "6df24922a1400241dae323af55f30e4318a6ca65",
|
"rev": "8f3e1f807051e32d8c95cd12b9b421623850a34d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -478,6 +478,12 @@
|
||||||
github = "mainrs";
|
github = "mainrs";
|
||||||
githubId = 5113257;
|
githubId = 5113257;
|
||||||
};
|
};
|
||||||
|
mikilio = {
|
||||||
|
name = "mikilio";
|
||||||
|
email = "official.mikilio+dev@gmail.com";
|
||||||
|
github = "mikilio";
|
||||||
|
githubId = 86004375;
|
||||||
|
};
|
||||||
kmaasrud = {
|
kmaasrud = {
|
||||||
name = "Knut Magnus Aasrud";
|
name = "Knut Magnus Aasrud";
|
||||||
email = "km@aasrud.com";
|
email = "km@aasrud.com";
|
||||||
|
|
|
@ -246,6 +246,7 @@ let
|
||||||
./programs/tmate.nix
|
./programs/tmate.nix
|
||||||
./programs/tmux.nix
|
./programs/tmux.nix
|
||||||
./programs/tofi.nix
|
./programs/tofi.nix
|
||||||
|
./programs/todoman.nix
|
||||||
./programs/topgrade.nix
|
./programs/topgrade.nix
|
||||||
./programs/translate-shell.nix
|
./programs/translate-shell.nix
|
||||||
./programs/urxvt.nix
|
./programs/urxvt.nix
|
||||||
|
@ -345,6 +346,7 @@ let
|
||||||
./services/nextcloud-client.nix
|
./services/nextcloud-client.nix
|
||||||
./services/nix-gc.nix
|
./services/nix-gc.nix
|
||||||
./services/notify-osd.nix
|
./services/notify-osd.nix
|
||||||
|
./services/ollama.nix
|
||||||
./services/opensnitch-ui.nix
|
./services/opensnitch-ui.nix
|
||||||
./services/osmscout-server.nix
|
./services/osmscout-server.nix
|
||||||
./services/owncloud-client.nix
|
./services/owncloud-client.nix
|
||||||
|
|
|
@ -6,6 +6,8 @@ let
|
||||||
|
|
||||||
cfg = config.programs.go;
|
cfg = config.programs.go;
|
||||||
|
|
||||||
|
modeFileContent = "${cfg.telemetry.mode} ${cfg.telemetry.date}";
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ maintainers.rvolosatovs ];
|
meta.maintainers = [ maintainers.rvolosatovs ];
|
||||||
|
|
||||||
|
@ -71,6 +73,31 @@ in {
|
||||||
or checksum database.
|
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 != [ ]) {
|
(mkIf (cfg.goPrivate != [ ]) {
|
||||||
home.sessionVariables.GOPRIVATE = concatStringsSep "," 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;
|
||||||
|
};
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ let
|
||||||
int = toString option;
|
int = toString option;
|
||||||
float = int;
|
float = int;
|
||||||
path = int;
|
path = int;
|
||||||
bool = "false";
|
bool = "0"; # "on/off" opts are disabled with `=0`
|
||||||
string = option;
|
string = option;
|
||||||
list = concatStringsSep "," (lists.forEach option (x: toString x));
|
list = concatStringsSep "," (lists.forEach option (x: toString x));
|
||||||
}.${builtins.typeOf option};
|
}.${builtins.typeOf option};
|
||||||
|
|
|
@ -493,6 +493,23 @@ in {
|
||||||
for more information.
|
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 {
|
config = mkIf cfg.enable {
|
||||||
|
@ -518,14 +535,14 @@ in {
|
||||||
|
|
||||||
home.packages = optional (cfg.package != null) cfg.package;
|
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;
|
sortedMatchBlocks = hm.dag.topoSort cfg.matchBlocks;
|
||||||
sortedMatchBlocksStr = builtins.toJSON sortedMatchBlocks;
|
sortedMatchBlocksStr = builtins.toJSON sortedMatchBlocks;
|
||||||
matchBlocks = if sortedMatchBlocks ? result then
|
matchBlocks = sortedMatchBlocks.result or (abort
|
||||||
sortedMatchBlocks.result
|
"Dependency cycle in SSH match blocks: ${sortedMatchBlocksStr}");
|
||||||
else
|
in pkgs.writeText "ssh_config" ''
|
||||||
abort "Dependency cycle in SSH match blocks: ${sortedMatchBlocksStr}";
|
|
||||||
in ''
|
|
||||||
${concatStringsSep "\n"
|
${concatStringsSep "\n"
|
||||||
((mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)
|
((mapAttrsToList (n: v: "${n} ${v}") cfg.extraOptionOverrides)
|
||||||
++ (optional (cfg.includes != [ ]) ''
|
++ (optional (cfg.includes != [ ]) ''
|
||||||
|
|
62
modules/programs/todoman.nix
Normal file
62
modules/programs/todoman.nix
Normal 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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
|
@ -671,7 +671,7 @@ in
|
||||||
|
|
||||||
''
|
''
|
||||||
${optionalString cfg.prezto.enable
|
${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: ''
|
${concatStrings (map (plugin: ''
|
||||||
if [[ -f "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" ]]; then
|
if [[ -f "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" ]]; then
|
||||||
|
|
|
@ -14,6 +14,8 @@ let
|
||||||
options = {
|
options = {
|
||||||
enable = mkEnableOption "prezto";
|
enable = mkEnableOption "prezto";
|
||||||
|
|
||||||
|
package = mkPackageOption pkgs "prezto" { default = "zsh-prezto"; };
|
||||||
|
|
||||||
caseSensitive = mkOption {
|
caseSensitive = mkOption {
|
||||||
type = types.nullOr types.bool;
|
type = types.nullOr types.bool;
|
||||||
# See <https://github.com/nix-community/home-manager/issues/2255>.
|
# See <https://github.com/nix-community/home-manager/issues/2255>.
|
||||||
|
@ -379,15 +381,15 @@ in {
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable (mkMerge [{
|
config = mkIf cfg.enable (mkMerge [{
|
||||||
home.file."${relToDotDir ".zprofile"}".text =
|
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 =
|
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 =
|
home.file."${relToDotDir ".zlogout"}".text =
|
||||||
builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zlogout";
|
builtins.readFile "${cfg.package}/share/zsh-prezto/runcoms/zlogout";
|
||||||
home.packages = with pkgs; [ zsh-prezto ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
home.file."${relToDotDir ".zshenv"}".text =
|
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 = ''
|
home.file."${relToDotDir ".zpreztorc"}".text = ''
|
||||||
# Generated by Nix
|
# Generated by Nix
|
||||||
${optionalString (cfg.caseSensitive != null) ''
|
${optionalString (cfg.caseSensitive != null) ''
|
||||||
|
|
|
@ -11,7 +11,7 @@ in {
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
services.network-manager-applet = {
|
services.network-manager-applet = {
|
||||||
enable = mkEnableOption "the Network Manager applet";
|
enable = mkEnableOption "the Network Manager applet (nm-applet)";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
97
modules/services/ollama.nix
Normal file
97
modules/services/ollama.nix
Normal 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 ];
|
||||||
|
};
|
||||||
|
}
|
|
@ -421,7 +421,13 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
hideEdgeBorders = mkOption {
|
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";
|
default = "none";
|
||||||
description = "Hide window borders adjacent to the screen edges.";
|
description = "Hide window borders adjacent to the screen edges.";
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,14 +5,28 @@ with lib;
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.home-manager;
|
cfg = config.home-manager;
|
||||||
|
baseService = username: {
|
||||||
serviceEnvironment = optionalAttrs (cfg.backupFileExtension != null) {
|
Type = "oneshot";
|
||||||
HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension;
|
RemainAfterExit = "yes";
|
||||||
} // optionalAttrs cfg.verbose { VERBOSE = "1"; };
|
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 {
|
in {
|
||||||
imports = [ ./common.nix ];
|
imports = [ ./common.nix ];
|
||||||
|
options.home-manager.useUserService = mkEnableOption
|
||||||
|
"activation on each user login instead of every user together on system boot";
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
{
|
{
|
||||||
home-manager = {
|
home-manager = {
|
||||||
|
@ -26,66 +40,115 @@ in {
|
||||||
# fontconfig by default.
|
# fontconfig by default.
|
||||||
fonts.fontconfig.enable = lib.mkDefault
|
fonts.fontconfig.enable = lib.mkDefault
|
||||||
(cfg.useUserPackages && config.fonts.fontconfig.enable);
|
(cfg.useUserPackages && config.fonts.fontconfig.enable);
|
||||||
|
|
||||||
# Inherit glibcLocales setting from NixOS.
|
# Inherit glibcLocales setting from NixOS.
|
||||||
i18n.glibcLocales = lib.mkDefault config.i18n.glibcLocales;
|
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:
|
systemd.services = mapAttrs' (_: usercfg:
|
||||||
let username = usercfg.home.username;
|
let inherit (usercfg.home) username homeDirectory activationPackage;
|
||||||
in nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
|
in nameValuePair "home-manager-${utils.escapeSystemdPath username}"
|
||||||
description = "Home Manager environment for ${username}";
|
(attrsets.recursiveUpdate (baseUnit username) {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
wants = [ "nix-daemon.socket" ];
|
wants = [ "nix-daemon.socket" ];
|
||||||
after = [ "nix-daemon.socket" ];
|
after = [ "nix-daemon.socket" ];
|
||||||
before = [ "systemd-user-sessions.service" ];
|
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 = {
|
# The activation script is run by a login shell to make sure
|
||||||
User = usercfg.home.username;
|
# that the user is given a sane environment.
|
||||||
Type = "oneshot";
|
# If the user is logged in, import variables from their current
|
||||||
TimeoutStartSec = "5m";
|
# session environment.
|
||||||
SyslogIdentifier = "hm-activate-${username}";
|
eval "$(
|
||||||
|
${systemctl} --user show-environment 2> /dev/null \
|
||||||
|
| ${sed} -En '/^(${exportedSystemdVariables})=/s/^/export /p'
|
||||||
|
)"
|
||||||
|
|
||||||
ExecStart = let
|
exec "$1/activate"
|
||||||
systemctl =
|
'';
|
||||||
"XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$UID} systemctl";
|
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 "|" [
|
users.users = mapAttrs (_:
|
||||||
"DBUS_SESSION_BUS_ADDRESS"
|
{ home, ... }: {
|
||||||
"DISPLAY"
|
# unit files are taken from $XDG_DATA_DIRS too
|
||||||
"WAYLAND_DISPLAY"
|
# but are loaded after units from /etc
|
||||||
"XAUTHORITY"
|
# we write a drop in so that it will take precedence
|
||||||
"XDG_RUNTIME_DIR"
|
# over the above unit declaration
|
||||||
];
|
packages = [
|
||||||
|
(pkgs.writeTextDir "${hmDropIn}/10-user-activation.conf" ''
|
||||||
setupEnv = pkgs.writeScript "hm-setup-env" ''
|
[Service]
|
||||||
#! ${pkgs.runtimeShell} -el
|
ExecStart=${home.activationPackage}/activate
|
||||||
|
'')
|
||||||
# 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}";
|
|
||||||
};
|
|
||||||
}) cfg.users;
|
}) 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 = [ ];
|
||||||
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ in import nmtSrc {
|
||||||
./modules/programs/git
|
./modules/programs/git
|
||||||
./modules/programs/git-cliff
|
./modules/programs/git-cliff
|
||||||
./modules/programs/git-credential-oauth
|
./modules/programs/git-credential-oauth
|
||||||
|
./modules/programs/go
|
||||||
./modules/programs/gpg
|
./modules/programs/gpg
|
||||||
./modules/programs/gradle
|
./modules/programs/gradle
|
||||||
./modules/programs/granted
|
./modules/programs/granted
|
||||||
|
@ -269,6 +270,7 @@ in import nmtSrc {
|
||||||
./modules/services/mpd-mpris
|
./modules/services/mpd-mpris
|
||||||
./modules/services/mpdris2
|
./modules/services/mpdris2
|
||||||
./modules/services/nix-gc
|
./modules/services/nix-gc
|
||||||
|
./modules/services/ollama
|
||||||
./modules/services/osmscout-server
|
./modules/services/osmscout-server
|
||||||
./modules/services/pantalaimon
|
./modules/services/pantalaimon
|
||||||
./modules/services/parcellite
|
./modules/services/parcellite
|
||||||
|
|
1
tests/modules/programs/go/default.nix
Normal file
1
tests/modules/programs/go/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ go-telemetry = ./go-telemetry.nix; }
|
25
tests/modules/programs/go/go-telemetry.nix
Normal file
25
tests/modules/programs/go/go-telemetry.nix
Normal 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"
|
||||||
|
'';
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ cpu_stats
|
||||||
cpu_temp
|
cpu_temp
|
||||||
cpu_text=CPU
|
cpu_text=CPU
|
||||||
fps_limit=30,60
|
fps_limit=30,60
|
||||||
legacy_layout=false
|
legacy_layout=0
|
||||||
media_player_name=spotify
|
media_player_name=spotify
|
||||||
media_player_order=title,artist,album
|
media_player_order=title,artist,album
|
||||||
output_folder=/home/user/Documents/mangohud
|
output_folder=/home/user/Documents/mangohud
|
||||||
|
|
21
tests/modules/programs/todoman/config.nix
Normal file
21
tests/modules/programs/todoman/config.nix
Normal 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}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
1
tests/modules/programs/todoman/default.nix
Normal file
1
tests/modules/programs/todoman/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ todoman-config = ./config.nix; }
|
3
tests/modules/programs/todoman/todoman-config-expected
Normal file
3
tests/modules/programs/todoman/todoman-config-expected
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
path = "/home/hm-user/base/path/calendar/*/*"
|
||||||
|
date_format = "%d.%m.%Y"
|
||||||
|
default_list = "test"
|
13
tests/modules/services/ollama/basic.nix
Normal file
13
tests/modules/services/ollama/basic.nix
Normal 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'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
4
tests/modules/services/ollama/default.nix
Normal file
4
tests/modules/services/ollama/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
ollama-basic = ./basic.nix;
|
||||||
|
ollama-set-environment-variables = ./set-environment-variables.nix;
|
||||||
|
}
|
22
tests/modules/services/ollama/set-environment-variables.nix
Normal file
22
tests/modules/services/ollama/set-environment-variables.nix
Normal 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'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue