2 Jul 2025 |
| Markus Theil joined the room. | 13:30:44 |
4 Jul 2025 |
| Majiir Paktu joined the room. | 21:28:45 |
7 Jul 2025 |
| nbp changed their display name from nbp — PTO to nbp. | 13:12:04 |
8 Jul 2025 |
| Martin Gaens joined the room. | 09:11:18 |
Martin Gaens | Hey guys, I am trying to modularize my system, but there's one thing that I can't grasp. When you see everyone using Nix modules to split their configs, they almost always have their home manager configuration separate from their system configuration. I mean, it makes sense 95% of time, however, for some programs, like for example Hyprland, if you want to use Home Manager to manage Hyprland, you need the system module enabled as well. Basically everyone I've seen simply has a hyprland.nix config file both in the home-manager config as well as the system config. However, this means they're decoupled. If I am choosing which modules to enable inside my host, I have to think about enabling both my user hyprland module as well as my system hyprland module (which are in different parts of my dotfiles, since one of them is inside the home-manager configuration directory and the other one is inside the system configuration directory). How do I properly manage this sort of thing? | 09:17:03 |
nbp | Martin Gaens: I have a home-manager config which is either managed on its own or within NixOS, which I use across 2 different computer. I am using the extraSpecialArgs in flake.nix or home-manager.users.nicolas._module.args when embedded in a NixOS configuration, to set some configuration managed externally.
Note, there is nothing about special args, I might have as well set an option by adding an extra module in homeManager 's flake.nix and done the same within the configuration embedded in NixOS.
| 09:25:23 |
Martin Gaens | Thanks for your reply. I am quite new to this; I'm not sure I understand. Do you mean you have some externally-managed configuration, which you pass both to your home-manager config as well as to your system config, and then, make decisions in those configs based on the global configuration? | 09:43:25 |
nbp | I can either use my home manager as a standalone entry in my flake.nix :
homeConfigurations.nicolas = home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = inputs // {
inNixOS = false;
};
pkgs = import nixpkgs-unstable {
system = "x86_64-linux";
overlays = [ self.overlays.openpnp ];
};
modules = [ ./users/nicolas/home.nix ];
};
Or as a module to import in my NixOS configuration:
{ home-manager, ...}@inputs:
{
imports = [
home-manager.nixosModules.home-manager
];
home-manager = {
users.nicolas.imports = [ ./home.nix ];
users.nicolas._module.args = {
inNixOS = true;
} // inputs;
};
}
The inNixOS argument is nothing special, this is just an extra attribute I give as argument to the home-manager modules to tune it differently.
| 09:54:33 |
nbp | * I can either use my home manager as a standalone entry in my flake.nix :
homeConfigurations.nicolas = home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = inputs // {
inNixOS = false;
};
pkgs = import nixpkgs-unstable { system = "x86_64-linux"; };
modules = [ ./users/nicolas/home.nix ];
};
Or as a module to import in my NixOS configuration:
{ home-manager, ...}@inputs:
{
imports = [
home-manager.nixosModules.home-manager
];
home-manager = {
users.nicolas.imports = [ ./home.nix ];
users.nicolas._module.args = {
inNixOS = true;
} // inputs;
};
}
The inNixOS argument is nothing special, this is just an extra attribute I give as argument to the home-manager modules to tune it differently.
| 09:55:32 |
nbp | * I can either use my home manager as a standalone entry in my flake.nix :
homeConfigurations.nicolas = home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = inputs // {
inNixOS = false;
};
pkgs = import nixpkgs-unstable { system = "x86_64-linux"; };
modules = [ ./users/nicolas/home.nix ];
};
Or as a module to import in my NixOS configuration:
{ home-manager, ...}@inputs:
{
imports = [
home-manager.nixosModules.home-manager
];
home-manager = {
users.nicolas.imports = [ ./home.nix ];
users.nicolas._module.args = {
inNixOS = true;
inherit (inputs) awesome-copycats; // list other inputs forwarded from NixOS to home-manager
};
};
}
The inNixOS argument is nothing special, this is just an extra attribute I give as argument to the home-manager modules to tune it differently.
| 09:56:35 |
nbp | * I can either use my home manager as a standalone entry in my flake.nix :
homeConfigurations.nicolas = home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = inputs // {
inNixOS = false;
};
pkgs = import nixpkgs-unstable { system = "x86_64-linux"; };
modules = [ ./users/nicolas/home.nix ];
};
Or as a module to import in my NixOS configuration:
{ home-manager, ...}@inputs:
{
imports = [
home-manager.nixosModules.home-manager
];
home-manager = {
users.nicolas.imports = [ ./home.nix ];
users.nicolas._module.args = {
inNixOS = true;
inherit (inputs) awesome-copycats; # list other inputs forwarded from NixOS to home-manager
};
};
}
The inNixOS argument is nothing special, this is just an extra attribute I give as argument to the home-manager modules to tune it differently.
| 09:56:50 |
nbp | * I can either use my home manager as a standalone entry in my flake.nix :
homeConfigurations.nicolas = home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = inputs // {
inNixOS = false;
};
pkgs = import nixpkgs-unstable { system = "x86_64-linux"; };
modules = [ ./home.nix ];
};
Or as a module to import in my NixOS configuration:
{ home-manager, ...}@inputs:
{
imports = [
home-manager.nixosModules.home-manager
];
home-manager = {
users.nicolas.imports = [ ./home.nix ];
users.nicolas._module.args = {
inNixOS = true;
inherit (inputs) awesome-copycats; # list other inputs forwarded from NixOS to home-manager
};
};
}
The inNixOS argument is nothing special, this is just an extra attribute I give as argument to the home-manager modules to tune it differently.
| 09:57:26 |
9 Jul 2025 |
| atagen joined the room. | 07:41:54 |
14 Jul 2025 |
| @mightyiam:matrix.org joined the room. | 10:05:13 |
| n4ch723hr3r joined the room. | 14:00:31 |
18 Jul 2025 |
| Sandro 🐧 joined the room. | 12:28:34 |
20 Jul 2025 |
| x10an14 joined the room. | 14:14:08 |
x10an14 | I already asked in https://matrix.to/#/!6oudZq5zJjAyrxL2uY:0upti.me/$7AxNR83n3qUrjad6j0KXIDLtaUKnZIxy-sP_liLL04A, but this might be a better place:
I have written 1x module, and I want to make use of it (read: extend it) in another .nix file.
The module I have written looks like this:
{ lib, ... }:
{
options.flake.modules.foo = lib.mkOption {
type =
with lib.types;
attrsOf (
submodule (
{ name, ... }:
{
options = {
username = lib.mkOption {
type = str;
default = lib.splitString "@" name |> lib.flip builtins.elemAt 0;
};
hostname = lib.mkOption {
type = str;
default = lib.splitString "@" name |> lib.flip builtins.elemAt 1;
};
system = lib.mkOption {
type = enum [
"x86_64-linux"
];
};
};
}
)
);
};
config.flake.modules.foo."username@hostname".system = "x86_64-linux";
}
Now I want to extend foo like this:
{
lib,
repoRoot,
...
}@toplevel:
let
fooConfs = toplevel.config.flake.modules.foo;
in
{
options.flake.modules.foo.<fooInstance>.home-manager = lib.mkOption {
type =
with lib.types;
attrsOf (
submodule (
{
name,
config,
...
}:
let
username = config.username;
hostname = config.hostname;
system = config.system;
in
{
entryPoint = lib.mkOption {
type = lib.types.path;
default = "${repoRoot}/home-manager/${username}@${hostname}";
};
homeDirectory = lib.mkOption {
type = lib.types.path;
default =
if lib.strings.hasSuffix "-darwin" system then "/Users/${username}" else "/home/${username}";
};
toplevelBuild = lib.mkOption {
type = lib.types.raw;
readOnly = true;
};
}
)
);
};
config.flake.modules.foo.<fooInstance>.home-manager = fooConfs;
}
I have obviously grossly misunderstood something, so anyone here got any suggestions on how to proceed?
BTW: I'm not even sure I want homeManager to be nested under flake.modules.foo , I'd be happier if it was alongside like so flake.modules.homeManager.<instance of home-manager generated from instance of foo>
| 14:15:34 |
n4ch723hr3r | i think you have to overwrite the type if that is possible | 14:17:24 |
x10an14 | In reply to @n4ch723hr3r:nope.chat i think you have to overwrite the type if that is possible Is your answer independent of the BTW? | 14:18:31 |
n4ch723hr3r | from what i understand about the module system everything inside attrsOf is a subtype so you have to find a way to put something new into that type | 14:19:38 |
x10an14 | In reply to @n4ch723hr3r:nope.chat from what i understand about the module system everything inside attrsOf is a subtype so you have to find a way to put something new into that type So if my BTW wish is taken into account, the point you're making loses relevance, right? | 14:21:04 |
x10an14 | In reply to @n4ch723hr3r:nope.chat from what i understand about the module system everything inside attrsOf is a subtype so you have to find a way to put something new into that type I think you're correct about this though | 14:21:33 |
n4ch723hr3r | i was thinking about a general sense. like if you wanted to extend users.users for example. | 14:23:14 |
n4ch723hr3r | im not sure about if this is even possible since youd have to overwrite or wrap the binOp functor in .type.functor | 14:23:57 |
n4ch723hr3r | you can also explore via nix repl ;) | 14:24:13 |
n4ch723hr3r | apparently you can 🤔 | 14:27:06 |
n4ch723hr3r | users.users = lib.mkOption {
type = with lib.types; attrsOf (submodule userOptions);
};
found this in the openssh module
| 14:27:27 |
n4ch723hr3r | thats why if you search for "users.users" on search.nixos.org there are sometimes openssh and sometimes users-groups.nix given as a source | 14:28:46 |
n4ch723hr3r | x10an14 so maybe try extending it like openssh does for users.users and see what happens xD | 14:29:58 |