Skip to content

Commit

Permalink
Add devenv option to not install git hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-q committed May 9, 2024
1 parent 3370d88 commit 240abf7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 40 deletions.
84 changes: 46 additions & 38 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -1,52 +1,60 @@
{ pkgs, lib, inputs, ... }:
{ pkgs, lib, inputs, config, ... }:
let
pkgs-stable = import inputs.nixpkgs-stable { system = pkgs.stdenv.system; };
cfg = config.hugr;
in
{
# https://devenv.sh/packages/
# on macos frameworks have to be explicitly specified
# otherwise a linker error ocurs on rust packages
packages = [
pkgs.just
pkgs.llvmPackages_16.libllvm
# cargo-llvm-cov is currently marked broken on nixpkgs unstable
pkgs-stable.cargo-llvm-cov
] ++ lib.optionals
pkgs.stdenv.isDarwin
(with pkgs.darwin.apple_sdk; [
frameworks.CoreServices
frameworks.CoreFoundation
# added for json schema validation tests
frameworks.SystemConfiguration
]);
options.hugr = {
installGitHooks = lib.mkEnableOption "installGitHooks" // { default = true; };
};

config = {
# https://devenv.sh/packages/
# on macos frameworks have to be explicitly specified
# otherwise a linker error ocurs on rust packages
packages = [
pkgs.just
pkgs.llvmPackages_16.libllvm
# cargo-llvm-cov is currently marked broken on nixpkgs unstable
pkgs-stable.cargo-llvm-cov
] ++ lib.optionals
pkgs.stdenv.isDarwin
(with pkgs.darwin.apple_sdk; [
frameworks.CoreServices
frameworks.CoreFoundation
# added for json schema validation tests
frameworks.SystemConfiguration
]);

# https://devenv.sh/scripts/
scripts.hello.exec = "echo Welcome to hugr dev shell!";
# https://devenv.sh/scripts/
scripts.hello.exec = "echo Welcome to hugr dev shell!";

enterShell = ''
hello
cargo --version
export LLVM_COV="${pkgs.llvmPackages_16.libllvm}/bin/llvm-cov"
export LLVM_PROFDATA="${pkgs.llvmPackages_16.libllvm}/bin/llvm-profdata"
enterShell = let
justArgs = if !cfg.installGitHooks then " git-hooks=false" else "";
in ''
hello
cargo --version
export LLVM_COV="${pkgs.llvmPackages_16.libllvm}/bin/llvm-cov"
export LLVM_PROFDATA="${pkgs.llvmPackages_16.libllvm}/bin/llvm-profdata"
just setup
'';
just setup${justArgs}
'';

languages.python = {
enable = true;
poetry = {
languages.python = {
enable = true;
activate.enable = true;
poetry = {
enable = true;
activate.enable = true;
};
};
};

# https://devenv.sh/languages/
# https://devenv.sh/reference/options/#languagesrustversion
languages.rust = {
channel = "stable";
enable = true;
components = [ "rustc" "cargo" "clippy" "rustfmt" "rust-analyzer" ];
# https://devenv.sh/languages/
# https://devenv.sh/reference/options/#languagesrustversion
languages.rust = {
channel = "stable";
enable = true;
components = [ "rustc" "cargo" "clippy" "rustfmt" "rust-analyzer" ];
};
};

# See full reference at https://devenv.sh/reference/options/
}
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ help:

# Prepare the environment for development, installing all the dependencies and
# setting up the pre-commit hooks.
setup:
setup git-hooks="true":
poetry install
poetry run pre-commit install -t pre-commit
{{ if git-hooks == "true" { "poetry run pre-commit install -t pre-commit" } else { "" } }}

# Run the pre-commit checks.
check:
Expand Down

0 comments on commit 240abf7

Please sign in to comment.