!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1518 Members
Nix programming language267 Servers

Load older messages


SenderMessageTime
18 Sep 2024
@aadniz:knaben.org@aadniz:knaben.org left the room.12:16:57
@subfractal:matrix.orgsubfractal changed their display name from gkze to subfractal.15:32:12
@kwaaaaarzu:matrix.org@kwaaaaarzu:matrix.org joined the room.17:25:19
@kwaaaaarzu:matrix.org@kwaaaaarzu:matrix.org changed their display name from kwaaaaarzu to kwizu.17:34:42
@artur:glasgow.social(artur 'manuel) changed their profile picture.23:01:05
19 Sep 2024
@kwaaaaarzu:matrix.org@kwaaaaarzu:matrix.org removed their profile picture.00:59:12
@kwaaaaarzu:matrix.org@kwaaaaarzu:matrix.org removed their display name kwizu.00:59:15
@kwaaaaarzu:matrix.org@kwaaaaarzu:matrix.org left the room.00:59:23
@memegames99:matrix.org@memegames99:matrix.org joined the room.01:51:34
@memegames99:matrix.org@memegames99:matrix.org set a profile picture.02:02:24
@memegames99:matrix.org@memegames99:matrix.org changed their profile picture.02:02:30
@bumperboat:matrix.orgbumperboat joined the room.07:54:33
@benjaminedwardwebb:envs.netbenwebb joined the room.21:46:08
20 Sep 2024
@mwoodpatrickmx:matrix.orgmwoodpatrickmxNot sure if this is the right place to ask the question but when using the nix repl is there a way to get a list of all the variables the repl currently has14:08:23
@mwoodpatrickmx:matrix.orgmwoodpatrickmxSeems like doing ":<tab>" (colon followed by tab autocompletes and generates a list of known variables.14:36:31
@wizardlink:matrix.orgwizardlink joined the room.23:26:07
@wizardlink:matrix.orgwizardlink

Hello there! A quick and maybe dumb question...

I am currently working on my home-manager configuration and decided to make my scripts into .nix files that evaluate strings (for interpolating packages). Now, if I do

{
  # ...
  text = import ./my-script.nix;
}

It yields an error, which is very non-descriptive... But:

{
  # ...
  text = import ./my-script.nix { pkgs = pkgs; };
}

Does not errors and the function is evaluated? I thought that parameters got passed down kind of like imports does, but it isn't the case... Can someone explain me better how functions are evaluated in the case of an import?

23:29:59
@wizardlink:matrix.orgwizardlink *

Hello there! A quick and maybe dumb question...

I am currently working on my home-manager configuration and decided to make my scripts into .nix files that evaluate strings (for interpolating packages). Now, if I do

{
  # ...
  text = import ./my-script.nix;
}

It yields an error, which is very non-descriptive... But:

{
  # ...
  text = import ./my-script.nix { pkgs = pkgs; };
}

Does not errors and the function is evaluated? I thought that parameters got passed down kind of like imports does, but it isn't the case... Can someone explain me better how functions are evaluated in the case of an import?

Thanks in advance!

23:31:04
@wizardlink:matrix.orgwizardlink changed their profile picture.23:37:50
21 Sep 2024
@jordan.steinke:matrix.org@jordan.steinke:matrix.org changed their display name from Jordan to Jordan🪻.04:33:14
@luna-null:matrix.orgAutumn joined the room.05:42:44
@jordan.steinke:matrix.org@jordan.steinke:matrix.org removed their profile picture.16:54:41
@jordan.steinke:matrix.org@jordan.steinke:matrix.org removed their display name Jordan🪻.16:54:48
@jordan.steinke:matrix.org@jordan.steinke:matrix.org left the room.16:55:07
@cycyone3:matrix.org@cycyone3:matrix.org left the room.17:10:01
@iv-nn:matrix.orgiv-nn joined the room.18:17:25
22 Sep 2024
@cafkafk:gitter.imcafkafk
In reply to @wizardlink:matrix.org

Hello there! A quick and maybe dumb question...

I am currently working on my home-manager configuration and decided to make my scripts into .nix files that evaluate strings (for interpolating packages). Now, if I do

{
  # ...
  text = import ./my-script.nix;
}

It yields an error, which is very non-descriptive... But:

{
  # ...
  text = import ./my-script.nix { pkgs = pkgs; };
}

Does not errors and the function is evaluated? I thought that parameters got passed down kind of like imports does, but it isn't the case... Can someone explain me better how functions are evaluated in the case of an import?

Thanks in advance!

imports is actually a nixpkgs/nixos specific thing, it calls the "modules" (really functions) with a bunch of pre-defined arguments (see e.g. nixpkgs/lib/modules.nix if curious).

import on the other hand is a Nix keyword that parses and loads the expression from some path, and the attrSet it takes here (in your case { pkgs = pkgs; } is an argument passed to the function found in ./my-script.nix.

the start of your ./my-script.nix file likely looks something like this:

{ pkgs }:

Here, { pkgs }: is actually an anonymous function taking an attrSet with an attribute called pkgs.

09:29:41
@cafkafk:gitter.imcafkafk The reason you can't just use imports ./my-script.nix is because you're not specifying the pkgs attribute 09:31:40
@cafkafk:gitter.imcafkafk * The reason you can't just use import ./my-script.nix is because you're not specifying the pkgs attribute 09:31:44
@cafkafk:gitter.imcafkafk * The reason you can't just use import ./my-script.nix is because you're not specifying the pkgs attribute as an argument 09:32:05

Show newer messages


Back to Room ListRoom Version: 6