2024-07-14 14:57:41 +02:00
|
|
|
{
|
|
|
|
description = "Portfolio rust configuration";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
|
|
flake-utils.lib.eachSystem flake-utils.lib.allSystems (system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
2024-07-14 20:35:22 +02:00
|
|
|
|
2024-07-14 22:54:31 +02:00
|
|
|
import_pub_gpg = pkgs.writeScriptBin "import_pub_gpg" ''
|
|
|
|
#!${pkgs.runtimeShell}
|
|
|
|
|
|
|
|
echo "Importing public key"
|
|
|
|
gpg --import <(curl https://gitea.mrdev023.fr/florian.richer.gpg)
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
2024-08-31 20:20:48 +02:00
|
|
|
decrypt_sops = pkgs.writeScriptBin "decrypt_sops" ''
|
2024-07-14 20:35:22 +02:00
|
|
|
#!${pkgs.runtimeShell}
|
|
|
|
|
|
|
|
echo "Decrypting vars file"
|
|
|
|
sops -d group_vars/all.enc.yml > group_vars/all.yml
|
|
|
|
|
2024-08-31 20:15:19 +02:00
|
|
|
echo "Decrypting inventory file"
|
2024-07-14 20:35:22 +02:00
|
|
|
sops -d work/inventory.enc.yml > work/inventory.yml
|
|
|
|
'';
|
|
|
|
|
|
|
|
clean_sops = pkgs.writeScriptBin "clean_sops" ''
|
|
|
|
#!${pkgs.runtimeShell}
|
|
|
|
|
2024-08-31 20:15:19 +02:00
|
|
|
echo "Deleting vars file"
|
|
|
|
rm group_vars/all.yml
|
2024-07-14 20:35:22 +02:00
|
|
|
|
2024-08-31 20:15:19 +02:00
|
|
|
echo "Deleting inventory file"
|
|
|
|
rm work/inventory.yml
|
|
|
|
'';
|
|
|
|
|
|
|
|
encrypt_sops = pkgs.writeScriptBin "encrypt_sops" ''
|
|
|
|
#!${pkgs.runtimeShell}
|
|
|
|
|
|
|
|
echo "Crypting vars file"
|
|
|
|
sops -e group_vars/all.yml > group_vars/all.enc.yml
|
|
|
|
|
|
|
|
echo "Crypting inventory file"
|
|
|
|
sops -e work/inventory.yml > work/inventory.enc.yml
|
2024-07-14 20:35:22 +02:00
|
|
|
'';
|
2024-07-14 14:57:41 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
devShells = {
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
buildInputs = [
|
|
|
|
pkgs.ansible
|
|
|
|
pkgs.sops
|
2024-07-14 22:54:31 +02:00
|
|
|
import_pub_gpg
|
2024-08-31 20:20:48 +02:00
|
|
|
decrypt_sops
|
2024-07-14 20:35:22 +02:00
|
|
|
clean_sops
|
2024-08-31 20:15:19 +02:00
|
|
|
encrypt_sops
|
2024-07-14 14:57:41 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|