!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

132 Members
27 Servers

Load older messages


SenderMessageTime
20 Jul 2025
@n4ch723hr3r:nope.chatn4ch723hr3r *
          {
            name,
            ...
          }:
let
  inherit (config.flake.modules.x10.device-config.${name}) username;
in
          {
            options.homeManager = {
15:07:07
@x10an14:matrix.orgx10an14 Gotcha. Just managed to put 2+2 together with your previous mention of fooConf.${name}. I got infinite recursion error 15:09:37
@n4ch723hr3r:nope.chatn4ch723hr3ryeah i hope that makes sense why you got infinite recursion error15:10:34
@n4ch723hr3r:nope.chatn4ch723hr3r* yeah i hope that it makes sense why you got infinite recursion error15:10:45
@x10an14:matrix.orgx10an14 I got it to work with lots of help from @mightyiam:matrix.org (thanks)! =) 17:11:02
@n4ch723hr3r:nope.chatn4ch723hr3rnice what did you do?22:12:49
21 Jul 2025
@x10an14:matrix.orgx10an14

Something I'd already tried earlier but discarded due to an unrelated error (that I thought told me I could not do things this way):

{
    type =
      with lib.types;
      attrsOf (
        submodule (
          nixosConfig:
          let
            cfg = nixosConfig.config.nixos;
            inherit (nixosConfig.config) hostname username system;
          in
          {
            options.nixos = builtins.break {
              entryPoint = lib.mkOption {
                type = lib.types.path;
                default = "${repoRoot}/nixos/${username}_at_${hostname}";
              };
              toplevelBuild = lib.mkOption {
                type = lib.types.raw;
                readOnly = true;
              };
            };
            config.nixos.toplevelBuild = lib.mkIf (builtins.pathExists cfg.entryPoint) (
              inputs.nixpkgs.lib.nixosSystem {
                modules = [
                  {
                    nixpkgs.hostPlatform = { inherit system; };
                  }
                  (import cfg.entryPoint (inputs // { inherit repoRoot; }))
                  "${repoRoot}/x10/options/unfree-packages.nix"
                  inputs.nur.modules.nixos.default
                ];
                specialArgs = {
                  inherit inputs hostname repoRoot;
                };
              }
            );
          }
        )
      );
  }

So yeah, the inner config variable of the extending submodule contains the submodule's "sibling" option values.

07:14:28
@nbp:mozilla.orgnbp

x10an14: taking the discussion from the beginning …

If you want to declare options specific to one instance, you can do it as follow:

{ lib,  ... }@toplevel:
{
  config.flake.modules.foo.<fooInstance> = {config, ...}@submoduleInstance: {
    options.home-manager = lib.mkOption { ... };
    config.home-manager = ...;
  }
}

If you want to make the home-manager option available to all instances, then your initial example is almost there, you have to redefine the foo option with the submodule that you want to add. Submodule option declarations are merged, see fileSystems option as an example, which is declared in multiple modules.

09:36:22
@nbp:mozilla.orgnbp If you want your option to define home-manager.<user> from foo.<user>, unfortunately there is no simple shortcut that exists today, you will have to fallback to the nix language / Nixpkgs library to map the attributes of one into the other. 09:39:25
@x10an14:matrix.orgx10an14

nbp: Thanks! =D

I got it to work, as described in the previous 2x messages of mine =)
This is how I did it: https://git.sr.ht/~x10an14/nix-parts-conf/tree/main/item/device-configs/home-manager.nix

Any feedback/suggestions welcome!
PS: I urge those who've got feedback/suggestions to consider whether it's too niche for this channel/is maybe better suited for a DM =)

10:29:35
@nbp:mozilla.orgnbp x10an14: This is the right channel. Thanks for the link, I was not aware of the pipe operator. 12:03:29
@x10an14:matrix.orgx10an14 Aight, and yw =) 12:07:17
25 Jul 2025
@hsjobeki:matrix.orghsjobeki joined the room.12:11:00
31 Jul 2025
@unwary:matrix.orgunwary joined the room.00:25:28
@unwary:matrix.orgunwaryThis might be the wrong chat, but I'm trying to understand how to package something like a .desktop file so that a module I write will be included in start menus and such. Right now, enabling my module gets me the executable available on the command line, but as it's a GUI program, that's suboptimal.00:26:59
@mightyiam:matrix.org@mightyiam:matrix.orgThere's plenty of examples in Nixpkgs. Did you find some?06:42:08
@mightyiam:matrix.org@mightyiam:matrix.orgAnd yes, this isn't quite the correct room.06:42:25
@sammy:cherrykitten.gaysammy (It/Its) joined the room.09:35:10
@sammy:cherrykitten.dev@sammy:cherrykitten.dev left the room.10:02:52
@unwary:matrix.orgunwaryI did not, or did not detect it. I seemed to examine modules that used various build-wrapping tools that I presumed handled that as part of the build.23:53:39
1 Aug 2025
@mightyiam:matrix.org@mightyiam:matrix.org Sorry for not being clear. It's not in a NixOS module typically, but in the package for some piece of software. And might not be obvious. The part of this that is in the NixOS module is that the package of the software ends up in environment.systemPackages and includes the .desktop file. 06:32:42
@yan:we2.eeyan 💕 joined the room.15:42:19
5 Aug 2025
@isabel:isabelroses.comisabel changed their profile picture.09:49:13
@axelkar:matrix.orgAxel Karjalainen joined the room.18:48:14
6 Aug 2025
@vidariondr:matrix.orgvidariondr set a profile picture.18:31:00
7 Aug 2025
@mightyiam:matrix.org@mightyiam:matrix.orghttps://discourse.nixos.org/t/nixpkgs-module-system-config-modules-graph/67722?u=mightyiam16:53:44
@nbp:mozilla.orgnbp Let's see how much time it take before someone ask what is the difference between key and file. 17:05:23
@nbp:mozilla.orgnbp

Now people might understand why you should not write a NixOS module within a flake, because it lacks position information.

{agenix, ...}:

{
  # Using the module directly prevent the deduplication from working properly.
  imports = [
    agenix.nixosModules.default
  ];
}
17:11:50
@nbp:mozilla.orgnbp *

Now people might understand why you should not write a NixOS module within a flake.nix file, because it lacks position information.

{agenix, ...}:

{
  # Using the module directly prevent the deduplication from working properly.
  imports = [
    agenix.nixosModules.default
  ];
}
17:12:41
8 Aug 2025
@0x4a6f:nixos.dev0x4A6F joined the room.06:31:30

Show newer messages


Back to Room ListRoom Version: 10