Wanted to know if this code is alright

{
  description = "Nixos config flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs,home-manager, ... }@inputs: 
    let 
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in
    {
      nixosConfigurations.default = nixpkgs.lib.nixosSystem {
        system = system;
        specialArgs = {
           home-manager= home-manager;
           pkgs = pkgs;  
        };
        modules = [
          ./hosts/default/configuration.nix
          home-manager.nixosModules.default
        ];
      };
    };
}
1 Like

Don’t pass pkgs or system in

Nothing hits me as being particularly wrong personally. I have a few nitpicks, though.

Both self and inputs are unused, so you may omit them, like so:

outputs = { nixpkgs, home-manager, ...}:


This can be simplified a bit:

        specialArgs = {
           inherit home-manager pkgs;
        };

I don’t think you need to pass pkgs into specialArgs, you should be able to drop that.

        specialArgs = {
           inherit home-manager;
        };

Other than that, the only other nitpick I can think of is that the formatting appears to be a little inconsistent. If you are a fan of autoformatting, you can use nixfmt (available as nixfmt-rfc-style in Nixpkgs I believe.) It can be integrated into your editor using either a language server like nixd.

1 Like