8 May 2025 |
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 |
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 module can set the values of options defined in any module
| 11:36:25 |
dramforever | do note that you can't have the value of an option affect the definition of options themselves (so, in short, no using config in imports or options ) | 11:37:20 |
kdobieder | Okay, I see. The problem I have is that I want to pass a custom variable to bar for example. | 11:37:33 |
dramforever | that would be a cyclic dependency | 11:37:35 |
dramforever | what is the argument used for? | 11:38:32 |
kdobieder | That would be the folder of the consuming flake, because the imported home manager module should provide a nix-rebuild command which does home-manager switch --flake ${flakefolder}#main . flakefolder is the variable I want to pass downstream. | 11:40:11 |
kdobieder | * That would be the folder of the consuming flake, because the imported home manager module should provide a nix-rebuild command which does home-manager switch --flake ${flakefolder}#main (and other corporate stuff). flakefolder is the variable I want to pass downstream. | 11:40:38 |
dramforever | you would have something like
{ config, lib, ... }:
{
options = {
my-scripts.flakefolder = lib.mkOption {
type = with lib.types; types.str;
description = "The flake folder for my-scripts";
};
};
config = {
home.packages = [
(something config.my-scripts.flakefolder)
];
};
}
| 11:45:12 |
dramforever | (note: untested) | 11:45:29 |
dramforever | and then in your regular module you would set
my-scripts.flakefolder = "git+file:///home/whatever/you-get-the-idea";
| 11:45:49 |
dramforever | this way the module works just like any other option you already have in home-manager | 11:48:58 |
kdobieder | Ah I see, thank you. | 11:51:22 |
| FPS DEV GUY (izdihar) joined the room. | 12:00:10 |
kdobieder | So that would result in something like this?
outputs = { nixpkgs, nixpkgs-unstable, myvendor-scripts, ... }: let
getModule = {system}: let
homeManagerModule = import ./modules {
inherit myvendor-scripts;
pkgs = nixpkgs.legacyPackages.${system};
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
};
in {
home-manager = homeManagerModule ;
};
in {
getModule = getModule;
};
config and lib can't be used in submodules then.
| 12:39:13 |
9 May 2025 |
| Fionna joined the room. | 03:23:08 |
10 May 2025 |
| Edward Hesketh joined the room. | 19:44:36 |
| @strutztm:strutztm.de left the room. | 19:53:11 |
| Edward Hesketh changed their display name from headb to Edward Hesketh. | 23:32:18 |
12 May 2025 |
nim65s | I have a bunch of eg.
inputs.patch-arsenik = {
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/386205.patch";
flake = false;
};
in the flake for my systems, applied with patchedNixpkgs = inputs.nixpkgs.legacyPackages.x86_64-linux.applyPatches { src = inputs.nixpkgs; patches = [ inputs.patch-arsenik ]; }; , for some of my PRs I want in my pkgs but are not merged. This allow to have up-to-date patches with low effort.
But recently, github rate limits have been hitting me on like 100% of my nix flake update . Anybody has a workaround ?
| 16:35:42 |
nim65s | If I could set an access token on githubusercontent, it would work (eg. as in curl "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/386205.patch?access_token=$GITHUB_TOKEN" ), but I have no idea how to configure that without exposing the token directly in my flake.nix, which is a public file | 16:39:36 |
nim65s | * I have a bunch of eg.
inputs.patch-arsenik = {
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/386205.patch";
flake = false;
};
in the flake for my systems, applied with patchedNixpkgs = inputs.nixpkgs.legacyPackages.x86_64-linux.applyPatches { src = inputs.nixpkgs; patches = [ inputs.patch-arsenik ]; }; , for some PRs I want in my pkgs but are not merged. This allow to have up-to-date patches with low effort.
But recently, github rate limits have been hitting me on like 100% of my nix flake update . Anybody has a workaround ?
| 16:41:03 |