NixOS: Basic nix functionality broken

Hi guys!
Im still new to nix and got most of the things working, but some basic nix-stuff simply refuses to cooperate, like nix-shell. For example, when I execute nix-env --upgrade '*', I get the following error

error: anonymous function at /home/marc/git/dotfiles/nixos/configuration.nix:1:1 called without required argument 'config'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/default.nix:74:10:

           73|     if lib.isFunction config0
           74|     then config0 { inherit pkgs; }
             |          ^
           75|     else config0;
(use '--show-trace' to show detailed location information)

(Yes I know this is not the intended way of how you do this on nixos → just an example :slight_smile:

Nixos configuration:

{ config, pkgs, lib, ... }:

#let
#  unstable = import <nixos-unstable> { config = { allowUnfree = true; }; };
#in

{
imports =
  [ # Include the results of the hardware scan.
    ./hardware-configuration.nix
    ./suspend-and-hibernate.nix
    ./conan.nix
    # ./tuxedo.nix
  ];

  # acpid
  services.acpid = {
    enable = true;
  };

# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# environment.systemPackages = with config.boot.kernelPackages;[ turbostat ];
environment.systemPackages = with pkgs; [
   (python310.withPackages(ps: with ps; [ pandas numpy ]))
  ];

# Setup keyfile
boot.initrd.secrets = {
  "/crypto_keyfile.bin" = null;
};

# Enable swap on luks
boot.initrd.luks.devices."luks-18911171-72fb-4967-82f8-161b16b6432a".device = "/dev/disk/by-uuid/18911171-72fb-4967-82f8-161b16b6432a";
boot.initrd.luks.devices."luks-18911171-72fb-4967-82f8-161b16b6432a".keyFile = "/crypto_keyfile.bin";

networking.hostName = "nixos"; # Define your hostname.
# networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

# Enable networking
networking.networkmanager.enable = true;
# Open ports for the Naviswiss External Dispaly --> Port 50051
networking.firewall.allowedTCPPortRanges = [ { from = 50051; to = 50051; } ];
networking.firewall.allowedUDPPortRanges = [ { from = 50051; to = 50051; } ];

# Set your time zone.
time.timeZone = "Europe/Zurich";

# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";

# Enable the X11 windowing system.
services.xserver.enable = true;

# services.xserver.videoDrivers = [ "displaylink" "modesetting" ];

# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;

# Enable hyperland
# hyprland
#programs.hyprland = {
#    enable = true;
#    xwayland = {
#      enable = true;
#      hidpi = false;
#  };
#};

programs.waybar = {
    enable = true;
    package = pkgs.waybar.overrideAttrs (oldAttrs: {
      mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ];
    });
};

# Configure keymap in X11
services.xserver = {
  layout = "de";
  xkbVariant = "";
};

# Configure console keymap
console = {
  useXkbConfig = true;
};


# Map CapsLock to Esc on single press and Ctrl on when used with multiple keys.
services.interception-tools = {
  enable = true;
  plugins = [ pkgs.interception-tools-plugins.caps2esc ];
  udevmonConfig = ''
    - JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.caps2esc}/bin/caps2esc | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE"
      DEVICE:
        EVENTS:
          EV_KEY: [KEY_CAPSLOCK, KEY_ESC]
  '';
};


# Enable CUPS to print documents.
services.printing.enable = true;

# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
  enable = true;
  alsa.enable = true;
  alsa.support32Bit = true;
  pulse.enable = true;
  # If you want to use JACK applications, uncomment this
  #jack.enable = true;

  # use the example session manager (no others are packaged yet so this is enabled by default,
  # no need to redefine it in your config for now)
  #media-session.enable = true;
  };

# Add docker support
virtualisation.docker.enable = true;
# virtualisation.docker.rootless = {
#   enable = true;
#   setSocketVariable = true;
# };

programs.nix-ld.enable = true;

