Mic92 / nix-fast-build

Combine the power of nix-eval-jobs with nix-output-monitor to speed-up your evaluation and building process.
MIT License
226 stars 10 forks source link

How do I add checks to my normal NixOS flake #75

Closed Verantor closed 3 weeks ago

Verantor commented 3 weeks ago

How do I add checks to my normal NixOS flake. I have looked at your config and i cant wrap my head around on how to add checks to my flake.nix

I have attached my flake that i use right now:

{
  description = "cornflakes";

  inputs = {
   #..... (removed for better overview)
  };

  outputs =
    { self
    , nixpkgs
    , ...
    } @ inputs:
    let
      inherit (self) outputs;
      core = ./system/core;

     # some imports and declatation of modules (removed for better overview)
      shared = [ core ];

      home-manager = {
        useUserPackages = true;
        useGlobalPkgs = true;
        extraSpecialArgs = {
          inherit inputs;
          inherit self;
          inherit outputs;
        };
        sharedModules = [
          {

          }
        ];

        users.ver = {
          imports = [ ./home ];
          _module.args.theme = import ./theme;
        };
      };
    in
    #rec for recursion
    {
      overlays = import ./system/overlays.nix { inherit inputs; };

      nixosConfigurations = {
        main = nixpkgs.lib.nixosSystem {
          system = "x86_64-linux";

          modules =
            [
              { networking.hostName = "main"; }

              ./hosts/main

              #import the declared modules

              { inherit home-manager; } #
            ]
            ++ shared;
          specialArgs = { inherit inputs outputs; };
        };

      };
    };
}
Mic92 commented 3 weeks ago

Something like this:

{
      # ...
      checks = nixpkgs.lib.genAttrs [ "x86_64-linux" ] (
        system:
        let
          inherit (nixpkgs) lib;
          nixosMachines = lib.mapAttrs' (
            name: config: lib.nameValuePair "nixos-${name}" config.config.system.build.toplevel
          ) ((lib.filterAttrs (_: config: config.pkgs.system == system)) self.nixosConfigurations);
        in
        nixosMachines
      );
}