!SgYlXivkogarTVcnZO:nixos.org

Nix Flakes

903 Members
184 Servers

Load older messages


SenderMessageTime
7 Nov 2023
@crtified:crtified.meCRTified tbh, I don't know whether the let/inherit approach or the higher-order-function approach is better, but nix evaluates slow either way, so I'd say that it makes sense to use what the user can actually use 🙂 22:19:44
@janik0:matrix.org@janik0:matrix.org
In reply to @crtified:crtified.me
https://gist.github.com/CRTified/69f83b3c1eef037413a400566e583cd3 Note that the externalModule.nix contains a function taking self which returns the usual module (which is a function in config, lib, ...)
thank you for this ❤️
22:20:48
@crtified:crtified.meCRTified
In reply to @janik0:matrix.org
thank you for this ❤️
Oh, if you need the proper name for that concept: It's a Closure - more obvious with the external module
22:42:46
@janik0:matrix.org@janik0:matrix.org
In reply to @crtified:crtified.me
Oh, if you need the proper name for that concept: It's a Closure - more obvious with the external module
I'll look into that later. I gave myself the challenge of getting a deeper understating of the nix lang and nixos module system so I'm Implementing a dns libary a module which gives necessary meta information to generate something like a octodns config.
22:49:11
@janik0:matrix.org@janik0:matrix.orgimage.png
Download image.png
22:49:25
@crtified:crtified.meCRTifiedoh, dns name manipulation might come handy once in a while 🙂 22:49:53
@mib:kanp.aimib 🥐
In reply to @janik0:matrix.org
I'll look into that later. I gave myself the challenge of getting a deeper understating of the nix lang and nixos module system so I'm Implementing a dns libary a module which gives necessary meta information to generate something like a octodns config.
Nice idea! I hope you share it once you're done! :)
22:53:15
@mib:kanp.aimib 🥐
In reply to @janik0:matrix.org
I think this works, but I also need pass in the nixpkgs lib and the magic nixosModules config attribute somehow
dunno about closure approach but you could merge them; nixpkgs.lib // (import ./lib)
22:54:06
@mib:kanp.aimib 🥐 * dunno about closure approach but you could merge them; lib = nixpkgs.lib // (import ./lib) 22:54:28
@mib:kanp.aimib 🥐
In reply to @crtified:crtified.me
https://gist.github.com/CRTified/69f83b3c1eef037413a400566e583cd3
Ah, yeah, so it is either the inherit (because external file) or inlining a closure. I prefer passing an attribute set to generate the module since the actual module is in another file, but to each their own :) (also makes it easier if you e.g. have a bunch of modules)
22:57:17
@mib:kanp.aimib 🥐Thanks for the example though! :) always nice to see alternative ways of solving issues ^^22:57:47
@mib:kanp.aimib 🥐 * you could merge them; lib = nixpkgs.lib // (import ./lib). Works with both closure and passing the attributeset, but you'll probably want a let in regardless 22:58:39
@janik0:matrix.org@janik0:matrix.org
In reply to @crtified:crtified.me
Oh, if you need the proper name for that concept: It's a Closure - more obvious with the external module
* I'll look into that later. I gave myself the challenge of getting a deeper understating of the nix lang and nixos module system so I'm Implementing a dns libary and module which gives necessary meta information to generate something like a octodns config.
22:58:46
@janik0:matrix.org@janik0:matrix.org
In reply to @mib:kanp.ai
Nice idea! I hope you share it once you're done! :)
of course, how else would I get people to do free qa :D
23:00:57
@antifuchs:asf.computer@antifuchs:asf.computer
In reply to @janik0:matrix.org
I would try to avoid anything relying on a extra piece of infrastructure that is potentially a single point of failure so the whole proxy thing seems quite meh I find the approach https://github.com/snowfallorg/thaw is taking nice but I have to admit I didn't use it yet.
Ooooh, that does look pretty excellent! I’m skeptical of the proxy approach too, and I even more dislike having transitive deps inject those into my system dependencies… so today I switched from Eza to lsd (:
23:37:47
9 Nov 2023
@fabianhjr:matrix.orgFabián HerediaHi, a friend just released a very small flake-parts module extension around perSystem in case someone wants to give it a try :3 https://github.com/vic/fp-nm-ws05:38:57
@bootstrapper:matrix.org@bootstrapper:matrix.org changed their display name from snick to Ido Samuelson.06:33:38
@kraem:ne.bul.aekraem
In reply to @antifuchs:asf.computer
Ooooh, that does look pretty excellent! I’m skeptical of the proxy approach too, and I even more dislike having transitive deps inject those into my system dependencies… so today I switched from Eza to lsd (:
out of curiosity. what's the extra transitive dep you're thinking of? zlib? :)
21:00:23
@antifuchs:asf.computer@antifuchs:asf.computer I was pulling eza into my system definition flake, and it started using the proxy on its flake inputs for some reason 21:17:29
@antifuchs:asf.computer@antifuchs:asf.computer So now that flake was using the proxy; I noticed because my hydra builds were failing in the sandbox 21:17:59
@antifuchs:asf.computer@antifuchs:asf.computer Turns out I like lsd more (: 21:18:15
@kraem:ne.bul.aekraemah i see :)21:39:47
10 Nov 2023
@atka:matrix.org@atka:matrix.org left the room.07:35:14
@industrial:matrix.orgIndustrial Hello. I'm trying to do this:

    nixosConfigurations = {
      langhus = inputs.nixpkgs.lib.nixosSystem {
        inherit system;
        inherit pkgs;

        modules = [
          (import ./features/system/networking {
            options = {
              hostname = "langhus";
            };
          })
          ./features/system/bluetooth
          ./features/system/boot

With the help of ChatGPT to try to get my modules configurable. I want to use them in different ways on different hosts
13:21:37
@industrial:matrix.orgIndustrial
{ lib, ... }:
{
  options = {
    hostname = lib.mkOption {
      type = lib.types.str;
      default = "langhus";
      description = "Hostname for the system";
    };
  };

  config = {
    networking.hostName = options.hostname;
    networking.networkmanager.enable = true;
  };
}

This is the networking module.

I'm getting error: undefined variable 'options'.
13:22:12
@industrial:matrix.orgIndustrialHow do I pass the options to my module correctly?13:22:56
@industrial:matrix.orgIndustrial Hmm. It works if I remove the options = {}. 13:24:03
@mib:kanp.aimib 🥐

ah, well that's a simple issue. when you do import ./some/expr.nix { some = "options"; }, you first import ./some/expr.nix, which could be anything (in this case what you showed) and then you pass it the attribute set { some = "options"; }. If you really want to do what you're doing, you'd need

{ options }:
{ lib, ... }:
{
  networking.hostName = options.hostname;
  /* ... etc */
}
13:25:04
@mib:kanp.aimib 🥐my point is that you're misusing the modules system.13:25:54
@mib:kanp.aimib 🥐 *

ah, well that's a simple issue. when you do import ./some/expr.nix { some = "options"; }, you first import ./some/expr.nix, which could be anything (in this case what you showed) and then you pass it the attribute set { some = "options"; }. If you really want to do what you're doing, you'd need

{ options }:
{ lib, ... }:
{
  networking.hostName = options.hostname;
  networking.networkmanager.enable = true;
}
13:26:19

Show newer messages


Back to Room ListRoom Version: 6