services.udev = {
      extraRules = ''
        # User access to navigation unit USB devices.
        # Cypress FX3
        SUBSYSTEMS=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="00f3", MODE="0666"
        # UVC Camera
        SUBSYSTEMS=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="00f9", MODE="0666"
        # Microchip HUB controller
        SUBSYSTEMS=="usb", ATTRS{idVendor}=="0424", ATTRS{idProduct}=="2740", MODE="0666"
        # Display
        SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="08a6", MODE="0666"
      '';
  }; 

services.upower.enable = true;
services.devmon.enable = true;
services.gvfs.enable = true;
services.udisks2.enable = true;

# enable the tailscale service
services.tailscale.enable = true;

# Allow unfree packages
nixpkgs.config.allowUnfree = true;

nix = {
  package = pkgs.nixFlakes;
  extraOptions = ''
  experimental-features = nix-command flakes
'';
};


# Change default shell
users.defaultUserShell = pkgs.zsh;
programs.zsh.enable = true;
environment.shells = with pkgs; [ zsh ];

# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.marc = {
  isNormalUser = true;
  description = "Hans Ruedi";
  extraGroups = [ "networkmanager" "wheel" "docker" "storage" ];
  packages = with pkgs; [

# Storage
cifs-utils

# Network
networkmanagerapplet
nettools
inetutils
tailscale

## VPN
networkmanager-l2tp
strongswan

# Frontend for X11 
gnome3.gnome-tweaks
jumpapp
xorg.xhost
xdotool
wmctrl
xbindkeys
autorandr
arandr
xorg.xhost
polkit

# Frontend for wayland 
kanshi #autorandr for wayland
wl-clipboard #clipboard for wayland
wev # wayland event viewer
wdisplays # wayland version of arandr
wlr-randr # wayland xrandr
wlrctl # Command line utility for miscellaneous wlroots Wayland extensions

# Hyprland
wofi
swaybg # the wallpaper
swayidle # the idle timeout
swaylock # locking the screen
wlogout # logout menu
wl-clipboard # copying and pasting
wf-recorder # creen recording
grim # taking screenshots
slurp # selecting a region to screenshot
mako # the notification daemon, the same as dunst
yad # a fork of zenity, for creating dialogs


# audio
alsa-utils # provides amixer/alsamixer/...
playerctl # Command-line utility and library for controlling media players that implement MPRIS
mpd # for playing system sounds
mpc-cli # command-line mpd client
ncmpcpp # a mpd client with a UI
networkmanagerapplet # provide GUI app: nm-connection-editor


# Development tools
vscode
git
gitg
gitkraken
gimp
docker
docker-compose
pandoc
rpi-imager
gparted
meld
glxinfo
kooha
masterpdfeditor
jetbrains-toolbox
shell_gpt
#unstable.jetbrains.clion

# Development environment 
acpid # A daemon for delivering ACPI events to userspace programs
nodejs
patchelf
steam-run
stdenv
xvfb-run
fuse
pmutils # A small collection of scripts that handle suspend and resume on behalf of HAL

## CPP
cmake
gdb
gcc
gnumake
doxygen
python311Packages.pip

## Qt 
qtcreator
# qt6.qtbase
qt5.full
qt6.full
# libsForQt5.full
# libsForQt5.base
# libsForQt5.qmake
# libsForQt5.qt5.qttools
# libsForQt5.qtutilities
# libsForQt5.qtstyleplugins
# libsForQt5.qt5.qtbase
# libsForQt5.qt5.qtsvg

# Power management testing
gnome.gnome-power-manager # Waybar applets
upower # Waybar applets
powertop
stress
geekbench_5


## Androie tools
android-tools
android-studio
scrcpy


# Terminal 
kitty
zsh
neofetch
trash-cli
killall
neovim
s-tui
htop
tree
zip
unzip
xclip
toybox
jq # A lightweight and flexible command-line JSON processor
socat


# Generla stuff
google-chrome
firefox
_1password-gui
obsidian
discord
spotify
slack
libreoffice
drawio
gnome.nautilus
cinnamon.nemo-with-extensions
evince # default gnome pdf viewer
udisks # automount usb sticks

# Naviswiss 
## Naviplan workflow dependencies
paraview
flatbuffers
flatcc
    ];
  };


