chore: add basic template and lib

This commit is contained in:
technofab 2024-03-06 10:23:25 +00:00
parent c39e29b568
commit 6d7653ff0c
8 changed files with 593 additions and 0 deletions

88
flake.nix Normal file
View file

@ -0,0 +1,88 @@
{
outputs = {
self,
flake-parts,
systems,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.devenv.flakeModule
];
systems = import systems;
flake = rec {
utils = import ./lib {
inherit (inputs.nixpkgs) lib;
inherit inputs;
};
# █▄░█ █ ▀▄▀ █░░ █▀▀ ▀█▀ █▀
# █░▀█ █ █░█ █▄▄ ██▄ ░█░ ▄█
nixlets = {
# <name> = utils.mkNixlet ./nixlets/<name>;
};
};
perSystem = {
pkgs,
system,
inputs',
...
}: {
formatter = pkgs.alejandra;
devenv.shells.default = {
containers = pkgs.lib.mkForce {};
packages = with pkgs; [
kube-linter
];
pre-commit = {
hooks = {
alejandra.enable = true;
};
};
};
# check if every nixlet successfully renders with default values
checks =
builtins.mapAttrs (
name: nixlet:
self.utils.renderNixlet {
inherit system nixlet;
project = name;
values = {};
}
)
self.nixlets;
# allow directly building every nixlet with default values
packages =
builtins.mapAttrs (
name: nixlet:
self.utils.renderNixlet {
inherit system nixlet;
project = name;
values = {};
}
)
self.nixlets;
};
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# flake & devenv related
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default-linux";
devenv = {
url = "github:cachix/devenv";
inputs.pre-commit-hooks.follows = "pre-commit-hooks";
};
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
kubenix = {
url = "github:hall/kubenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}