Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self parameter for eachSystem/eachDefaultSystem #78

Open
WizardUli opened this issue Aug 9, 2022 · 2 comments · May be fixed by #79
Open

self parameter for eachSystem/eachDefaultSystem #78

WizardUli opened this issue Aug 9, 2022 · 2 comments · May be fixed by #79
Labels
enhancement New feature or request

Comments

@WizardUli
Copy link

When you want to reference a package from another package, or a devShell, etc... inside eachSystem/eachDefaultSystem closure then you have to either use the pesky rec keyword which even does not work for all cases or you have to use self parameter from the flake itself like self.${system}.packages.abc which is unnecessarily repeating the system.

I propose adding a variant of eachSystem/eachDefaultSystem which could be used like this:

{
  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem2 (sself: system: {
      packages.abc = ...;

      devShells.default = pkgs.mkShell {
        packages = [
          sself.packages.abc # Instead of self.${system}.packages.abc;
        ];
      };
    });
}

Perhaps it could be made backward compatible similar to overrideAttrs (NixOS/nixpkgs#119942) so new variant of eachSystem may not be necessary.

@WizardUli WizardUli added the enhancement New feature or request label Aug 9, 2022
@zimbatm
Copy link
Member

zimbatm commented Aug 10, 2022

That's a good observation. As long as it doesn't break backwards compatibility, I don't mind extending the existing functions. Otherwise, it's probably best to introduce a new one (if you're sending a PR).

ilkecan added a commit to ilkecan/flake-utils that referenced this issue Sep 7, 2022
ilkecan added a commit to ilkecan/flake-utils that referenced this issue Sep 7, 2022
ilkecan added a commit to ilkecan/flake-utils that referenced this issue Sep 7, 2022
ilkecan added a commit to ilkecan/flake-utils that referenced this issue Sep 7, 2022
ilkecan added a commit to ilkecan/flake-utils that referenced this issue Sep 7, 2022
ilkecan added a commit to ilkecan/flake-utils that referenced this issue Sep 7, 2022
@ilkecan ilkecan linked a pull request Sep 7, 2022 that will close this issue
@nrdxp
Copy link

nrdxp commented Nov 15, 2022

fwiw, divnix/nosys does just what you are looking for. I did start #83 to maybe see if there was interest in bringing this functionality to live here.

ilkecan added a commit to ilkecan/flake-utils that referenced this issue Oct 24, 2023
ilkecan added a commit to ilkecan/flake-utils that referenced this issue Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants