nix-community / flakelight

Framework for simplifying flake setup [maintainer=@accelbread]
MIT License
227 stars 5 forks source link

Unable to Call Custom Package in /packages #12

Closed ghost closed 9 months ago

ghost commented 9 months ago

I am using nixdir = ./.; and creating a custom package in the packages folder. I cannot directly use that package with pkgs.{package_name}.

Evidence from my code: https://gitlab.com/jongjapra/nix-jongjapra-config/-/blob/main/home-modules/theming/gtk.nix?ref_type=heads

accelbread commented 9 months ago

Hi!

The pkgs arg of a home-manager module comes from home-manager; in this case the NixOS module configures it to use the NixOS pkgs set. This is created by lib.nixosSystem and is different from the flakelight pkgs set.

Flakelight provides config.propagationModule to apply flakelight package set customizations to NixOS package sets and home-manager package sets.

Theres two ways you can use it by modifying your system configuration.

The first option is not calling lib.nixosSystem, in which case flakelight can handle this for you. That would look like this:

 {
   inputs,
   src,
   ...
 }: let
   vars = import ./variables.nix;
 in
-  inputs.nixpkgs.lib.nixosSystem {
+  {
     system = vars.ARCHITECTURE;
     specialArgs = {inherit inputs src vars;};
     modules = with inputs; [
       ./hardware-configuration.nix
       disko.nixosModules.disko
       ./disko-configuration.nix
       ./configuration.nix
       self.nixosModules.hardware
       self.nixosModules.environment
       self.nixosModules.service
       self.nixosModules.wayland
       ./home-manager.nix
     ];
   }

The second option is still calling lib.nixosSystem yourself, and adding config.propagationModule to modules:

 {
   inputs,
   src,
+  config,
   ...
 }: let
   vars = import ./variables.nix;
 in
   inputs.nixpkgs.lib.nixosSystem {
     system = vars.ARCHITECTURE;
     specialArgs = {inherit inputs src vars;};
     modules = with inputs; [
+     config.propagationModule
       ./hardware-configuration.nix
       disko.nixosModules.disko
       ./disko-configuration.nix
       ./configuration.nix
       self.nixosModules.hardware
       self.nixosModules.environment
       self.nixosModules.service
       self.nixosModules.wayland
       ./home-manager.nix
     ];
   }

After applying one of the above two, you will be able to use pkgs.everforest-gtk in your nixos and home modules.

ghost commented 9 months ago

Thank you very much, your answer worked well. I hope that in the future, more people will use this great framework. 👍 👍 👍