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

50 lines
1002 B
Bash
Raw Normal View History

2024-11-23 23:27:15 +00:00
# shellcheck disable=SC2148
function nxinit() {
2024-11-24 02:13:41 +00:00
set -u
2024-11-23 23:27:15 +00:00
2024-11-24 02:13:41 +00:00
if [ ! -f ".envrc" ]; then
cat >.envrc <<EOL
2024-11-23 23:27:15 +00:00
use flake
EOL
2024-11-24 02:13:41 +00:00
else
echo ".envrc already exists, ignoring..."
fi
2024-11-23 23:27:15 +00:00
2024-11-24 02:13:41 +00:00
if [ ! -f "flake.nix" ]; then
cat >flake.nix <<EOL
2024-11-23 23:27:15 +00:00
{
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
2024-11-24 02:13:41 +00:00
else
echo "flake.nix already exists, ignoring..."
fi
2024-11-23 23:27:15 +00:00
2024-11-24 02:13:41 +00:00
if ! grep -q .direnv .gitignore; then
echo ".direnv" >>.gitignore
fi
2024-11-23 23:27:15 +00:00
}