Help moving away from home.nix to flake.nix

Hi all,

I use Nix + Home Manager on a different GNU/Linux flavor.

I started my learning of Nix Flakes and came out with the following simple flake.nix , which isn’t working, and I can’t understand what is wrong:

{
  # Description of the flake
  description = "CLI apps and tools";

  # Define inputs (Nix packages and channels)
  inputs = {
    # Nixpkgs channel with unstable version
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    # Home Manager from community repository
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  # Define outputs (build results)
  outputs = { self, pkgs, home-manager }: {
      # Home Manager configuration
      homeManagerConfig = {
        config, pkgs, ... }: {
          # User information
          home.username = "cig0";
          home.homeDirectory = "/home/cig0";
          home.stateVersion = "24.05";

          # Enable Home Manager and set options
          programs.home-manager.enable = true;
          # ... (Uncomment other programs and configurations as needed)

          # Install desired packages
          home.packages = with pkgs; [
            # ... (Add desired packages from your current config)
            #ansible # Using Universal Blue's package
            argocd
            atuin
            awscli2
            bat
            bitlbee
            bitlbee-discord
            borgbackup
            btop
            chezmoi
            cargo
            chit
            cosign
            crc
            delta
            discordo
            difftastic
            dnstracer
            du-dust
            dua
            duf
            dysk
            eksctl
            exiftool
            fd
            fdupes
            fx
            fzf
            gh
            git-lfs
            glab
            glances
            go
            goaccess
            golangci-lint
            golangci-lint-langserver
            gopls
            grpcurl
            gum
            httpie
            hugo
            hyperfine
            inetutils
            inxi
            iotop
            k9s
            kind
            krew
            kube-bench
            kubecolor
            kubectl
            kubernetes-helm
            kubeswitch
            lazygit
            lf
            lftp
            lnav
            lynis
            lurk
            mc
            minikube
            moar
            ncdu
            neofetch
            #neovim # Using Fedora's package
            nerdctl
            nfstrace
            nixfmt
            nmap
            nodejs_latest
            nushell
            nvitop
            oath-toolkit
            oh-my-posh
            ocm
            odo
            ookla-speedtest
            opentofu
            packer
            podman-compose
            powertop
            python312Packages.yamllint
            qrscan
            ripgrep
            rust-analyzer
            rust-petname
            rustc
            rustfmt
            rustscan
            rustycli
            s-tui
            shellcheck
            sops
            strace
            strace-analyzer
            tcpdump
            telepresence2
            terraformer
            tesseract
            tf-summarize
            tflint
            tfsec
            tfswitch
            todoist
            tokei
            translate-shell
            ugrep
            vagrant
            vdpauinfo
            vt-cli
            weechat
            wiki-tui
            wl-clipboard
            yamlfmt
            zola
            zoxide
          ];

          # Enable generic Linux environment variables
          targets.genericLinux.enable = true;
        };
      };
}

I intend to split the flake into other flakes to install the tooling and set environments based on the hostname. However, I first need to get this flake working!

This is the error message I’m getting when nix build .:

       … while updating the flake input 'pkgs'

       error: cannot find flake 'flake:pkgs' in the flake registries

Thanks!

The immediate issue you’re facing is that the arguments to the function assigned to outputs should match the names provided in the inputs section. So in your case if you change that from pkgs to nixpkgs it should get past that error. There may be others that you encouter after that though.