Thanks to visit codestin.com
Credit goes to github.com

Skip to content

inherit with or #147

@orzklv

Description

@orzklv

When I use this kind of expression:

{
	description = i.description or "";
}

statix throws warning:

[W04] Warning: Assignment instead of inherit from
    ╭─[./lib/users.nix:11:7]
    │
 11 │       description = i.description or "";
    ·       ─────────────────┬────────────────
    ·                        ╰────────────────── This assignment is better written with inherit
────╯

When I got this warning for the first time, I thought I can use syntax like this:

{
	inherit (i) description or "";
}

However nix didn't evaluate throwing syntax error:

       error: attribute '""' missing
       at /nix/store/8ql1d9h3r74b0jmxk0kcxzswd9c9yh1x-source/lib/users.nix:11:34:
           10|       isNormalUser = true;
           11|       inherit (i) description or "";
             |                                  ^
           12|       # description = i.description or "";

which means, it's trying to lookup for key '""' inside i.

I have two guesses whether I'm missing some syntax knowledge in nix (which I'd love to and appreciate to know) or statix is judging based on first description = i.description ignoring or keyword next to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions