!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1692 Members
Nix programming language297 Servers

Load older messages


SenderMessageTime
30 Aug 2025
@niklauzg:matrix.orgNiklauzI appreciate that, this is a one off for a pretty small doc 17:30:16
@niklauzg:matrix.orgNiklauz* I appreciate that, this is a one off for a pretty small and simple doc 17:30:33
@emilazy:matrix.orgemily(I take it this isn't for Nixpkgs?)17:30:49
@niklauzg:matrix.orgNiklauzmy questions? No17:31:08
31 Aug 2025
@infinisil:matrix.orginfinisil You can do lib.mergeDefinitions [] (types.attrsOf (types.listOf types.int)) [ ... ] 13:23:45
@epimonic:matrix.orgepimonic joined the room.13:24:04
@infinisil:matrix.orginfinisilAnd there is types.anything, but I don't think it merges lists like you want13:24:19
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all) hmm, that just returns a bunch of «error: attribute 'file' missing» 13:28:25
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all) also its not attrsOf (listOf int), it'll be attrsOf utils.systemdUtils.unitOptions.unitOption 13:30:05
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all)there is some merging logic defined in https://github.com/NixOS/nixpkgs/blob/9d79c5b0ab7068419dc9c0e2b105d1b807d7dcd7/nixos/lib/systemd-unit-options.nix#L54-L62 fo9r that, but i don't quite understand that13:31:38
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all)

for testing:

> :l <nixpkgs>
> lib = pkgs.lib
> utils = import "${<nixpkgs>}/nixos/lib/utils.nix" { inherit pkgs lib; config = {}; }
> :p mergeDefinitions [] (types.attrsOf utils.systemdUtils.unitOptions.unitOption) [ { a = [1 2]; } { a = [3 4]; }]

instantiating systemd utils is annoying, but there is the code

13:38:05
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all)and the merge just returns bogus stuff13:38:14
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all)i am probably just doing something dumb13:38:22
@infinisil:matrix.orginfinisil Grimmauld (any/all) Ah, the last argument needs to be of the form [ { file = "a"; value = ...; } ... ] 13:39:47
@infinisil:matrix.orginfinisilIt uses the file for error messages13:39:58
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all)But i don't have any files, do i just "invent" files?13:40:10
@infinisil:matrix.orginfinisilYeah13:40:20
@infinisil:matrix.orginfinisil You can also wrap it into a small helper function that uses lib.imap0 to generate indexed fake files 13:40:52
@infinisil:matrix.orginfinisil * You can also wrap it into a small helper function that uses lib.imap0 to generate indexed fake file names 13:41:00
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all)and can this even error?13:44:20
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all)i guess inventing a file does work, ty :)13:44:20
@grimmauld:grapevine.grimmauld.deGrimmauld (any/all) (lib.mergeDefinitions [] (lib.types.attrsOf utils.systemdUtils.unitOptions.unitOption) [ {file = "test"; value = { a = [1 2]; }; } { file = "test"; value = { a = [3 4]; }; } ]).mergedValue did the trick 13:44:21
@yang:linuxe.orgyang joined the room.15:32:23
1 Sep 2025
@yusufraji49:matrix.orgYusuf Raji joined the room.10:59:25
2 Sep 2025
@corridor4572:matrix.orgRichInOverdraft changed their profile picture.16:20:36
3 Sep 2025
@ghpzin:envs.netghpzin joined the room.07:28:14
@msanft:matrix.orgMoritz Sanft Why does this not work?
# flake.nix
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };


  outputs = { nixpkgs, ... }: nixpkgs.lib.genAttrs [ "x86_64-linux" ]
    (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [
            (_final: prev: (import ./nix/pkgs { inherit (prev) lib callPackage; }))
            (_final: prev: { lib = prev.lib // (import ./nix/lib { inherit (prev) lib callPackage; }); })
          ];
        };
      in
      {
        devShells.${system}.default = pkgs.callPackage ./nix/shell.nix { };
      }
    );
}
The outputs-like structure gets put under ${system}, so if I do nix eval .#x86_64-linux, I get what I would expect outputs to be. However, if I eval attrs.${system}, it doesn't seem to be there :thinking:
19:33:25
@msanft:matrix.orgMoritz Sanft Why does this not work?
# flake.nix
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };


  outputs = { nixpkgs, ... }: nixpkgs.lib.genAttrs [ "x86_64-linux" ]
    (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [
            (_final: prev: (import ./nix/pkgs { inherit (prev) lib callPackage; }))
            (_final: prev: { lib = prev.lib // (import ./nix/lib { inherit (prev) lib callPackage; }); })
          ];
        };
      in
      {
        devShells.${system}.default = pkgs.callPackage ./nix/shell.nix { };
      }
    );
}
The outputs-like structure gets put under ${system}, so if I do nix eval .#x86_64-linux, I get what I would expect outputs to be. However, if I eval attrs.${system}, it doesn't seem to be there 🤔
19:33:36
4 Sep 2025
@atagen:ch.atagen.coatagen set a profile picture.12:04:16
@atagen:ch.atagen.coatagen changed their profile picture.12:04:40

Show newer messages


Back to Room ListRoom Version: 6