nixos-config/flake.nix

105 lines
2.5 KiB
Nix
Raw Normal View History

2024-10-28 09:51:44 +00:00
{
description = "Lottes nix configuration";
2022-01-14 09:19:01 +00:00
2022-03-05 20:39:49 +00:00
inputs = {
2024-10-28 09:56:58 +00:00
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
2024-10-28 09:51:44 +00:00
nixpkgs.url = "github:nixos/nixpkgs";
2024-10-28 13:58:23 +00:00
riscv-overlay = {
url = "github:DarkKirb/riscv-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-03-05 20:39:49 +00:00
};
2022-01-14 09:19:01 +00:00
2022-06-12 15:39:15 +00:00
outputs = {
self,
nixpkgs,
2024-10-28 10:28:35 +00:00
...
2024-10-28 09:51:44 +00:00
} @ inputs': let
inputs =
inputs'
// {
nixos-config = self;
inherit inputs;
};
2024-10-28 13:58:23 +00:00
pkgsFor = system: let
inputs' =
inputs
// {
inherit system;
2024-10-28 14:44:39 +00:00
inputs = inputs';
2024-10-28 13:58:23 +00:00
};
in
2024-10-28 09:51:44 +00:00
import nixpkgs {
inherit system;
2024-10-28 13:58:23 +00:00
overlays =
[
(_: _:
inputs'
// {
inputs = inputs';
})
]
++ (
if system == "riscv64-linux"
then [
inputs.riscv-overlay.overlays.default
]
else []
);
};
2024-10-28 09:51:44 +00:00
in {
checks.x86_64-linux = nixpkgs.lib.listToAttrs (map (testName: {
name = testName;
value = (pkgsFor "x86_64-linux").callPackage ./tests/${testName}.nix {};
}) ["containers-default"]);
nixosModules = {
containers = import ./modules/containers/default.nix;
2024-10-28 13:58:23 +00:00
default = import ./modules/default.nix;
2024-10-28 09:51:44 +00:00
};
nixosContainers = with nixpkgs.lib; let
containerNames = [
"default"
];
2024-10-28 13:58:23 +00:00
containerArches = ["x86_64-linux" "aarch64-linux" "riscv64-linux"];
2024-10-28 09:51:44 +00:00
containers = listToAttrs (flatten (map (system: let
pkgs = pkgsFor system;
in
map (container: {
name = "container-${container}-${system}";
value = pkgs.callPackage ./containers/${container}-configuration.nix {};
})
containerNames)
containerArches));
2024-06-17 19:11:14 +00:00
in
2024-10-28 09:51:44 +00:00
containers;
nixosConfigurations = with nixpkgs.lib; let
2024-10-28 13:58:23 +00:00
mkSystem = args: let
inputs' = inputs // {inherit (args) system;};
in
2024-10-28 09:51:44 +00:00
nixosSystem (args
// {
2022-06-12 15:39:15 +00:00
specialArgs =
2024-10-28 09:51:44 +00:00
args.specialArgs
or {}
2024-10-28 13:58:23 +00:00
// inputs';
2024-10-28 09:51:44 +00:00
});
containers = mapAttrs (_: container:
mkSystem {
inherit (container) system;
modules = [
container.config
];
2022-01-14 09:19:01 +00:00
})
2024-10-28 09:51:44 +00:00
self.nixosContainers;
in
containers;
2024-10-28 09:56:58 +00:00
hydraJobs = {
2024-10-28 13:27:27 +00:00
inherit (self) checks;
nixosConfigurations = nixpkgs.lib.mapAttrs (_: v: v.config.system.build.toplevel) self.nixosConfigurations;
2024-10-28 09:56:58 +00:00
};
2022-06-12 15:39:15 +00:00
};
2022-01-14 09:19:01 +00:00
}