nixos-wiki-infra/flake.nix

74 lines
2.4 KiB
Nix
Raw Normal View History

2023-05-10 21:05:10 +02:00
{
description = "Dependencies to deploy a nixos-wiki";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
2023-05-10 21:05:10 +02:00
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
2023-05-14 18:18:49 +02:00
2023-05-14 20:41:19 +02:00
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
2023-05-14 18:18:49 +02:00
srvos.url = "github:numtide/srvos";
srvos.inputs.nixpkgs.follows = "nixpkgs";
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
sops-nix.inputs.nixpkgs-stable.follows = "";
2023-05-10 21:05:10 +02:00
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } ({ self, lib, ... }: {
systems = [
"aarch64-linux"
"x86_64-linux"
"riscv64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
2023-05-10 21:05:10 +02:00
imports = [
inputs.treefmt-nix.flakeModule
2023-05-14 18:43:08 +02:00
./targets/flake-module.nix
./modules/flake-module.nix
2023-11-19 09:23:50 +01:00
./checks/flake-module.nix
2023-05-10 21:05:10 +02:00
];
perSystem = { config, self', system, pkgs, ... }: {
2023-05-10 21:05:10 +02:00
treefmt = {
projectRootFile = "flake.nix";
2023-10-24 17:34:54 +02:00
programs.hclfmt.enable = true;
2023-05-10 21:05:10 +02:00
programs.nixpkgs-fmt.enable = true;
};
2023-10-24 17:34:54 +02:00
packages.default =
pkgs.mkShell {
2024-02-09 11:54:32 +01:00
packages =
let
2024-02-12 11:02:51 +01:00
convert2Tofu = provider: provider.override (prev: {
homepage = builtins.replaceStrings [ "registry.terraform.io/providers" ] [ "registry.opentofu.org" ] prev.homepage;
});
2024-02-09 11:54:32 +01:00
in
[
pkgs.bashInteractive
pkgs.sops
2024-02-12 11:02:51 +01:00
(pkgs.opentofu.withPlugins (p: builtins.map convert2Tofu [
2024-02-09 11:54:32 +01:00
p.hcloud
p.null
p.external
p.local
2024-02-12 11:02:51 +01:00
]))
2024-02-09 11:54:32 +01:00
];
2023-10-24 17:34:54 +02:00
};
checks =
let
nixosMachines = lib.mapAttrs' (name: config: lib.nameValuePair "nixos-${name}" config.config.system.build.toplevel) ((lib.filterAttrs (_: config: config.pkgs.system == system)) self.nixosConfigurations);
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages;
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
in
nixosMachines // packages // devShells;
2023-05-10 21:05:10 +02:00
};
});
}