| 8 May 2025 |
kdobieder | * Does anyone have an example of a Home Manager module shared via Flake? In the consuming flakes, I’d like it to be added directly to homeManagerModule.modules. The Home Manager module should be able to install packages from nixpkgs. | 10:51:05 |
dramforever |
The Home Manager module should be able to install packages from nixpkgs.
pkgs
| 10:54:50 |
dramforever | *
The Home Manager module should be able to install packages from nixpkgs.
use pkgs
| 10:54:55 |
kdobieder | Well I'd like to pass some things to the flake and this is what I came up with:
{
description = "Custom Flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
myvendor-scripts.url = "git+https://git.myvendor.de/linux/scripts";
};
outputs = { nixpkgs, nixpkgs-unstable, myvendor-scripts, ... }: let
getModule = {system, flakefolder}: let
homeManagerModule = import ./modules {
lib = nixpkgs.lib;
pkgs = nixpkgs.legacyPackages.${system};
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
flakefolder = flakefolder;
myvendor-scripts = myvendor-scripts;
};
in {
home-manager = homeManagerModule ;
};
in {
getModule = getModule;
};
}
But this way I have to define everything a would need - like lib, config, etc. Doesn't seem to be a good solution. Am I missing something?
| 10:57:18 |
kdobieder | * Well I'd like to pass some things to the flake and this is what I came up with:
{
description = "Custom Flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
myvendor-scripts.url = "git+https://git.myvendor.de/linux/scripts";
};
outputs = { nixpkgs, nixpkgs-unstable, myvendor-scripts, ... }: let
getModule = {system, flakefolder}: let
homeManagerModule = import ./modules {
lib = nixpkgs.lib;
pkgs = nixpkgs.legacyPackages.${system};
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
flakefolder = flakefolder;
myvendor-scripts = myvendor-scripts;
};
in {
home-manager = homeManagerModule ;
};
in {
getModule = getModule;
};
}
But this way I have to define everything a module would need - like lib, config, etc. Doesn't seem to be a good solution. Am I missing something?
| 10:58:08 |
dramforever | just don't pass it lib, config, etc | 11:27:18 |
dramforever | modules are supposed to be a function | 11:27:30 |
dramforever | ideally, module inputs can be set through options | 11:29:09 |
kdobieder | How would that be done? | 11:29:44 |
dramforever | https://nixos.org/manual/nixos/stable/#sec-writing-modules | 11:31:35 |
kdobieder | I don't see how that mentions passing options from a consuming flake to an imported home manager module. | 11:33:47 |
dramforever | there is no mention of that because that has nothing to do with flakes | 11:34:20 |
dramforever | when you have something like in a "consuming flake"
homeConfigurations.dram = home-manager.lib.homeManagerConfiguration {
...
modules = [
foo
bar
./home.nix
];
};
all three modules are on equal footing, they can each have options and config, and any one module can set the values of options defined in any module
| 11:36:12 |