-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
689d099
commit 742d7b0
Showing
7 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
use flake --impure | ||
use flake . --impure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ MODULE.bazel.lock | |
trivy-results.sarif | ||
Pulumi.dev.yaml | ||
lre.bazelrc | ||
nixos.bazelrc | ||
rust-project.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
lib, | ||
flake-parts-lib, | ||
... | ||
}: { | ||
options = { | ||
perSystem = flake-parts-lib.mkPerSystemOption ( | ||
{ | ||
config, | ||
options, | ||
pkgs, | ||
... | ||
}: let | ||
cfg = config.nixos; | ||
in { | ||
options = { | ||
nixos = { | ||
pkgs = lib.mkOption { | ||
type = lib.types.uniq (lib.types.lazyAttrsOf (lib.types.raw or lib.types.unspecified)); | ||
description = "Nixpkgs to use."; | ||
default = pkgs; | ||
defaultText = lib.literalMD "`pkgs` (module argument)"; | ||
}; | ||
settings = lib.mkOption { | ||
type = lib.types.submoduleWith { | ||
modules = [./modules/nixos.nix]; | ||
specialArgs = {inherit (cfg) pkgs;}; | ||
}; | ||
default = {}; | ||
description = "Configuration for Bazel on NixOS."; | ||
}; | ||
installationScript = lib.mkOption { | ||
type = lib.types.str; | ||
description = "Create nixos.bazelrc."; | ||
default = cfg.settings.installationScript; | ||
defaultText = lib.literalMD "bazelrc content"; | ||
readOnly = true; | ||
}; | ||
}; | ||
}; | ||
} | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
config, | ||
lib, | ||
pkgs, | ||
... | ||
}: let | ||
pathString = builtins.concatStringsSep ":" config.path; | ||
bazelrc = pkgs.writeText "nixos.bazelrc" '' | ||
build --action_env=PATH=${pathString} | ||
build --host_action_env=PATH=${pathString} | ||
''; | ||
in { | ||
options = { | ||
installationScript = lib.mkOption { | ||
type = lib.types.str; | ||
description = "A bash snippet which creates a nixos.bazelrc file in the | ||
repository."; | ||
}; | ||
path = lib.mkOption { | ||
type = lib.types.listOf lib.types.str; | ||
default = []; | ||
description = "List of paths to include in the Bazel environment."; | ||
}; | ||
}; | ||
config = { | ||
installationScript = '' | ||
if ! type -t git >/dev/null; then | ||
# In pure shells | ||
echo 1>&2 "WARNING: nixos: git command not found; skipping installation." | ||
elif ! ${pkgs.git}/bin/git rev-parse --git-dir &> /dev/null; then | ||
echo 1>&2 "WARNING: nixos: .git not found; skipping installation." | ||
else | ||
GIT_WC=`${pkgs.git}/bin/git rev-parse --show-toplevel` | ||
# These update procedures compare before they write, to avoid | ||
# filesystem churn. This improves performance with watch tools like | ||
# lorri and prevents installation loops by lorri. | ||
if ! readlink "''${GIT_WC}/nixos.bazelrc" >/dev/null \ | ||
|| [[ $(readlink "''${GIT_WC}/nixos.bazelrc") != ${bazelrc} ]]; then | ||
echo 1>&2 "nixos: updating $PWD repository" | ||
[ -L nixos.bazelrc ] && unlink nixos.bazelrc | ||
if [ -e "''${GIT_WC}/nixos.bazelrc" ]; then | ||
echo 1>&2 "nixos: WARNING: Refusing to install because of pre-existing nixos.bazelrc" | ||
echo 1>&2 " Remove the nixos.bazelrc file and add nixos.bazelrc to .gitignore." | ||
else | ||
ln -fs ${bazelrc} "''${GIT_WC}/nixos.bazelrc" | ||
fi | ||
fi | ||
fi | ||
''; | ||
}; | ||
} |