| 30 Aug 2025 |
Niklauz | I appreciate that, this is a one off for a pretty small doc | 17:30:16 |
Niklauz | * I appreciate that, this is a one off for a pretty small and simple doc | 17:30:33 |
emily | (I take it this isn't for Nixpkgs?) | 17:30:49 |
Niklauz | my questions? No | 17:31:08 |
| 31 Aug 2025 |
infinisil | You can do lib.mergeDefinitions [] (types.attrsOf (types.listOf types.int)) [ ... ] | 13:23:45 |
| epimonic joined the room. | 13:24:04 |
infinisil | And there is types.anything, but I don't think it merges lists like you want | 13:24:19 |
Grimmauld (any/all) | hmm, that just returns a bunch of «error: attribute 'file' missing» | 13:28:25 |
Grimmauld (any/all) | also its not attrsOf (listOf int), it'll be attrsOf utils.systemdUtils.unitOptions.unitOption | 13:30:05 |
Grimmauld (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 that | 13:31:38 |
Grimmauld (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 (any/all) | and the merge just returns bogus stuff | 13:38:14 |
Grimmauld (any/all) | i am probably just doing something dumb | 13:38:22 |
infinisil | Grimmauld (any/all) Ah, the last argument needs to be of the form [ { file = "a"; value = ...; } ... ] | 13:39:47 |
infinisil | It uses the file for error messages | 13:39:58 |
Grimmauld (any/all) | But i don't have any files, do i just "invent" files? | 13:40:10 |
infinisil | Yeah | 13:40:20 |
infinisil | You can also wrap it into a small helper function that uses lib.imap0 to generate indexed fake files | 13:40:52 |
infinisil | * You can also wrap it into a small helper function that uses lib.imap0 to generate indexed fake file names | 13:41:00 |
Grimmauld (any/all) | and can this even error? | 13:44:20 |
Grimmauld (any/all) | i guess inventing a file does work, ty :) | 13:44:20 |
Grimmauld (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 joined the room. | 15:32:23 |
| 1 Sep 2025 |
| Yusuf Raji joined the room. | 10:59:25 |
| 2 Sep 2025 |
| RichInOverdraft changed their profile picture. | 16:20:36 |
| 3 Sep 2025 |
| ghpzin joined the room. | 07:28:14 |
Moritz 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 |
Moritz 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 set a profile picture. | 12:04:16 |
| atagen changed their profile picture. | 12:04:40 |