nixpkgs.config.permittedInsecurePackages = [
  "nodejs-14.21.3"
  "openssl-1.1.1u"
  "electron-13.6.9"
  "qtwebkit-5.212.0-alpha4"
];

# Fonts. Corefonts contain the webdings fonts needed by some Medivation documents, like the risk analysis 
fonts.fonts = with pkgs; [
  nerdfonts
  corefonts
];


# List packages installed in system profile. To search, run:
# $ nix search wget
#environment.systemPackages = with pkgs; [
#];
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment?

}

My NIX_PATH is as follows:

 ❯ echo $NIX_PATH
nixos-config=/home/marc/git/dotfiles/nixos/configuration.nix:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs

Additional info:

  • This also applies for other commands, like nix-shell --packages nano.
  • I symlinked the nixos folder (/etc/nixos -> /home/marc/git/dotfiles/nixos)
  • nixos-rebuild switch works just fine
  • Nixos version 23.05

If there is any info that might help, I’ll be happy to provide. Thanks a lot for your efforts :slight_smile:

Do you have stuff in ~/.config/nix/ that you haven’t shared? Because the error makes no sense. configuration.nix is not involved in a command like nix-env --upgrade '*' or nix-shell

1 Like

Hi!
There are no nix related folder in my home directory I know of – and sadly I don’t have a folder under ~/.config/nix/, but I assume you mean the nix configuration folder (which for me is located under /etx/nixos/)?

~/git/tmp/nixos_config main ?3 ❯ t /etc/nixos
/etc/nixos
├── conan.nix
├── configuration.nix
├── connect_wifi_guest.sh
├── connect_wifi_inside.sh
├── hardware-configuration.nix
├── suspend-and-hibernate.nix
├── tuxedo.nix
└── unstable_packages.nix
/etc/nix
├── nix.conf -> /etc/static/nix/nix.conf
└── registry.json -> /etc/static/nix/registry.json

For any that are wondering, here is also the trace for an example command nix-shell -p nano --show-trace:

