Add flake template to nix-direnv
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -32,15 +32,34 @@
|
||||
nix-direnv() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "use flake" > .envrc
|
||||
|
||||
if [ ! -f flake.nix ]; then
|
||||
echo "Do you want to create an empty flake.nix? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
cp "${./template.nix}" flake.nix
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "use flake self#$1" > .envrc
|
||||
fi
|
||||
|
||||
if git rev-parse --is-inside-work-tree &> /dev/null && ! grep -q "^\.envrc$" .gitignore .git/info/exclude; then
|
||||
echo "Do you want to hide the .envrc file from git? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
echo ".envrc" >> .git/info/exclude
|
||||
if git rev-parse --is-inside-work-tree &> /dev/null; then
|
||||
if ! grep -q "^\.envrc$" .gitignore .git/info/exclude; then
|
||||
echo "Do you want to hide the .envrc file from git? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
echo ".envrc" >> .git/info/exclude
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f flake.nix ] && ! grep -q "^flake.nix$" .gitignore .git/info/exclude; then
|
||||
echo "Do you want to hide the flake.nix and flake.lock files from git? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
echo "flake.nix" >> .git/info/exclude
|
||||
echo "flake.lock" >> .git/info/exclude
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
30
hosts/common/configs/user/console/nix-direnv/template.nix
Normal file
30
hosts/common/configs/user/console/nix-direnv/template.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs = {
|
||||
type = "github";
|
||||
owner = "karaolidis";
|
||||
repo = "nixpkgs";
|
||||
ref = "integration";
|
||||
};
|
||||
|
||||
flake-utils = {
|
||||
url = "github:numtide/flake-utils";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ nixpkgs, ... }@inputs:
|
||||
inputs.flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [ ];
|
||||
};
|
||||
|
||||
formatter = pkgs.nixfmt-rfc-style;
|
||||
}
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user