nixos-config/flake.nix

47 lines
1.9 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
nixbsd.url = "github:nixos-bsd/nixbsd/main";
lix-module = {
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.92.0-3.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
bingosync.url = "github:rhelmot/bingosync";
blog-rhelmot-io.url = "git+https://git.lain.faith/rhelmot/blog.rhelmot.io";
blog-rhelmot-io.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, nixbsd, lix-module, bingosync, ... }@flakeInputs: let
sitesFiles = builtins.readDir ./sites;
sitesNames = builtins.filter (name: builtins.pathExists ./sites/${name}/configuration.nix) (builtins.attrNames sitesFiles);
systemTypes = {
nixos = nixpkgs.lib.nixosSystem;
nixbsd = nixbsd.lib.nixbsdSystem;
};
systemName = name: builtins.replaceStrings ["\n"] [""] (builtins.readFile ./sites/${name}/system);
nixosConfigurations = platform: builtins.listToAttrs (builtins.map (name: {
inherit name;
value = let evaluated = systemTypes.${systemName name} {
modules = [
./configuration.nix
./configuration-${systemName name}.nix
./sites/${name}/configuration.nix
{ nixpkgs.buildPlatform = platform; }
lix-module.nixosModules.default
bingosync.nixosModules.default
];
}; in {
inherit (evaluated) config options;
system = evaluated.config.system.build.toplevel;
deploy = import ./deploy.nix { inherit flakeInputs platform; site = name; };
};
}) sitesNames);
in {
packages = let
buildPlatforms = [ "x86_64-linux" "aarch64-linux" "x86_64-freebsd" "aarch64-freebsd" ];
toPackagesList = platform: { name = platform; value = let base = nixosConfigurations platform; in base // { nixosConfigurations = base; }; };
packagesList = builtins.map toPackagesList buildPlatforms;
in builtins.listToAttrs packagesList;
};
}