~/git/tmp ❯ nix-shell -p nano --show-trace
error:
       … while evaluating call site

       at «none»:0: (source not available)

       … while calling anonymous lambda

       at «string»:1:1:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (nano) ]; } ""
             | ^

       … while evaluating call site

       at «string»:1:18:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (nano) ]; } ""
             |                  ^

       … while calling anonymous lambda

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/impure.nix:14:1:

           13|
           14| { # We put legacy `system` into `localSystem`, if `localSystem` was not passed.
             | ^
           15|   # If neither is passed, assume we are building packages on the current

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/impure.nix:87:1:

           86|
           87| import ./. (builtins.removeAttrs args [ "system" ] // {
             | ^
           88|   inherit config overlays localSystem;

       … while calling anonymous lambda

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/default.nix:19:1:

           18|
           19| { # The system packages will be built on. See the manual for the
             | ^
           20|   # subtle division of labor between these two `*System`s and the three

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/default.nix:132:4:

          131|
          132| in checked pkgs
             |    ^
          133|

       … while calling anonymous lambda

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/default.nix:58:108:

           57|     throwIfNot (lib.isList crossOverlays) "The crossOverlays argument to nixpkgs must be a list."
           58|     lib.foldr (x: throwIfNot (lib.isFunction x) "All crossOverlays passed to nixpkgs must be functions.") (r: r) crossOverlays
             |                                                                                                            ^
           59|     ;

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/default.nix:130:10:

          129|
          130|   pkgs = boot stages;
             |          ^
          131|

       … while calling anonymous lambda

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/stdenv/booter.nix:42:1:

           41| # other words, this does a foldr not foldl.
           42| stageFuns: let
             | ^
           43|

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/stdenv/booter.nix:142:4:

          141|
          142| in dfold folder postStage (_: {}) withAllowCustomOverrides
             |    ^
          143|

       … while calling 'dfold'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/stdenv/booter.nix:60:27:

           59|   */
           60|   dfold = op: lnul: rnul: list:
             |                           ^
           61|     let

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/stdenv/booter.nix:72:13:

           71|       lapp = lnul cur;
           72|       cur = go lapp 0;
             |             ^
           73|     in cur;

       … while calling 'go'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/stdenv/booter.nix:63:18:

           62|       len = builtins.length list;
           63|       go = pred: n:
             |                  ^
           64|         if n == len

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/stdenv/booter.nix:78:30:

           77|   # isn't already set.
           78|   withAllowCustomOverrides = lib.lists.imap1
             |                              ^
           79|     (index: stageFun: prevStage:

       … while calling 'imap1'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/lists.nix:117:14:

          116|   */
          117|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
             |              ^
          118|

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/stdenv/booter.nix:85:6:

           84|       // (stageFun prevStage))
           85|     (lib.lists.reverseList stageFuns);
             |      ^
           86|

       … while calling 'reverseList'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/lists.nix:406:17:

          405|   */
          406|   reverseList = xs:
             |                 ^
          407|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/default.nix:126:12:

          125|
          126|   stages = stdenvStages {
             |            ^
          127|     inherit lib localSystem crossSystem config overlays crossOverlays;

       … while calling anonymous lambda

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/stdenv/default.nix:7:1:

            6|
            7| { # Args just for stdenvs' usage
             | ^
            8|   lib

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/default.nix:89:12:

           88|   # take all the rest as-is
           89|   config = lib.showWarnings configEval.config.warnings configEval.config;
             |            ^
           90|

       … while calling 'showWarnings'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/trivial.nix:414:28:

          413|
          414|   showWarnings = warnings: res: lib.foldr (w: x: warn w x) res warnings;
             |                            ^
          415|

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/trivial.nix:414:33:

          413|
          414|   showWarnings = warnings: res: lib.foldr (w: x: warn w x) res warnings;
             |                                 ^
          415|

       … while calling 'foldr'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/lists.nix:53:20:

           52|   */
           53|   foldr = op: nul: list:
             |                    ^
           54|     let

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/lists.nix:60:8:

           59|         else op (elemAt list n) (fold' (n + 1));
           60|     in fold' 0;
             |        ^
           61|

       … while calling 'fold''

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/lists.nix:56:15:

           55|       len = length list;
           56|       fold' = n:
             |               ^
           57|         if n == len

       … while evaluating the attribute 'config.warnings'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:326:9:

          325|         options = checked options;
          326|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          327|         _module = checked (config._module);

       … while evaluating call site

       at «none»:0: (source not available)

       … while calling 'g'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/attrsets.nix:595:19:

          594|           g =
          595|             name: value:
             |                   ^
          596|             if isAttrs value && cond value

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/attrsets.nix:598:20:

          597|               then recurse (path ++ [name]) value
          598|               else f (path ++ [name]) value;
             |                    ^
          599|         in mapAttrs g;

       … while calling anonymous lambda

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:248:72:

          247|           # For definitions that have an associated option
          248|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          249|

       … while evaluating the attribute 'value'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:759:9:

          758|     in warnDeprecation opt //
          759|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          760|         inherit (res.defsFinal') highestPrio;

       … while evaluating the option `_module.freeformType':

       … while evaluating the attribute 'mergedValue'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:794:5:

          793|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          794|     mergedValue =
             |     ^
          795|       if isDefined then

       … while evaluating the attribute 'values'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:788:9:

          787|       in {
          788|         values = defs''';
             |         ^
          789|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:887:7:

          886|     in {
          887|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          888|       inherit highestPrio;

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:598:22:

          597|       # extract the definitions for each loc
          598|       defnsByName' = byName "config" (module: value:
             |                      ^
          599|           [{ inherit (module) file; inherit value; }]

       … while calling 'byName'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:569:25:

          568|       */
          569|       byName = attr: f: modules:
             |                         ^
          570|         zipAttrsWith (n: concatLists)

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:594:21:

          593|       # an attrset 'name' => list of submodules that define ‘name’.
          594|       defnsByName = byName "config" (module: value:
             |                     ^
          595|           map (config: { inherit (module) file; inherit config; }) (pushDownProperties value)

       … while calling 'byName'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:569:25:

          568|       */
          569|       byName = attr: f: modules:
             |                         ^
          570|         zipAttrsWith (n: concatLists)

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:544:8:

          543|     mergeModules' prefix modules
          544|       (concatMap (m: map (config: { file = m._file; inherit config; }) (pushDownProperties m.config)) modules);
             |        ^
          545|

       … while calling anonymous lambda

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:544:19:

          543|     mergeModules' prefix modules
          544|       (concatMap (m: map (config: { file = m._file; inherit config; }) (pushDownProperties m.config)) modules);
             |                   ^
          545|

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:544:73:

          543|     mergeModules' prefix modules
          544|       (concatMap (m: map (config: { file = m._file; inherit config; }) (pushDownProperties m.config)) modules);
             |                                                                         ^
          545|

       … while calling 'pushDownProperties'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:826:24:

          825|   */
          826|   pushDownProperties = cfg:
             |                        ^
          827|     if cfg._type or "" == "merge" then

       … while evaluating the attribute 'config'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:478:11:

          477|           options = m.options or {};
          478|           config = addFreeformType (addMeta (m.config or {}));
             |           ^
          479|         }

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:478:20:

          477|           options = m.options or {};
          478|           config = addFreeformType (addMeta (m.config or {}));
             |                    ^
          479|         }

       … while calling 'addFreeformType'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:463:25:

          462|         else config;
          463|       addFreeformType = config: if m ? freeformType
             |                         ^
          464|         then mkMerge [ config { _module.freeformType = m.freeformType; } ]

       … while evaluating call site

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:478:37:

          477|           options = m.options or {};
          478|           config = addFreeformType (addMeta (m.config or {}));
             |                                     ^
          479|         }

       … while calling 'addMeta'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/lib/modules.nix:460:17:

          459|     let
          460|       addMeta = config: if m ? meta
             |                 ^
          461|         then mkMerge [ config { meta = m.meta; } ]

       … while evaluating the attribute 'config'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/default.nix:82:9:

           81|         _file = "nixpkgs.config";
           82|         config = config1;
             |         ^
           83|       })

       error: anonymous function at /home/marc/git/dotfiles/nixos/configuration.nix:1:1 called without required argument 'config'

       at /nix/store/kr54vf122h27ck1n86x54f0x355dag6h-nixos-23.05/nixos/pkgs/top-level/default.nix:74:10:

           73|     if lib.isFunction config0
           74|     then config0 { inherit pkgs; }
             |          ^
           75|     else config0;

It’s super odd that nix tries to load your configuration.nix. I would try to debug this to delete the symlink in /etc/nixos and move your configuration.nix to a different location to see at which location it tries to load this file.

Edit, incorrect - sorry for the noise
Using flakes myself, but I from what you’ve posted here I don’t think you need to add configuration.nix to NIX_PATH and it might trigger that error, as nix might try to eval that file - a nixos module - as a plain nix file?

There’s no reason that ordinary usage of nix-env or nix-shell would evaluate <nixos-config>, which is why I asked about implicit config files like ~/.config/nix/.... (yes, @GaryB477, I did mean ~/.config/nix, not /etc/nixos, because there are files in ~/.config/nix/ that can affect nixpkgs evaluation, while /etc/nixos won’t).

So having nixos-config in NIX_PATH like they do is fine and expected to work the way they intended. The fact that <nixos-config> is making its way into nix-env or nix-shell evaluations makes absolutely no sense; there’s probably something on this system that hasn’t been shared with us yet.

1 Like

https://stop-using-nix-env.privatevoid.net/

@ElvishJerricco Wow, thats embarrassing - you were absolutely right! While there was nothing in ~/.config/nix/, I did (for some unknown reason :slight_smile: ) simlink this:

~ ❯ ls -al ~/.config/nixpkgs/config.nix                                                                          12:27:32
lrwxrwxrwx 1 root root 47 2023-07-26 12:41 /home/marc/.config/nixpkgs/config.nix -> /home/marc/git/dotfiles/nixos/configuration.nix

… which was obviously wrong! With this gone, it works as intended :+1:

Thanks a lot guys!