feat: simplify overlay structure

This commit is contained in:
Swarsel 2024-12-11 01:14:25 +01:00
parent 59c3cb77ae
commit 647a2ae1a8
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
7 changed files with 56 additions and 47 deletions

View file

@ -355,7 +355,6 @@ This sections puts together the =flake.nix= file from the [[#h:d39b8dfb-536d-414
outputs = outputs =
inputs@{ self inputs@{ self
, nixpkgs , nixpkgs
, nixpkgs-stable
, home-manager , home-manager
, nix-darwin , nix-darwin
, systems , systems
@ -599,13 +598,6 @@ Lastly I define some common module lists that I can simply load depending on the
inherit (self) outputs; inherit (self) outputs;
lib = nixpkgs.lib // home-manager.lib; lib = nixpkgs.lib // home-manager.lib;
forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system});
forAllSystems = lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
pkgsFor = lib.genAttrs (import systems) ( pkgsFor = lib.genAttrs (import systems) (
system: system:
import nixpkgs { import nixpkgs {
@ -613,6 +605,13 @@ Lastly I define some common module lists that I can simply load depending on the
config.allowUnfree = true; config.allowUnfree = true;
} }
); );
forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system});
forAllSystems = lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
mkFullHost = host: isNixos: { mkFullHost = host: isNixos: {
${host} = ${host} =
let let
@ -703,15 +702,7 @@ In this section I am creating some attributes that define general concepts of my
in in
import ./checks { inherit self inputs system pkgs; } import ./checks { inherit self inputs system pkgs; }
); );
overlaysList = [ overlays = import ./overlays { inherit inputs; };
(import ./overlays { inherit inputs; }).additions
(import ./overlays { inherit inputs; }).modifications
(import ./overlays { inherit inputs; }).nixpkgs-stable
(import ./overlays { inherit inputs; }).zjstatus
inputs.nur.overlays.default
inputs.emacs-overlay.overlay
inputs.nixgl.overlay
];
#+end_src #+end_src
@ -892,7 +883,7 @@ This is the "reference implementation" of a setup that runs without NixOS, only
imports = builtins.attrValues outputs.homeManagerModules; imports = builtins.attrValues outputs.homeManagerModules;
nixpkgs = { nixpkgs = {
overlays = outputs.overlaysList; overlays = [ outputs.overlays.default ];
config = { config = {
allowUnfree = true; allowUnfree = true;
}; };
@ -985,7 +976,7 @@ My work machine. Built for more security, this is the gold standard of my config
nixpkgs = { nixpkgs = {
overlays = outputs.overlaysList; overlays = [ outputs.overlays.default ];
config = { config = {
allowUnfree = true; allowUnfree = true;
}; };
@ -1206,13 +1197,12 @@ My work machine. Built for more security, this is the gold standard of my config
nixpkgs = { nixpkgs = {
overlays = outputs.overlaysList; overlays = [ outputs.overlays.default ];
config = { config = {
allowUnfree = true; allowUnfree = true;
}; };
}; };
boot = { boot = {
loader.systemd-boot.enable = true; loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = true; loader.efi.canTouchEfiVariables = true;
@ -2326,7 +2316,6 @@ This program sets up a new NixOS host.
} }
#+end_src #+end_src
*** Overlays (additions, overrides, nixpkgs-stable) *** Overlays (additions, overrides, nixpkgs-stable)
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: h:5e3e21e0-57af-4dad-b32f-6400af9b7aab :CUSTOM_ID: h:5e3e21e0-57af-4dad-b32f-6400af9b7aab
@ -2336,7 +2325,9 @@ This file now holds all of the "nixpkgs-changes" that I am using across the conf
#+begin_src nix :tangle overlays/default.nix #+begin_src nix :tangle overlays/default.nix
{ inputs, ... }: { { inputs, ... }:
let
additions = final: _prev: import ../pkgs { pkgs = final; }; additions = final: _prev: import ../pkgs { pkgs = final; };
modifications = _: _prev: { modifications = _: _prev: {
vesktop = _prev.vesktop.override { vesktop = _prev.vesktop.override {
@ -2379,6 +2370,19 @@ This file now holds all of the "nixpkgs-changes" that I am using across the conf
zjstatus = inputs.zjstatus.packages.${_prev.system}.default; zjstatus = inputs.zjstatus.packages.${_prev.system}.default;
}; };
in
{
default =
final: prev:
(additions final prev)
// (modifications final prev)
// (nixpkgs-stable final prev)
// (zjstatus final prev)
// (inputs.nur.overlays.default final prev)
// (inputs.emacs-overlay.overlay final prev)
// (inputs.nixgl.overlay final prev);
} }
#+end_src #+end_src
@ -6219,7 +6223,7 @@ This section sets up all the imports that are used in the home-manager section.
nix.settings.experimental-features = "nix-command flakes"; nix.settings.experimental-features = "nix-command flakes";
nixpkgs = { nixpkgs = {
hostPlatform = "x86_64-darwin"; hostPlatform = "x86_64-darwin";
overlays = outputs.overlaysList; overlays = [ outputs.overlays.default ];
config = { config = {
allowUnfree = true; allowUnfree = true;
}; };

View file

@ -120,7 +120,6 @@
outputs = outputs =
inputs@{ self inputs@{ self
, nixpkgs , nixpkgs
, nixpkgs-stable
, home-manager , home-manager
, nix-darwin , nix-darwin
, systems , systems
@ -131,13 +130,6 @@
inherit (self) outputs; inherit (self) outputs;
lib = nixpkgs.lib // home-manager.lib; lib = nixpkgs.lib // home-manager.lib;
forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system});
forAllSystems = lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
pkgsFor = lib.genAttrs (import systems) ( pkgsFor = lib.genAttrs (import systems) (
system: system:
import nixpkgs { import nixpkgs {
@ -145,6 +137,13 @@
config.allowUnfree = true; config.allowUnfree = true;
} }
); );
forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system});
forAllSystems = lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
mkFullHost = host: isNixos: { mkFullHost = host: isNixos: {
${host} = ${host} =
let let
@ -218,15 +217,7 @@
in in
import ./checks { inherit self inputs system pkgs; } import ./checks { inherit self inputs system pkgs; }
); );
overlaysList = [ overlays = import ./overlays { inherit inputs; };
(import ./overlays { inherit inputs; }).additions
(import ./overlays { inherit inputs; }).modifications
(import ./overlays { inherit inputs; }).nixpkgs-stable
(import ./overlays { inherit inputs; }).zjstatus
inputs.nur.overlays.default
inputs.emacs-overlay.overlay
inputs.nixgl.overlay
];
nixosConfigurations = nixosConfigurations =

View file

@ -4,7 +4,7 @@
imports = builtins.attrValues outputs.homeManagerModules; imports = builtins.attrValues outputs.homeManagerModules;
nixpkgs = { nixpkgs = {
overlays = outputs.overlaysList; overlays = [ outputs.overlays.default ];
config = { config = {
allowUnfree = true; allowUnfree = true;
}; };

View file

@ -29,7 +29,7 @@ in
nixpkgs = { nixpkgs = {
overlays = outputs.overlaysList; overlays = [ outputs.overlays.default ];
config = { config = {
allowUnfree = true; allowUnfree = true;
}; };

View file

@ -23,13 +23,12 @@ in
nixpkgs = { nixpkgs = {
overlays = outputs.overlaysList; overlays = [ outputs.overlays.default ];
config = { config = {
allowUnfree = true; allowUnfree = true;
}; };
}; };
boot = { boot = {
loader.systemd-boot.enable = true; loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = true; loader.efi.canTouchEfiVariables = true;

View file

@ -1,4 +1,6 @@
{ inputs, ... }: { { inputs, ... }:
let
additions = final: _prev: import ../pkgs { pkgs = final; }; additions = final: _prev: import ../pkgs { pkgs = final; };
modifications = _: _prev: { modifications = _: _prev: {
vesktop = _prev.vesktop.override { vesktop = _prev.vesktop.override {
@ -41,4 +43,17 @@
zjstatus = inputs.zjstatus.packages.${_prev.system}.default; zjstatus = inputs.zjstatus.packages.${_prev.system}.default;
}; };
in
{
default =
final: prev:
(additions final prev)
// (modifications final prev)
// (nixpkgs-stable final prev)
// (zjstatus final prev)
// (inputs.nur.overlays.default final prev)
// (inputs.emacs-overlay.overlay final prev)
// (inputs.nixgl.overlay final prev);
} }

View file

@ -10,7 +10,7 @@ in
nix.settings.experimental-features = "nix-command flakes"; nix.settings.experimental-features = "nix-command flakes";
nixpkgs = { nixpkgs = {
hostPlatform = "x86_64-darwin"; hostPlatform = "x86_64-darwin";
overlays = outputs.overlaysList; overlays = [ outputs.overlays.default ];
config = { config = {
allowUnfree = true; allowUnfree = true;
}; };