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, ... }:
let
nix-prepare = pkgs.writeShellScript "nix-prepare" ''
flake-dir = {flake, impure ? false}: pkgs.writeShellScript "nix-prepare" ''
run() {
local dir="$1"
echo "Preparing nix environment in $dir"
@ -16,14 +16,14 @@ let
git init
# Insert the nix flake
cp ${./flake-templates/c3c-flake.nix} flake.nix
cp ${flake} flake.nix
chmod 644 flake.nix
echo '/*' > .gitignore
echo '!/.gitignore' >> .gitignore
echo '!/flake.nix' >> .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 commit -m "Setup initial flake"
@ -38,7 +38,7 @@ let
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
run() {
local repo="$1"
@ -49,7 +49,7 @@ let
exit 1
fi
${nix-prepare} "$projectName"-nix
${flake-dir {inherit flake impure;}} "$projectName"-nix
git clone "$repo" "$projectName"-nix"/$projectName"
}
@ -59,8 +59,10 @@ let
in
{
programs.zsh.shellAliases = {
git-nix-clone = lib.mkDefault "${git-nix-clone}";
nix-prepare = lib.mkDefault "${nix-prepare}";
git-c3c-clone = lib.mkDefault "${git-flake-dir-clone { flake = ./flake-templates/c3c-flake.nix; impure = false;}}";
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;}}";
};
}