How to "install" a flake like a package in home-manager

Hello,
i have a flake.nix from here and changed it so that it works with the newest version.
My configuration looks like this:

/etc/nixos/flake.nix
{
  description = "NixOS Flake configuration";

  inputs = {
    # NixOS official package source, using the nixos-25.11 branch here
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
    # home-manager, used for managing user configuration
    home-manager = {
      url = "github:nix-community/home-manager/release-25.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    tinyMediaManager-flake = {
      url = "/home/lukas/Documents/tinyMediaManager-flake/";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, home-manager, tinyMediaManager-flake, ... }@inputs: {
    # Please replace my-nixos with your hostname
    nixosConfigurations."nixos" = nixpkgs.lib.nixosSystem {
      modules = [
        ./configuration.nix
        home-manager.nixosModules.home-manager {
          home-manager.useGlobalPkgs = true;
          home-manager.useUserPackages = true;

          home-manager.extraSpecialArgs = { inherit tinyMediaManager-flake; };
          home-manager.users.lukas = import ./home.nix;
        }
      ];
    };
  };
}

/etc/nixos/home.nix
{ config, pkgs, tinyMediaManager-flake, ... }:

{
  home.username = "lukas";
  home.homeDirectory = "/home/lukas";

    # Packages that should be installed to the user profile.
    home.packages = [
        pkgs.kdePackages.kate
        tinyMediaManager-flake
    ];
    programs.bash.enable = true;
    home.stateVersion = "25.11";
}

/home/lukas/Documents/tinyMediaManager-flake/flake.nix
{
  description = "tinyMediaManager NixOS flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        ### modify this to update ###
        version = "5.2.10";
        sha256 = "sha256-JbNb3Ze2YLF1LswWph77K1xXNcTtl2tJkjZrzNcBkQg=";
        #############################
        pkgs = nixpkgs.legacyPackages.${system};
      in {
        packages.default = pkgs.stdenv.mkDerivation {
          pname = "tinyMediaManager";
          version = version;

          src = pkgs.fetchurl {
            url = "https://archive.tinymediamanager.org/v${version}/tinyMediaManager-${version}-linux-amd64.tar.xz";
            sha256 = sha256;
          };

          nativeBuildInputs = [ pkgs.autoPatchelfHook pkgs.unzip ];
          buildInputs = with pkgs; [
            zlib glibc fontconfig alsa-lib
            xorg.libX11 xorg.libXext xorg.libXrender
            xorg.libXtst xorg.libXi wayland
            gcc13.cc.lib
            libzen libmediainfo
            zenity # GUI file dialog
          ];

          installPhase = ''
            mkdir -p $out/opt/tmm
            cp -r * $out/opt/tmm

            mkdir -p $out/bin
            cat > $out/bin/tinyMediaManager << EOF
#!/bin/sh
export LD_LIBRARY_PATH=${pkgs.libzen}/lib:${pkgs.libmediainfo}/lib:\$LD_LIBRARY_PATH
export PATH=${pkgs.zenity}/bin:\$PATH
cd $out/opt/tmm
exec ${pkgs.zulu25}/bin/java -Djava.library.path=./native -cp "tmm.jar:lib/*" org.tinymediamanager.TinyMediaManager "\$@"
EOF
            chmod +x $out/bin/tinyMediaManager
          '';
        };
      });
}

If i want to start the flake i can do this with nix run but i want to “install” the flake like all the other packages i have from pkgs like pkgs.kdePackages.kate.

After nixos-rebuild switch i don’t have tinyMediaManager in my start menu/ search.
How can i add the flake to my configuration so that i can start the application through the search like i can start firefox or any other pkgs package?

1 Like

Add the relevant package output to the package list you think suites the purpose best. You’ll have to add the flake as an input and thread that through config/HM using specialArgs and extraSpecialArgs respecitvely.

I think i have done that.
In flake.nix i have defined it as an input

    tinyMediaManager-flake = {
      url = "/home/lukas/Documents/tinyMediaManager-flake/";
      inputs.nixpkgs.follows = "nixpkgs";
    };

and used home-manager.extraSpecialArgs = { inherit tinyMediaManager-flake; };

In home.nix tinyMediaManager-flake is an input that i added in home.packages:

    home.packages = [
        pkgs.kdePackages.kate
        tinyMediaManager-flake
    ];

That added the flakes folder, you have to use whatever package it outputs.

1 Like

Ok it seems to be a problem with this specific program. I just tested another flake and this flake didn’t have the same problem.
My changes:
flake.nix
tinyMediaManager-flake.url = "path:/home/lukas/Documents/tinyMediaManager-flake";
home.nix
tinyMediaManager-flake.packages.${pkgs.system}.default

To integrate an external flake into your system like any other package, you need to add it as an input to your system’s main flake.nix and then include the package in the environment.systemPackages list.
Here are the concrete steps:

  1. Edit /etc/nixos/flake.nix
    Add the tinyMediaManager flake to the inputs and pass it to specialArgs:
    nix
    {
    inputs = {
    nixpkgs.url = “github:NixOS/nixpkgs/nixos-unstable”;

Add this line (adjust the path if necessary)

tmm-flake.url = “path:/home/lukas/Documents/tinyMediaManager-flake”;
};

outputs = { self, nixpkgs, tmm-flake, … }@inputs: {
nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; }; # This passes the inputs to home.nix/configuration.nix
modules = [ ./configuration.nix ];
};
};
}
Use code carefully.

  1. Modify /etc/nixos/home.nix (or configuration.nix)
    Now you can call the package directly from the inputs:
    nix
    { pkgs, inputs, … }: {
    home.packages = [
    pkgs.kdePackages.kate

Add the package from the new flake

inputs.tmm-flake.packages.${pkgs.system}.default
];
}
Use code carefully.

  1. Why doesn’t it appear in the menu?
    For an application to appear in the start menu, it must have a .desktop file. If the tinyMediaManager flake has this file defined properly in the package, it will appear automatically after the nixos-rebuild switch.
    If the flake does not have one, you must create it manually in home.nix:
    nix
    xdg.desktopEntries.tinymediamanager = {
    name = “tinyMediaManager”;
    exec = “tinyMediaManager”; # Name of the binary that executes ‘nix run’
    icon = “tinymediamanager”;
    terminal = false;
    categories = [ “Video” “AudioVideo” ];
    };
    Use code .
1 Like