!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1518 Members
Nix programming language267 Servers

Load older messages


SenderMessageTime
24 Jul 2024
@quapka4:matrix.orgquapka4So, optionally change the source.12:20:19
@quapka4:matrix.orgquapka4 Latest meaning the latest version of OpenSSL in nixpkgs, not the HEAD of the repo. 12:21:38
@quapka4:matrix.orgquapka4 So, I don't think I want { version ? "master" }. 12:22:02
@quapka4:matrix.orgquapka4

Ah:

          src = if version != "" then pkgs.fetchurl {
            url = "https://www.openssl.org/source/openssl-${version}.tar.gz";
            hash = hash;
          } else
          prev.src;

does the job.

13:27:54
@quapka4:matrix.orgquapka4

Btw. regarding override and overrideAttrs is there some common patterns to follow? I need both so did something like:

package = ( pkgs.package.override { param = 1 } ).overrideAttrs (final: prev: { ... });
13:42:53
@quapka4:matrix.orgquapka4Feels okay, maybe I just question it because I did it the first time :D13:43:14
@kaleocheng:matrix.org@kaleocheng:matrix.org left the room.13:59:52
@rvdp:infosec.exchangeRamses 🇵🇸That's how I do it all the time as well14:06:26
@rick:matrix.ciphernetics.nlMindaviThese questions are more suitable for nixpkgs channels since they involve nixpkgs patterns16:31:15
@tazv:matrix.orgtazv joined the room.21:08:41
@lambadada:matrix.org@lambadada:matrix.org left the room.23:57:14
25 Jul 2024
@fluffeh:matrix.org@fluffeh:matrix.org left the room.01:02:07
@mr-qubo:matrix.orgmr-qubo

How can I map over types.attrsOf option in config. Example:

{ config, lib, ... }:
with lib;

{
  options = {
    users = mkOption {
      type = types.attrsOf (types.submodule ({ ... }: {
        options = {
          foo = mkEnableOption "foo";
          bar = mkEnableOption "bar";
        };
      }));
      default = {};
    };
  };
}

How can I do something like users.<user>.foo = mkIf config.users.<user>.bar true for every <user>?

03:17:19
@mr-qubo:matrix.orgmr-qubo

I've tried

    users = flip mapAttrs config.users (name: user: {
      foo = mkIf user.bar true;
    });

but this gives me infinite recursion error.

03:24:07
@mr-qubo:matrix.orgmr-qubo *

How can I map over types.attrsOf option in config. Example:

{ config, lib, ... }:
with lib;

{
  options = {
    users = mkOption {
      type = types.attrsOf (types.submodule ({ ... }: {
        options = {
          foo = mkEnableOption "foo";
          bar = mkEnableOption "bar";
        };
      }));
      default = {};
    };
  };
}

How can I do something like users.<user>.foo = mkIf config.users.<user>.bar true for every <user>?

03:24:22
@mr-qubo:matrix.orgmr-qubo *

I've tried

    users = flip mapAttrs config.users (name: user: {
      foo = mkIf user.bar true;
    });

but this gives me infinite recursion error.

03:24:27
@ity:itycodes.orgTranquil ItyPlease don't use threads, they break some clients (such as Element Web)05:18:34
@ity:itycodes.orgTranquil ItyWith that said05:26:22
@ity:itycodes.orgTranquil Ityimage.png
Download image.png
05:26:23
@ity:itycodes.orgTranquil ItyDoes this answer your Q?05:26:26
@ity:itycodes.orgTranquil Ityimage.png
Download image.png
05:31:11
@ity:itycodes.orgTranquil ItyNamely, smth like this should work05:31:15
@mr-qubo:matrix.orgmr-qubo
In reply to @ity:itycodes.org
Does this answer your Q?

No. I don't know the users a prori. The users of the module can use anything, e.g. someone could configure it like.

{
  users.alice = { foo = true; }
  users.bob = { bar = true; }
}

And with this example I wold want it to evaluate to

{
  users.alice.foo = true;
  users.alice.bar = false;
  users.bob.foo = true;
  users.bob.bar = true;
09:26:05
@mr-qubo:matrix.orgmr-qubo
In reply to @ity:itycodes.org
Does this answer your Q?
*

No. I don't know the users a prori. The users of the module can use anything, e.g. someone could configure it like.

{
  users.alice = { foo = true; }
  users.bob = { bar = true; }
}

And with this example I wold want it to evaluate to

{
  users.alice.foo = true;
  users.alice.bar = false;
  users.bob.foo = true;
  users.bob.bar = true;
09:26:12
@mr-qubo:matrix.orgmr-qubo *

No. I don't know the users a prori. The users of the module can use anything, e.g. someone could configure it like.

{
  users.alice = { foo = true; }
  users.bob = { bar = true; }
}

And with this example I wold want it to evaluate to

{
  users.alice.foo = true;
  users.alice.bar = false;
  users.bob.foo = true;
  users.bob.bar = true;
}
09:26:34
@ity:itycodes.orgTranquil ItyWhy is foo for bob true while bar for alice is false09:32:20
@ity:itycodes.orgTranquil ItyWhich part exactly are you stuck on?09:32:34
@mr-qubo:matrix.orgmr-qubo
In reply to @ity:itycodes.org
Why is foo for bob true while bar for alice is false
That's a small example of what I want it to do.
I want to write a module, but it's for home-manager, so it must work for everyone and I don't know what will be the attribute for users in this example.
I want to set users.${user}.foo = mkIf config.users.${user}.bar true for every attribute of users. That's also just example, what I'm trying to write involves more complicated expression.
09:38:31
@mr-qubo:matrix.orgmr-qubo

But I've managed to figure it out:

{ config, lib, ... }:
with lib;

{
  options = {
    users = mkOption {
      type = types.attrsOf (types.submodule (args: let user = args.config; in {
        options = {
          foo = mkEnableOption "foo";
          bar = mkEnableOption "bar";
        };
        config = {
          foo = mkIf user.bar true;
        };
      }));
      default = {};
    };
  };
}
09:39:30
@kotomine:matrix.orgKotomine joined the room.10:48:32

Show newer messages


Back to Room ListRoom Version: 6