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

How to add parameter to devenv.nix? #1614

Open
tennox opened this issue Nov 25, 2024 · 2 comments
Open

How to add parameter to devenv.nix? #1614

tennox opened this issue Nov 25, 2024 · 2 comments
Labels
question Further information is requested

Comments

@tennox
Copy link
Contributor

tennox commented Nov 25, 2024

I like to use a nixpkgs channel for most packages, but for some, I want the latest version, so I've added an extra input.
Now I'd like to have that available in devenv.nix as:

{ pkgs, pkgs-latest, ... }:

When I used to import the file manually I could do it:

let
    pkgs = nixpkgs.legacyPackages.${system};
    pkgs-latest = inputs.nixpkgs-unstable.legacyPackages.${system};
in {
    devenv.shells.default = (import ./devenv.nix { inherit pkgs pkgs-latest inputs config; });

But recently I needed to access config.env.DEVENV_ROOT so I had to change it to:

devenv.shells.default = {
  imports = [ ./devenv.nix ];
};

Which I guess is better anyways, but now I don't know how to get the pkgs-latest passed into there 🤔

@tennox tennox added the question Further information is requested label Nov 25, 2024
@tennox
Copy link
Contributor Author

tennox commented Nov 25, 2024

I'm in a flake with flake-parts, and tried some things, but not successfully so (see the commented parts):

      imports = [
        inputs.devenv.flakeModule
        ({ lib, config, ... }: {
          config = {
            # devenv.modules = [
            #   ({ inputs', ... }: { pkgs-latest = inputs'.nixpkgs-unstable.legacyPackages; })
            # ];
          };
        })
      ];
      perSystem = { config, self', inputs', pkgs, system, ... }: # perSystem docs: https://flake.parts/module-arguments.html#persystem-module-parameters
        let
          pkgs = nixpkgs.legacyPackages.${system};
          latest = inputs'.nixpkgs-unstable.legacyPackages;
        in
        {
          # devenv.shells.default = (import ./devenv.nix { inherit pkgs latest inputs config; });
          devenv.shells.default = {
            imports = [
              # ({ config, ... }: { config.pkgs-latest = inputs'.nixpkgs-unstable.legacyPackages; })
              ./devenv.nix
            ];
          };
        };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants