snowfallorg / nix-software-center

A simple gtk4/libadwaita software center to easily install and manage nix packages
GNU General Public License v3.0
529 stars 16 forks source link

error installing via nixos flakes way #27

Open zapatagustin opened 1 year ago

zapatagustin commented 1 year ago

Hi, i'm new in nixos and i have no idea how to fix this error:

sudo nixos-rebuild switch --flake .#host warning: updating lock file '/etc/nixos/flake.lock': • Added input 'nix-software-center': 'github:vlinkz/nix-software-center/64ef8b1bb08fe27863743ea5f135391c7fd287a3' (2023-02-24) • Added input 'nix-software-center/nixpkgs': 'github:NixOS/nixpkgs/5f4e07deb7c44f27d498f8df9c5f34750acf52d2' (2023-02-18) • Added input 'nix-software-center/utils': 'github:numtide/flake-utils/3db36a8b464d0c4532ba1c7dda728f4576d6d073' (2023-02-13) error: 'outputs' at /nix/store/79fjmfcjsd61kml6jjv5cnfvjsl84isn-source/flake.nix:7:13 called with unexpected argument 'nix-software-center'

   at «string»:45:21:

       44|
       45|           outputs = flake.outputs (inputs // { self = result; });
         |                     ^
       46|

Is a vanilla kde installation with flakes enabled, nothing more. The single runs works.

Lord-Valen commented 1 year ago

tl;dr -- Add nix-software-center or ... to the outputs function arguments.

nix-software-center must be one of the arguments to the outputs function. All inputs are passed as arguments to outputs, if any argument is not expected, an error similar to this one will occur. You should probably have ... in the arguments to compress any extra inputs that you aren't explicitly using, to prevent such an error from occurring when you add inputs.

zapatagustin commented 1 year ago

Nice, the outputs error is gone, but now i have this error in configuration.nix

error: undefined variable 'inputs'

   at /nix/store/1sdg7qm9ap9p4p68q6r5wy5q49c0n4qb-source/configuration.nix:105:4:

      104|   environment.systemPackages = with pkgs; [
      105|          inputs.nix-software-center.packages.${system}.nix-software-center
         |    ^
      106|          neovim

(use '--show-trace' to show detailed location information)

setting nix-software-center inside the systemPackages like the other way is not correct?

Lord-Valen commented 1 year ago

Yes, I suspected that might happen. If you added the nix-software-centre argument, just use nix-software-center rather than inputs.nix-software-center. Otherwise, use the @ pattern as seen here.

iopq commented 1 year ago

I added it as an output, but when I tried using nix-software-center directly it didn't work

error: undefined variable 'nix-software-center'

   at /nix/store/dqinl2bcvkhyjrhi9z1sjcfb0mgnfmj5-source/configuration.nix:196:5:

      195|   environment.systemPackages = with pkgs; [
      196|     nix-software-center.packages.${system}.nix-software-center
         |     ^
      197|     xray

(use '--show-trace' to show detailed location information)

Lord-Valen commented 1 year ago

Can you share your configuration?

zapatagustin commented 1 year ago

Hi, I've managed to install it with the flakes option. This is the configuration.nix

{ config, pkgs, lib, nix-software-center, inputs, ... }: let nixos-conf-editor = (import (pkgs.fetchFromGitHub { owner = "vlinkz"; repo = "nixos-conf-editor"; rev = "0.1.1"; sha256 = "sha256-TeDpfaIRoDg01FIP8JZIS7RsGok/Z24Y3Kf+PuKt6K4="; })) {}; in

environment.systemPackages = with pkgs; [ inputs.nix-software-center.packages.${system}.nix-software-center neovim git ];

and the flake.nix:

{ description = "An example NixOS configuration";

inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nur.url = "github:nix-community/NUR"; nix-software-center.url = "github:vlinkz/nix-software-center"; };

outputs = inputs: / ignore:: / let ignoreme = ({config,lib,nix-software-center,inputs,...}: with lib; { system.nixos.revision = mkForce null; system.nixos.versionSuffix = mkForce "pre-git"; }); in { nixosConfigurations = {

  thonkpad = inputs.nixpkgs.lib.nixosSystem {
    system = "x86_64-linux";
    modules = [
      ./configuration.nix

      /* ignore */ ignoreme # ignore this; don't include it; it is a small helper for this example
    ];
    specialArgs = { 
      inherit inputs;
      systemPackages = with inputs.nixpkgs; [
        rustup
      ];
    };
  };
};

}; }

to compile it:

sudo nixos-rebuild switch --flake .#yourconfigname --impure

good luck

tobiasBora commented 6 months ago

I guess we can close it then? On mine I used successfully:

{
  description = "The configuration of my system";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    # https://github.com/snowfallorg/nix-software-center
    nix-software-center.url = "github:snowfallorg/nix-software-center";
  };

  outputs = { self, nixpkgs, nix-software-center }@inputs: {
    nixosConfigurations.bestos = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = { inherit inputs; };
      modules = [
        ({pkgs, ...}: {

          environment.systemPackages = with pkgs; [
            inputs.nix-software-center.packages.${system}.nix-software-center
          ];

        })
        ./configuration.nix
      ];
    };
  };
}