diff --git a/hosts/common/configs/user/console/nix-direnv/default.nix b/hosts/common/configs/user/console/nix-direnv/default.nix index cc5c29b..e81695a 100644 --- a/hosts/common/configs/user/console/nix-direnv/default.nix +++ b/hosts/common/configs/user/console/nix-direnv/default.nix @@ -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 diff --git a/hosts/common/configs/user/console/nix-direnv/template.nix b/hosts/common/configs/user/console/nix-direnv/template.nix new file mode 100644 index 0000000..c72aebf --- /dev/null +++ b/hosts/common/configs/user/console/nix-direnv/template.nix @@ -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; + } + ); +}