Update nix init scripts

This commit is contained in:
Lukas Cech 2025-01-21 17:36:23 +01:00
parent 367e7ff45c
commit 802eba9819
3 changed files with 51 additions and 7 deletions

View File

@ -0,0 +1,21 @@
{
inputs = {
nix.url = "git+ssh://git@git.investbay.dev/devops/nix?branch=main";
};
outputs = { self, nix }: {
formatter = nix.formatter;
devShells = nix.lib.forAllSystems (pkgs: {
default = pkgs.devshell.mkShell {
name = "investbay";
packages = with pkgs; [
];
commands = [];
};
});
};
}

View File

@ -0,0 +1,21 @@
{
inputs = {
nix.url = "git+ssh://git@bitbucket.org/yourpass/nix";
};
outputs = { self, nix }: {
formatter = nix.formatter;
devShells = nix.lib.forAllSystems (pkgs: {
default = pkgs.devshell.mkShell {
name = "yp";
packages = with pkgs; [
];
commands = [];
};
});
};
}

View File

@ -1,6 +1,6 @@
{ lib, pkgs, ... }: { lib, pkgs, ... }:
let let
nix-prepare = pkgs.writeShellScript "nix-prepare" '' flake-dir = {flake, impure ? false}: pkgs.writeShellScript "nix-prepare" ''
run() { run() {
local dir="$1" local dir="$1"
echo "Preparing nix environment in $dir" echo "Preparing nix environment in $dir"
@ -16,14 +16,14 @@ let
git init git init
# Insert the nix flake # Insert the nix flake
cp ${./flake-templates/c3c-flake.nix} flake.nix cp ${flake} flake.nix
chmod 644 flake.nix chmod 644 flake.nix
echo '/*' > .gitignore echo '/*' > .gitignore
echo '!/.gitignore' >> .gitignore echo '!/.gitignore' >> .gitignore
echo '!/flake.nix' >> .gitignore echo '!/flake.nix' >> .gitignore
echo '!/flake.lock' >> .gitignore echo '!/flake.lock' >> .gitignore
echo 'use flake . --impure' > .envrc echo 'use flake .${(if impure then " --impure" else "")}' > .envrc
git add flake.nix .gitignore git add flake.nix .gitignore
git commit -m "Setup initial flake" git commit -m "Setup initial flake"
@ -38,7 +38,7 @@ let
run "$@" run "$@"
''; '';
git-nix-clone = pkgs.writeShellScript "git-nix-clone" '' git-flake-dir-clone = { flake, impure? false}: pkgs.writeShellScript "git-nix-clone" ''
# Input is a git repository such as git@github.com:group/project-name.git # Input is a git repository such as git@github.com:group/project-name.git
run() { run() {
local repo="$1" local repo="$1"
@ -49,7 +49,7 @@ let
exit 1 exit 1
fi fi
${nix-prepare} "$projectName"-nix ${flake-dir {inherit flake impure;}} "$projectName"-nix
git clone "$repo" "$projectName"-nix"/$projectName" git clone "$repo" "$projectName"-nix"/$projectName"
} }
@ -59,8 +59,10 @@ let
in in
{ {
programs.zsh.shellAliases = { programs.zsh.shellAliases = {
git-nix-clone = lib.mkDefault "${git-nix-clone}"; git-c3c-clone = lib.mkDefault "${git-flake-dir-clone { flake = ./flake-templates/c3c-flake.nix; impure = false;}}";
nix-prepare = lib.mkDefault "${nix-prepare}"; flake-dir-c3c = lib.mkDefault "${flake-dir { flake = ./flake-templates/c3c-flake.nix; impure = false;}}";
flake-dir-yp = lib.mkDefault "${flake-dir { flake = ./flake-templates/yp-flake.nix; impure = false;}}";
flake-dir-investbay = lib.mkDefault "${flake-dir { flake = ./flake-templates/investbay-flake.nix; impure = false;}}";
}; };
} }