Skip to content
30 changes: 24 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 66 additions & 38 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,48 +1,76 @@
{
description = "devshell";
# To update all inputs:
# $ nix flake update --recreate-lock-file
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.systems.url = "github:nix-systems/default";

outputs = { self, nixpkgs, systems }:
let
eachSystem = nixpkgs.lib.genAttrs (import systems);
in
{
legacyPackages = eachSystem (system:
import self {
inherit system;
inputs = null;
nixpkgs = nixpkgs.legacyPackages.${system};
}
);

templates = rec {
toml = {
path = ./templates/toml;
description = "nix flake new my-project -t github:numtide/devshell";
};
flake-parts = {
path = ./templates/flake-parts;
description = "nix flake new my-project -t github:numtide/devshell#flake-parts";
# nix flake update --recreate-lock-file
inputs.nixpkgs.url = "github:NixOS/nixpkgs/efc960b6d6a6498c23868f4ba59fcb8bb51c9861";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point to a channel instead, to make it easier to bump nixpkgs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in bd708b4

inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
devshell = import ./. { nixpkgs = pkgs; };
in
rec {
packages = {
docs = pkgs.writeShellApplication {
name = "docs";
meta.description = ''Run mdBook server at http://localhost:3000'';
runtimeInputs = [ pkgs.mdbook ];
text = ''
cd docs
cp ${devshell.modules-docs.markdown} src/modules_schema.md
mdbook serve
'';
};
bench = pkgs.writeShellApplication {
name = "benchmark";
meta.description = ''Run benchmark'';
runtimeInputs = [ pkgs.hyperfine ];
text = ''
cd benchmark
hyperfine -w 3 \
'nix-instantiate ../shell.nix' \
'nix-instantiate ./devshell-nix.nix' \
'nix-instantiate ./devshell-toml.nix' \
'nix-instantiate ./nixpkgs-mkshell.nix'
'';
};
};
default = toml;
};

devShells = eachSystem (system: {
default = self.legacyPackages.${system}.fromTOML ./devshell.toml;
});
devShells.default = devshell.fromTOML ./devshell.toml;

apps.default = devShells.default.flakeApp;

apps = eachSystem (system: {
default = self.devShells.${system}.default.flakeApp;
});
checks =
with pkgs.lib;
pipe (import ./tests { inherit pkgs; }) [
(collect isDerivation)
(map (x: { name = x.name or x.pname; value = x; }))
listToAttrs
];

# Import this overlay into your instance of nixpkgs
overlays.default = import ./overlay.nix;
lib = {
importTOML = import ./nix/importTOML.nix;
formatter = pkgs.nixpkgs-fmt;
}
) // {
# Import this overlay into your instance of nixpkgs
overlays.default = import ./overlay.nix;

templates = rec {
toml = {
path = ./templates/toml;
description = "nix flake new my-project -t github:numtide/devshell";
};
flake-parts = {
path = ./templates/flake-parts;
description = "nix flake new my-project -t github:numtide/devshell#flake-parts";
};
flakeModule = ./flake-module.nix;
default = toml;
};

lib.importTOML = import ./nix/importTOML.nix;

flakeModule = ./flake-module.nix;
}
;
}