nixlets/flake.nix

198 lines
5.8 KiB
Nix
Raw Normal View History

2024-03-06 10:23:25 +00:00
{
outputs = {
self,
nixpkgs,
2024-03-06 10:23:25 +00:00
flake-parts,
systems,
...
} @ inputs: let
nixlet-lib = import ./lib {
inherit (nixpkgs) lib;
inherit (inputs) kubenix;
};
in
2024-03-06 10:23:25 +00:00
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.devenv.flakeModule
2024-03-09 15:32:47 +01:00
inputs.nix-gitlab-ci.flakeModule
2025-04-27 16:03:23 +02:00
inputs.nix-mkdocs.flakeModule
inputs.treefmt-nix.flakeModule
2024-03-06 10:23:25 +00:00
];
systems = import systems;
2024-05-08 17:09:17 +00:00
flake = {
nixlets = import ./nixlets {inherit nixlet-lib;};
2024-03-06 10:23:25 +00:00
};
perSystem = {
2024-05-08 17:09:17 +00:00
lib,
2024-03-06 10:23:25 +00:00
pkgs,
config,
2024-03-06 10:23:25 +00:00
system,
...
}: {
2024-03-09 15:32:47 +01:00
imports = [
./ci.nix
];
treefmt = {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
mdformat.enable = true;
};
2025-04-28 13:06:28 +02:00
settings.formatter.mdformat.command = let
pkg = pkgs.python3.withPackages (p: [
p.mdformat
p.mdformat-mkdocs
]);
in
lib.mkForce "${pkg}/bin/mdformat";
};
2024-03-06 10:23:25 +00:00
devenv.shells.default = {
containers = lib.mkForce {};
2024-03-06 10:23:25 +00:00
packages = with pkgs; [
kube-linter
];
pre-commit.hooks.treefmt = {
enable = true;
packageOverrides.treefmt = config.treefmt.build.wrapper;
2024-03-06 10:23:25 +00:00
};
};
2025-04-27 16:03:23 +02:00
doc = {
path = ./docs;
deps = pp: [pp.mkdocs-material (pp.callPackage inputs.mkdocs-material-umami {})];
config = {
site_name = "Nixlets";
repo_name = "TECHNOFAB/nixlets";
repo_url = "https://gitlab.com/TECHNOFAB/nixlets";
edit_uri = "edit/main/docs/";
theme = {
name = "material";
features = ["content.code.copy" "content.action.edit"];
2025-04-27 17:41:29 +02:00
icon.repo = "simple/gitlab";
logo = "images/logo.png";
favicon = "images/favicon.png";
2025-04-27 16:03:23 +02:00
palette = [
{
scheme = "default";
media = "(prefers-color-scheme: light)";
primary = "blue";
accent = "light blue";
toggle = {
icon = "material/brightness-7";
name = "Switch to dark mode";
};
}
{
scheme = "slate";
media = "(prefers-color-scheme: dark)";
primary = "blue";
accent = "light blue";
toggle = {
icon = "material/brightness-4";
name = "Switch to light mode";
};
}
];
};
plugins = ["search" "material-umami"];
nav = [
2025-04-28 13:06:28 +02:00
{"Introduction" = "index.md";}
{"Creating Nixlets" = "creation.md";}
{"Packaging" = "packaging.md";}
{"Usage" = "usage.md";}
{"Secrets" = "secrets.md";}
2025-04-27 16:03:23 +02:00
];
markdown_extensions = [
{
"pymdownx.highlight".pygments_lang_class = true;
}
"pymdownx.inlinehilite"
"pymdownx.snippets"
"pymdownx.superfences"
"fenced_code"
2025-04-28 13:06:28 +02:00
"admonition"
2025-04-27 16:03:23 +02:00
];
extra.analytics = {
provider = "umami";
site_id = "a4181010-317a-45e3-978c-5d07a93e0cd2";
src = "https://analytics.tf/umami";
feedback = {
title = "Was this page helpful?";
ratings = [
{
icon = "material/thumb-up-outline";
name = "This page is helpful";
data = "good";
note = "Thanks for your feedback!";
}
{
icon = "material/thumb-down-outline";
name = "This page could be improved";
data = "bad";
note = "Thanks for your feedback!";
}
];
};
};
};
};
2024-03-06 10:23:25 +00:00
# check if every nixlet successfully renders with default values
checks =
builtins.mapAttrs (
2024-05-08 17:09:17 +00:00
_: nixlet:
nixlet.render {
inherit system;
2024-03-06 10:23:25 +00:00
}
)
self.nixlets;
# allow directly building every nixlet with default values
packages =
builtins.mapAttrs (
2024-05-08 17:09:17 +00:00
_: nixlet:
nixlet.render {
inherit system;
2024-03-06 10:23:25 +00:00
}
)
self.nixlets;
2024-05-08 17:09:17 +00:00
apps.upload = {
type = "app";
program = pkgs.callPackage nixlet-lib.uploadNixletsToGitlab {
projectId = "55602785";
nixlets = lib.attrValues self.nixlets;
};
};
2024-03-06 10:23:25 +00:00
};
};
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.git-hooks.follows = "git-hooks";
2024-03-06 10:23:25 +00:00
};
git-hooks.url = "github:cachix/git-hooks.nix";
treefmt-nix.url = "github:numtide/treefmt-nix";
2025-04-27 16:03:08 +02:00
nix-gitlab-ci.url = "gitlab:TECHNOFAB/nix-gitlab-ci/feat/v2?dir=lib";
2025-04-27 16:03:23 +02:00
nix-mkdocs.url = "gitlab:TECHNOFAB/nixmkdocs?dir=lib";
mkdocs-material-umami.url = "gitlab:technofab/mkdocs-material-umami";
2024-03-06 10:23:25 +00:00
kubenix = {
2024-03-20 15:48:21 +01:00
url = "github:TECHNOFAB11/kubenix";
2024-03-06 10:23:25 +00:00
inputs.nixpkgs.follows = "nixpkgs";
};
};
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
2024-03-06 10:23:25 +00:00
};
}