Added mkenv script

This commit is contained in:
Jan-Bulthuis 2025-02-15 16:28:38 +01:00
parent 7080ae11af
commit 187b23fd64
4 changed files with 84 additions and 1 deletions

View File

@ -22,6 +22,7 @@
./obsidian/default.nix ./obsidian/default.nix
./rofi/default.nix ./rofi/default.nix
./rofi/rofi-rbw.nix ./rofi/rofi-rbw.nix
./scripts/default.nix
./shell/default.nix ./shell/default.nix
./shell/bash.nix ./shell/bash.nix
./shell/fish.nix ./shell/fish.nix

View File

@ -0,0 +1,21 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.scripts;
in
{
options.modules.scripts.enable = mkEnableOption "scripts";
config = mkIf cfg.enable {
# home.packages = with pkgs; map (path: (writeShellScriptBin "${path}" (readFile path))) scripts;
home.packages = with pkgs; [
(writeShellScriptBin "mkenv" (readFile ./mkenv.sh))
];
};
}

View File

@ -0,0 +1,53 @@
setupEnv () {
echo "Setting up .envrc"
if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
insideGit;
else
outsideGit;
fi;
}
insideGit () {
echo "Inside of git environment"
cd $(git rev-parse --show-toplevel)
echo "Setting up inside $PWD"
echo "git add -f --intent-to-add flake.nix
use flake ." > .envrc
echo "Enabling environment"
direnv allow
setupFlake
}
outsideGit () {
echo "Outside of git environment"
echo "use flake . --impure" > .envrc
echo "Enabling environment"
direnv allow
setupFlake
}
setupFlake () {
if [ -e flake.nix ]; then
echo "flake.nix already exists."
return
fi;
echo "Setting up flake.nix"
echo "{
inputs.devenv.url = \"git+https://git.bulthuis.dev/Jan/dotfiles\";
outputs = { devenv, ... }: devenv.lib.mkShell { };
}" > flake.nix
}
echo "Creating dev environment"
if [ -e .envrc ]; then
echo ".envrc already exists."
setupFlake
else
setupEnv
fi;

View File

@ -68,7 +68,7 @@
# Gaming # Gaming
steam.enable = true; steam.enable = true;
modrinth.enable = true; modrinth.enable = true;
es-de.enable = true; es-de.enable = false;
retroarch.enable = true; retroarch.enable = true;
ryujinx.enable = true; ryujinx.enable = true;
@ -82,6 +82,13 @@
enable = true; enable = true;
user = "Jan-Bulthuis"; user = "Jan-Bulthuis";
email = "git@bulthuis.dev"; email = "git@bulthuis.dev";
# TODO: Move
ignores = [
".envrc"
".direnv"
"flake.nix"
"flake.lock"
];
}; };
btop.enable = true; btop.enable = true;
fish.enable = true; fish.enable = true;
@ -91,6 +98,7 @@
zathura.enable = true; zathura.enable = true;
eduvpn.enable = true; eduvpn.enable = true;
keyring.enable = true; keyring.enable = true;
scripts.enable = true;
# Development # Development
neovim.enable = true; neovim.enable = true;