thelio76: add nxinit helper

This commit is contained in:
Alex 2024-11-23 18:27:15 -05:00
parent aa0873eeff
commit 6bbb9333cc
2 changed files with 50 additions and 0 deletions

View File

@ -4,6 +4,7 @@
enable = true;
bashrcExtra = ''
${builtins.readFile ./nxr.sh}
${builtins.readFile ./nxinit.sh}
eval "$(direnv hook bash)"
'';

View File

@ -0,0 +1,49 @@
# shellcheck disable=SC2148
function nxinit() {
set -u
if [ ! -f ".envrc" ]; then
cat >.envrc <<EOL
use flake
EOL
else
echo ".envrc already exists, ignoring..."
fi
if [ ! -f "flake.nix" ]; then
cat >flake.nix <<EOL
{
description = "Flake based shell for the current project";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
# your overlays here
];
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# your packages here
];
};
});
}
EOL
else
echo "flake.nix already exists, ignoring..."
fi
if ! grep -q .direnv .gitignore; then
echo ".direnv" >>.gitignore
fi
}