1
0
Fork 0
mirror of https://github.com/zhaofengli/attic.git synced 2024-12-15 17:50:57 +00:00
attic/flake/devshells.nix

119 lines
2.5 KiB
Nix
Raw Normal View History

2024-08-30 16:32:10 +00:00
# Development shells
toplevel @ { lib, flake-parts-lib, ... }:
let
inherit (lib)
mkOption
types
;
inherit (flake-parts-lib)
mkPerSystemOption
;
in
{
options = {
perSystem = mkPerSystemOption {
options.attic.devshell = {
packageSets = mkOption {
type = types.attrsOf (types.listOf types.package);
default = {};
};
extraPackages = mkOption {
type = types.listOf types.package;
default = [];
};
extraArgs = mkOption {
type = types.attrsOf types.unspecified;
default = {};
};
};
};
};
config = {
perSystem = { self', pkgs, config, ... }: let
cfg = config.attic.devshell;
in {
attic.devshell.packageSets = with pkgs; {
2024-09-11 13:59:49 +00:00
rustc = lib.optionals (config.attic.toolchain == null) [
2024-08-30 16:32:10 +00:00
rustc
];
2024-08-30 16:32:10 +00:00
rust = [
2024-08-30 16:32:10 +00:00
cargo-expand
cargo-outdated
2024-08-30 16:32:10 +00:00
cargo-edit
tokio-console
];
linters = [
clippy
rustfmt
editorconfig-checker
];
utils = [
jq
just
];
ops = [
postgresql
sqlite-interactive
flyctl
skopeo
manifest-tool
] ++ lib.optionals pkgs.stdenv.isLinux [
2024-08-30 16:32:10 +00:00
wrangler
];
bench = [
wrk
] ++ lib.optionals pkgs.stdenv.isLinux [
linuxPackages.perf
];
wasm = [
llvmPackages_latest.bintools
worker-build wasm-pack wasm-bindgen-cli
];
};
devShells.default = pkgs.mkShell (lib.recursiveUpdate {
inputsFrom = [
self'.packages.attic
self'.packages.book
];
packages = lib.flatten (lib.attrValues cfg.packageSets);
env = {
ATTIC_DISTRIBUTOR = toplevel.config.attic.distributor;
RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library";
NIX_PATH = "nixpkgs=${pkgs.path}";
# See comment in `attic/build.rs`
NIX_INCLUDE_PATH = "${lib.getDev self'.packages.attic.passthru.nix}/include";
# Used by `just with-nix` to build/test with alternative Nix versions.
NIX_VERSIONS = config.attic.nix-versions.manifestFile;
2024-08-30 16:32:10 +00:00
};
} cfg.extraArgs);
devShells.demo = pkgs.mkShell {
packages = [ self'.packages.default ];
shellHook = ''
>&2 echo
>&2 echo '🚀 Run `atticd` to get started!'
>&2 echo
'';
};
};
};
}