nixos-config/config/apps/bash/nxinit.sh

50 lines
1.0 KiB
Bash

# 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
}