15 Feb 2025 |
| BenjB83 joined the room. | 10:17:49 |
| BenjB83 changed their display name from BenjamĂn Buske to BenjB83. | 10:43:33 |
21 Feb 2025 |
| clay53 joined the room. | 01:12:47 |
15 Mar 2025 |
| galactic_starfish joined the room. | 03:02:32 |
25 Apr 2025 |
| Marek RychlĂ˝ joined the room. | 08:58:08 |
28 Apr 2025 |
| nicoty joined the room. | 18:54:23 |
9 Jun 2025 |
| SigmaSquadron joined the room. | 13:14:45 |
11 Jun 2025 |
| Zhenxing He joined the room. | 09:41:35 |
Zhenxing He | Hi, How can I extend flakelight to support a new way of configuring nixos system. For example, I want to add a new directory hosts under nix directory, and also adding some new attributes not current supported. I think I need to add some new options for the host configuration and functions to convert the host configuation to nixos configuration supported by flakelight, but I don't have a clue how to do this. Any help would be greatly appreciated! | 09:49:20 |
Zhenxing He | Also thank you for the great work, I'm new to nix, flakelight is the best flake module library I found. | 09:52:52 |
accelbread | Hi, that should totally be possible. I'll put together a quick example | 15:18:23 |
accelbread | In your flake.nix you can import a module that adds your options (can also just directly add but a module is probably cleaner):
{
inputs.flakelight.url = "github:nix-community/flakelight";
outputs = { flakelight, ... }:
flakelight ./. {
imports = [ ./nix/flakelightModules/my_module.nix ];
};
}
Then in your module file, you can add options and config using them (same as for nixos or home-manager modules but setting the flakelight options):
{ config, lib, src, flakelight, ... }:
let
inherit (lib.types) lazyAttrsOf any;
in
{
options = {
hosts = mkOption {
type = lazyAttrsOf any;
default = {};
};
};
config = {
nixosConfigurations = fnThatConvertsHostsToNixosConf config.hosts;
};
}
| 17:24:56 |
accelbread | this adds a hosts option to flakelight. The loading from ./nix/hosts will work automatically. | 17:25:54 |
accelbread | * this adds a hosts option to flakelight. The loading from ./nix/hosts/ will work automatically. | 17:26:03 |
accelbread | Theres some docs on using the Nix module system here: https://nixos.org/manual/nixos/stable/#sec-writing-modules
Also looks like some docs here: https://nix.dev/tutorials/module-system/index.html | 17:29:15 |
accelbread | Feel free to ask more questions, and I can help with more specifics | 17:31:13 |
Zhenxing He | Thank you for the quick response, it works like a charm! I had thought I might need to use the extend or extraModules of mkFlake, what are those for and how to use them? | 23:39:38 |
12 Jun 2025 |
accelbread | Those are intended for making flakes providing project integration with flakelight, i.e. stuff like https://github.com/accelbread/flakelight-rust or https://github.com/accelbread/flakelight-zig | 01:46:15 |
accelbread | Its used here: https://github.com/nix-community/flakelight/blob/master/nix/flakelightModules/flakelightModule.nix | 01:46:36 |
accelbread | Those other repos use this module so that instead of calling flakelight ./. { imports = [ flakelight-zig.flakelightModules.default ], ... } in the consuming flakes, you can instead call flakelight-zig ./. { ... } | 01:48:21 |
accelbread | extend takes mkFlake and returns a version that automatically includes some modules | 01:49:13 |
accelbread | * extend takes mkFlake and returns a mkFlake function that automatically includes some modules | 01:49:32 |
accelbread | extraModules is part of implementation of extend | 01:50:46 |
accelbread | So not really something consumers of flakelight really need to touch | 01:51:46 |
accelbread | I should probably add to the comment where those are defined | 01:52:23 |
Zhenxing He | That's a lot of information, thanks a lot, it looks very cool, I actually have tried writing github:hezhenxing/flakelight-haskell, but I do not fully understand it when I wrote it. Just copy the others. | 01:57:15 |
accelbread | oh cool! Yeah, copying from others should be fine for that. If you get the haskell project building
=working, feel free to add it to the flakelight readme as an available module | 01:58:59 |
accelbread | * oh cool! Yeah, copying from others should be fine for that. If you get the haskell project building working, feel free to add it to the flakelight readme as an available module | 01:59:07 |
Zhenxing He | OK, I'd be very glad to be able to do some contribution | 02:01:51 |
Zhenxing He | I am also using flakelight for defining nixos configurations, I created a flake with some pre-configured nixosModules or homeModules for hyprland and xmonad, etc. These modules may referencing other modules by using inputs.self.nixosModules or inputs.self.homeModules, this works fine when defining new hosts within the flake. But when I want to use this flake as inputs in another flake, there will be problems with the inputs.self references. and also inputs.home-manager and other inputs used in the previous flake will also be missing. | 02:04:03 |