devshell
devshell copied to clipboard
Extra modules from other flakes
Is your feature request related to a problem? Please describe.
Currently it is possible to add modules from the extra/ directory using:
imports = ["locale"]
which corresponds to extra/locale.nix.
However, if I'd like to extend devshell with external flakes it seems not possible or not documented. Other than forking devshell and basing everything on that.
Also using Nix (in flakes) it is unclear how to refer to these module files.
Describe the solution you'd like
Would it be eventually possible to do something like:
imports = ["github:me/myflake#mydevshelmodule"]
It would be cool if it worked the same way as homeManagerModules and nixosModules in flakes:
{
inputs = { ... };
ouputs = ...
devshellModules = {
locale = import ./extra/locale.nix;
};
};
}
That way they are easily referred to from Nix in other flakes.
Describe alternatives you've considered
- Forking the project and adding modules to
extra/
in there :shrug: - Leaving my custom modules non-reusable. Adding them all to my personal devshell repository where I can do
imports = [ ./mymodule.nix ]
in Nix.
Example:
{
description = "virtual environments";
inputs.devshell.url = "github:numtide/devshell";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.dsf.url = "github:cruel-intentions/devshell-files";
inputs.gha.url = "github:cruel-intentions/gh-actions";
outputs = { self, flake-utils, devshell, nixpkgs, dsf, gha }:
flake-utils.lib.eachDefaultSystem (system: {
devShell = let pkgs = import nixpkgs { inherit system; overlays = [ devshell.overlay ]; }; in
pkgs.devshell.mkShell {
imports = [
"${dsf}/modules/files.nix" # create text files for you
"${dsf}/modules/yaml.nix" # use files to write yaml files from nix
"${gha}/gha/gh-actions.nix" # use yaml to create .github/workflows/gh-pages.yaml
# ... :-)
(pkgs.devshell.importTOML ./devshell.toml)
];
};
});
}
There is an external lib that help
{
description = "Dev Environment";
inputs.nixpkgs.url = "github:nixos/nixpkgs/22.05";
inputs.dsf.url = "github:cruel-intentions/devshell-files";
inputs.dsf.inputs.nixpkgs.follows = "nixpkgs";
inputs.gha.url = "github:cruel-intentions/gh-actions";
outputs = inputs: inputs.dsf.lib.shell inputs [
"hello" # import nix package
"${inputs.gha}/gh-actions.nix"
./project.nix # import nix module
(inputs.dsf.lib.importTOML ./devshell.toml)
];
}
See also #153
Looking at old issues, there is also #136