Add flake templates
lilyball opened this issue · 5 comments
Is your feature request related to a problem? Please describe.
I'm finally checking out Nix flakes now that Nix 2.4 is out, and there's a bunch of extra stuff to remember. flake-utils looks really handy for things like setting up a devShell
flake, but there's still annoying boilerplate there.
Describe the solution you'd like
It would be really handy if flake-utils could vend some templates for use with nix flake init
. In particular I would love a template for devShell
specifically that wraps shell.nix
. The NixOS Wiki page on Flakes suggests
{
description = "my project description";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let pkgs = nixpkgs.legacyPackages.${system}; in
{
devShell = import ./shell.nix { inherit pkgs; };
}
);
}
So having something like this as the template (perhaps with a better description though) would be very convenient.
I currently use flake-utils
for my development shells and propose the following as a template in addition to one by @lilyball.
This one does not wrap legacy nix-shell
environments and is a single self-contained file.
{
description = "...";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
packages = [
# packages go here, like this:
pkgs.zig
];
# environment variables go here, like this:
SOME_ENV_VAR = "42";
};
});
}
LGTM
Well I'm not the person who opened this issue. Maybe this should remain open until they acknowledge the solution.
For sure. I'll re-open if I hear an objection.