fhs envrc

This commit is contained in:
Peder Bergebakken Sundt 2025-03-20 13:48:34 +01:00
parent bbf0624868
commit b95e1eb37f
3 changed files with 31 additions and 18 deletions

18
.envrc

@ -44,14 +44,18 @@ if [[ ! -s .direnv/pull-date || "$now" != "$(cat .direnv/pull-date)" ]]; then
fi fi
# source env # source env
if [[ ! -f .remote.toml ]]; then flake_shell=.#envrc
use flake .#envrc-local if [[ -f .remote.toml ]]; then
else flake_shell+=-remotes
use flake .#envrc-remote
printf "\n"
just motd
printf "\n"
fi fi
if [[ ! -f /run/current-system/nixos-version ]]; then
flake_shell+=-fhs
fi
use flake "$flake_shell"
printf "\n"
just motd
printf "\n"
unset -f git unset -f git

@ -1,6 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
export HOST_SHELL="$(command -v "$SHELL")" export HOST_SHELL="$(command -v "$SHELL")"
export IS_REMOTE_ENV=1 export IS_REMOTE_ENV=1
eval "$(nix print-dev-env .#remoteenv)"
flake_shell=.#remoteenv
if [[ ! -f /run/current-system/nixos-version ]]; then
flake_shell+=-fhs
fi
eval "$(nix print-dev-env "$flake_shell")"
unset flake_shell
echo Entered "$(hostname --fqdn)" echo Entered "$(hostname --fqdn)"
df -h /nix/store df -h /nix/store

@ -451,14 +451,14 @@
#}); #});
devShells = forAllSystems ({ pkgs, system, ... }: let devShells = forAllSystems ({ pkgs, system, ... }: let
mkShell = packages: pkgs.mkShellNoCC { inherit packages; }; mkShell = {...}@args: packages: pkgs.mkShellNoCC (args // { packages = (args.packages or []) ++ packages; });
#mkShell'= packages: pkgs.mkShellNoCC { #mkShell'= {...}@args: packages: pkgs.mkShellNoCC (args // {
# inherit (self.checks.${system}.pre-commit-check) shellHook; # inherit (self.checks.${system}.pre-commit-check) shellHook;
# packages = packages ++ self.checks.${system}.pre-commit-check.enabledPackages; # packages = (args.packages or []) ++ packages ++ self.checks.${system}.pre-commit-check.enabledPackages;
#}; #});
inherit (inputs-edge.system-manager-edge.packages.${system}) system-manager;
envrc-pkgs = [ envrc-pkgs = [
self.packages.${system}.nixos-rebuild-nom self.packages.${system}.nixos-rebuild-nom
inputs-edge.system-manager-edge.packages.${system}.system-manager
pkgs.home-manager pkgs.home-manager
pkgs.nix-output-monitor pkgs.nix-output-monitor
pkgs.cachix pkgs.cachix
@ -469,21 +469,23 @@
pkgs.gum pkgs.gum
pkgs.mprocs pkgs.mprocs
]; ];
in { in rec {
envrc-local = mkShell envrc-pkgs; envrc = mkShell { } envrc-pkgs;
envrc-remote = mkShell (envrc-pkgs ++ [ envrc-remotes = mkShell { } (envrc-pkgs ++ [
pkgs.remote-exec pkgs.remote-exec
pkgs.yq pkgs.yq
pkgs.rsync pkgs.rsync
]); ]);
remoteenv = mkShell [ remoteenv = mkShell { } [
self.packages.${system}.nixos-rebuild-nom self.packages.${system}.nixos-rebuild-nom
inputs-edge.system-manager-edge.packages.${system}.system-manager
pkgs.age pkgs.age
pkgs.ssh-to-age pkgs.ssh-to-age
pkgs.just pkgs.just
pkgs.gum pkgs.gum
]; ];
envrc-fhs = mkShell { inheritFrom = [ envrc ]; } [ system-manager ];
envrc-remotes-fhs = mkShell { inheritFrom = [ envrc-remotes ]; } [ system-manager ];
remoteenv-fhs = mkShell { inheritFrom = [ remoteenv ]; } [ system-manager ];
}); });
}; };