Custom derivation doesn't seem to get included in flake based configuration

Hey, I’m pretty new to NIX and have got the following, basic, flake-based configuration going which works good. However I’m trying to include a custom derivation into it, that gets built to be available when rebuilding the system with nixos-rebuild, but it doesn’t seem to work. The custom derivation file seems to get totally ignored…


  description = "A very basic flake";

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

  outputs = inputs @ { self, nixpkgs, home-manager, ... }: {
    nixosConfigurations = {
      nixos = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        specialArgs = {inherit inputs;};
        modules = [

    default.x86_64-linux = home-manager.default.x86_64-linux;
    homeConfigurations = {
      "myhost" = home-manager.lib.homeManagerConfiguration {
        pkgs = import nixpkgs {
          system = "x86_64-linux";
          config.allowUnfree = true;
        modules = [./home/myhost.nix]; 

    defaultPackage.x86_64-linux = nixpkgs.lib.mkDefault {
      hello = import ./pkgs/hello.nix { inherit nixpkgs; };

And the custom derivation in ./pkgs/hello.nix:

{ stdenv }:

stdenv.mkDerivation rec {
  name = "hello-2.10";
  src = fetchurl {
    url = mirror://gnu/hello/hello-2.10.tar.gz;
    sha256 = "0z2c7x6iywzynf22pby5wszfvrxmi8f4g82kmn25hbwjv9b5myaa";

  buildPhase = ''
    echo "Building hello..."

  installPhase = ''
    echo "Installing hello..."
    make install DESTDIR=$out

How do you use that “custom derivation” in your configuration?

PS: You do not want to pass a “pre-imported” pkgs to homeManagerConfiguration! Instead you want to pass nixpkgs.legacyPackages.x86_64-linux and set nixpkgs.config.* via HM. For unfree packages you need to set nixpkgs.config.allowUnfreePredicate = _: true due to a so far unsolved but known issue between HM and nixpkgs which only manifests with flakes and standalone.

Thanks that’s very good to know, will update that!

As for the usage, it’s more or less for a proof of concept to be able to build & compile things which are perhaps not available in the official repositories. So with this gnu hello pkg, the end goal would be to have the hello command after rebuilding the system.
I haven’t found a lot of (basic) examples yet of flake based system configurations where something like this or similar is showcased.

Or am I missing a complete set of instruction after importing the package? I was under the impression that this would be sufficient to include it into the resulting system.

You need to tell your system configuration to use the package.

Just because you declare a package as an output it will not be installed magically.

Please refer to to learn how to use inputs in your configuration.

In this case, the input is self.

And just another thing I realized just now: defaultPackage.<system> got deprecated quite some time ago, you should use packages.<system>.default instead.

Oh my… Somehow completely brushed over using it in my system packages :tired_face: Tysm for the quick help!