From a430b89bd6e03f6911a71100be4ce5b5f04670dc Mon Sep 17 00:00:00 2001 From: maxstrb Date: Fri, 26 Sep 2025 17:05:32 +0200 Subject: [PATCH] non important commit --- home/laptop/home.nix | 1 + home/main/home.nix | 1 + .../modules/create-project/create-project.nix | 67 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 home/modules/create-project/create-project.nix diff --git a/home/laptop/home.nix b/home/laptop/home.nix index 8a0795a..68ca4ce 100644 --- a/home/laptop/home.nix +++ b/home/laptop/home.nix @@ -20,5 +20,6 @@ ../modules/communication.nix ../modules/rice.nix ../modules/shells.nix + ../modules/create-project/create-project.nix ]; } diff --git a/home/main/home.nix b/home/main/home.nix index 094eb3b..1742905 100644 --- a/home/main/home.nix +++ b/home/main/home.nix @@ -17,5 +17,6 @@ ../modules/communication.nix ../modules/rice.nix ../modules/shells.nix + ../modules/create-project/create-project.nix ]; } diff --git a/home/modules/create-project/create-project.nix b/home/modules/create-project/create-project.nix new file mode 100644 index 0000000..44a596b --- /dev/null +++ b/home/modules/create-project/create-project.nix @@ -0,0 +1,67 @@ +{pkgs, ...}: { + home.packages = [ + (pkgs.writeScriptBin "create-project" + /* + nu + */ + '' + #!${pkgs.nushell}/bin/nu + + def main [ + name?: string + type?: string + --local (-l) + ] { + + if $name == null or $type == null { + print "Usage: create-project [Options: -l]" + exit 1 + } + + if ($name | str contains "/") or ($name | str contains ".") { + print "This is not a valid name for a project" + exit 1 + } + + if ($type | str contains "/") or ($type | str contains ".") { + print "This is not a valid project type" + exit 1 + } + + if ($"~/.nix-config/home/modules/create-project/project-blueprints/($type)" | path type) != "dir" { + print "This project type doesn't exist" + exit 1 + } + + mkdir $name + cd $name + + cp $"~/.nix-config/home/modules/create-project/project-blueprints/($type)/*" . + + if ($"./init.sh" | path type) == "file" { + bash "init.sh" + rm "init.sh" + } + + if $local { + exit 0 + } + + print "Enter server password" + let pass = (input) + + ssh admin@silvers.fun $"sudo -S -u git bash -c \"git init --bare ~/($name).git\" <<< ($pass)" <<< $pass + + git init + git add . + git commit -m "Project setup" + git $"remote add origin git@silvers.fun:($name).git" + git push origin main + + print "You are all done" + + exit 0 + } + '') + ]; +}