Refactor module input to use self for better input handling

This commit is contained in:
Chris Toph 2025-07-10 11:57:54 -04:00
parent e3326913f1
commit 3f904de4da
4 changed files with 39 additions and 39 deletions

View file

@ -15,53 +15,50 @@
{ {
self, self,
nixpkgs, nixpkgs,
home-manager,
flake-utils,
chaotic, chaotic,
... ...
}@inputs: }@inputs:
flake-utils.lib.eachDefaultSystem ( let
system: forAllSystems = nixpkgs.lib.genAttrs [
let "x86_64-linux"
pkgs = import nixpkgs { "aarch64-linux"
inherit system; ];
overlays = [ self.overlays.default ]; in
}; {
lib = import ./lib { inherit (nixpkgs) lib; };
# Extend lib with play utilities nixosModules = {
lib = nixpkgs.lib.extend ( play = import ./modules/nixos self;
final: prev: { default = self.nixosModules.play;
play = import ./lib { lib = final; }; };
}
);
in homeManagerModules = {
{ play = import ./modules/home self;
packages = { default = self.homeManagerModules.play;
proton-cachyos = pkgs.callPackage ./pkgs/proton-cachyos { }; };
default = self.packages.${system}.proton-cachyos;
};
# Expose the extended lib
lib = lib;
}
)
// {
homeManagerModules.play = import ./modules/home inputs;
nixosModules.play = import ./modules/nixos inputs;
# Default module (home-manager)
homeManagerModules.default = self.homeManagerModules.play;
# Test configuration
nixosConfigurations.test = nixpkgs.lib.nixosSystem { nixosConfigurations.test = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
self.nixosModules.play
./test-config.nix ./test-config.nix
self.nixosModules.play
]; ];
}; };
packages = forAllSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
in
{
proton-cachyos = pkgs.callPackage ./pkgs/proton-cachyos { };
default = self.packages.${system}.proton-cachyos;
}
);
# Overlay for packages # Overlay for packages
overlays.default = final: prev: { overlays.default = final: prev: {
proton-cachyos = final.callPackage ./pkgs/proton-cachyos { }; proton-cachyos = final.callPackage ./pkgs/proton-cachyos { };

View file

@ -1,4 +1,4 @@
inputs: { self: {
imports = [ imports = [
./monitors.nix ./monitors.nix
./gamescoperun.nix ./gamescoperun.nix
@ -6,5 +6,7 @@ inputs: {
]; ];
# Pass inputs to all modules via _module.args # Pass inputs to all modules via _module.args
_module.args = { inherit inputs; }; _module.args = {
inputs = self.inputs;
};
} }

View file

@ -129,7 +129,6 @@ let
# Execute gamescope with the final arguments and the command # Execute gamescope with the final arguments and the command
exec ${lib.getExe gamescopePackages.gamescope} $final_args -- $argv exec ${lib.getExe gamescopePackages.gamescope} $final_args -- $argv
''; '';
in in
{ {
options.play.gamescoperun = { options.play.gamescoperun = {

View file

@ -1,4 +1,4 @@
inputs: { self: {
imports = [ imports = [
./amd.nix ./amd.nix
./ananicy.nix ./ananicy.nix
@ -8,5 +8,7 @@ inputs: {
]; ];
# Pass inputs to all modules via _module.args # Pass inputs to all modules via _module.args
_module.args = { inherit inputs; }; _module.args = {
inputs = self.inputs;
};
} }