Review shell scripts
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -20,16 +20,34 @@
|
||||
in
|
||||
''
|
||||
nix-develop() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: nix-develop <shell>"
|
||||
return 1
|
||||
local devshell=""
|
||||
|
||||
while getopts "s:" opt; do
|
||||
case $opt in
|
||||
s)
|
||||
devshell=$OPTARG
|
||||
;;
|
||||
*)
|
||||
echo "Usage: nix-develop [-s <devshell>]"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$devshell" ]]; then
|
||||
if [ ! -f flake.nix ]; then cp "${./template.nix}" flake.nix; fi
|
||||
nix develop -c "$SHELL"
|
||||
else
|
||||
nix develop self#"$devshell" -c "$SHELL"
|
||||
fi
|
||||
nix develop self#"$1" -c "$SHELL"
|
||||
}
|
||||
|
||||
_nix-develop_completion() {
|
||||
local shells=(${devShells})
|
||||
compadd -- $shells
|
||||
local options=(
|
||||
'-s[Dev shell from root flake]:shell:(${devShells})'
|
||||
)
|
||||
|
||||
_arguments -s $options
|
||||
}
|
||||
|
||||
compdef _nix-develop_completion nix-develop
|
||||
|
30
hosts/common/configs/user/console/nix-develop/template.nix
Normal file
30
hosts/common/configs/user/console/nix-develop/template.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs = {
|
||||
type = "github";
|
||||
owner = "karaolidis";
|
||||
repo = "nixpkgs";
|
||||
ref = "integration";
|
||||
};
|
||||
|
||||
flake-utils = {
|
||||
url = "github:numtide/flake-utils";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ nixpkgs, ... }@inputs:
|
||||
inputs.flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [ ];
|
||||
};
|
||||
|
||||
formatter = pkgs.nixfmt-rfc-style;
|
||||
}
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user