pinwheel: Add skal to handle nix develop shells
This commit is contained in:
@@ -75,6 +75,10 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
mod = {
|
mod = {
|
||||||
|
skal = {
|
||||||
|
path = "/home/alex/code/own/skal";
|
||||||
|
};
|
||||||
|
|
||||||
nix-index.enable = false;
|
nix-index.enable = false;
|
||||||
greetd.enable = true;
|
greetd.enable = true;
|
||||||
hyprland.enable = true;
|
hyprland.enable = true;
|
||||||
|
|||||||
55
hosts/pinwheel/modules/skal/default.nix
Normal file
55
hosts/pinwheel/modules/skal/default.nix
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
{ pkgs, lib, config, ... }:
|
||||||
|
let
|
||||||
|
skalPath = config.mod.skal.path;
|
||||||
|
|
||||||
|
skal =
|
||||||
|
if skalPath == "" then
|
||||||
|
throw "'skal.path' cannot be empty"
|
||||||
|
else
|
||||||
|
pkgs.writeShellScriptBin "skal" ''
|
||||||
|
URL=`git config --get remote.origin.url`
|
||||||
|
GITHOST=`echo $URL | sed -e s/.*@// | sed -e s/:.*//`
|
||||||
|
GITPATH=`echo $URL | sed -e s/.*:// | sed -e s/.git$//`
|
||||||
|
|
||||||
|
FLAKE_DIR="${skalPath}/$GITHOST/$GITPATH"
|
||||||
|
|
||||||
|
if [ "$1" == "create" ]; then
|
||||||
|
if [ ! -d "$FLAKE_DIR" ]; then
|
||||||
|
echo Creating flake "$FLAKE_DIR"
|
||||||
|
mkdir -p "$FLAKE_DIR"
|
||||||
|
FLAKE="$FLAKE_DIR"/flake.nix
|
||||||
|
cp ${./flake-template.nix} "$FLAKE"
|
||||||
|
chmod 700 "$FLAKE"
|
||||||
|
${pkgs.vim}/bin/vim "$FLAKE"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo Flake already exist
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $FLAKE_DIR ]; then
|
||||||
|
echo No flake exist for "$FLAKE_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Using "$FLAKE_DIR"
|
||||||
|
nix develop $FLAKE_DIR $*
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
mod.skal = {
|
||||||
|
path = lib.mkOption {
|
||||||
|
description = "path to where all flake.nix reside";
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
home-manager.users.alex = {
|
||||||
|
home.packages = [ skal ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
18
hosts/pinwheel/modules/skal/flake-template.nix
Normal file
18
hosts/pinwheel/modules/skal/flake-template.nix
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
description = "";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { nixpkgs, ... }:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShells."${system}".default = pkgs.mkShell {
|
||||||
|
packages = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user