feat: make nixpkgs overlays modular
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-09-22 23:16:10 -04:00
parent 0d9c6bab75
commit e2d3edae4b
2 changed files with 47 additions and 35 deletions

View file

@ -1,8 +1,23 @@
{ inputs @ {
pkgs, pkgs,
self, self,
... ...
}: { }: {
nixpkgs.overlays =
(map (i: inputs.${i}.overlays.default) [
"discord-overlay"
"grim-hyprland"
"jovian"
"nixpkgs-wayland"
])
++ (builtins.attrValues {
inherit
(self.overlays)
misc
xdg-desktop-portal-kde
;
});
environment.systemPackages = environment.systemPackages =
(builtins.attrValues { (builtins.attrValues {
inherit inherit

View file

@ -11,34 +11,20 @@ inputs: rec {
allowUnfree = true; allowUnfree = true;
inherit cudaSupport; inherit cudaSupport;
}; };
overlays =
(map (i: inputs.${i}.overlays.default) [
"discord-overlay"
"grim-hyprland"
"jovian"
"nixpkgs-wayland"
])
++ (builtins.attrValues {
inherit
(inputs.self.overlays)
misc
xdg-desktop-portal-kde
;
});
}; };
# Function that makes the attrs that make up the specialArgs allowModularOverrides = {
mkArgs = { cudaSupport,
system, system,
cudaSupport ? false, }: ({config, ...}: let
}:
inputs
// {
pkgs = mkPkgs { pkgs = mkPkgs {
inherit system cudaSupport; inherit system cudaSupport;
inherit (inputs) nixpkgs; inherit (inputs) nixpkgs;
}; };
}; inherit (pkgs.lib) composeManyExtensions mkForce;
in {
_module.args.pkgs = mkForce (pkgs.extend (composeManyExtensions config.nixpkgs.overlays));
});
# Default system # Default system
mkNixOS = { mkNixOS = {
@ -47,9 +33,10 @@ inputs: rec {
}: }:
inputs.nixpkgs.lib.nixosSystem rec { inputs.nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = mkArgs {inherit system cudaSupport;}; specialArgs = inputs;
modules = modules =
[ [
(allowModularOverrides {inherit system cudaSupport;})
{home-manager.extraSpecialArgs = specialArgs;} {home-manager.extraSpecialArgs = specialArgs;}
../common ../common
] ]
@ -58,27 +45,37 @@ inputs: rec {
mkNixOnDroid = mods: mkNixOnDroid = mods:
inputs.nix-on-droid.lib.nixOnDroidConfiguration rec { inputs.nix-on-droid.lib.nixOnDroidConfiguration rec {
extraSpecialArgs = mkArgs {system = "aarch64-linux";}; extraSpecialArgs = inputs;
home-manager-path = inputs.home-manager.outPath; home-manager-path = inputs.home-manager.outPath;
pkgs = extraSpecialArgs.pkgs; inherit (extraSpecialArgs) pkgs;
modules = let modules =
inherit (pkgs.lib) mkOption types;
in
[ [
({config, ...}: { (allowModularOverrides {system = "aarch64-linux";})
options = {
environment.variables.FLAKE = mkOption { ({
config,
lib,
...
}: let
inherit (lib) mkOption types;
in {
# Adapt NixOnDroid to NixOS options
options.environment.variables = {
FLAKE = mkOption {
type = with types; nullOr str; type = with types; nullOr str;
}; };
environment.systemPackages = mkOption { systemPackages = mkOption {
type = with types; listOf package; type = with types; listOf package;
default = []; default = [];
}; };
}; };
config.environment.packages = config.environment.systemPackages; config.environment.packages = config.environment.systemPackages;
}) })
{home-manager = {inherit extraSpecialArgs;};} {home-manager = {inherit extraSpecialArgs;};}
../common/nix-on-droid.nix ../common/nix-on-droid.nix
] ]
++ mods; ++ mods;