feat: overhaul overlays

This commit is contained in:
Leon Schwarzäugl 2026-03-05 23:01:13 +01:00
parent 91f4393800
commit 130444f5d7
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
23 changed files with 406 additions and 246 deletions

View file

@ -2027,7 +2027,11 @@ Concerning the =flake = _:= part:
pkgsFor = lib.genAttrs (import systems) (system:
import inputs.nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
overlays = [
self.overlays.default
self.overlays.stables
self.overlays.modifications
];
config.allowUnfree = true;
}
);
@ -2134,6 +2138,8 @@ More information on the actual packages build can be found in [[#h:64a5cc16-6b16
};
overlays = [
self.overlays.default
self.overlays.stables
self.overlays.modifications
];
};
inherit pkgs;
@ -3137,27 +3143,37 @@ This defines some apps; they differ from normal packages in that they can be cal
};
}
#+end_src
** Overlays
** Overlays/Overrides
:PROPERTIES:
:CUSTOM_ID: h:7a059bd9-13f8-4005-b270-b41eeb6a4af2
:END:
In this section I define packages that I manually add to nixpkgs, or that I want to use in a modified way. This can be useful for packages that are currently awaiting a PR or public packages that I do not want to maintain.
In this section I define packages that I manually add to nixpkgs, or that I want to use in a modified way. This can be useful for packages that are currently awaiting a PR or public packages that I do not want to maintain. This is done in a three step process.
As such, I also define three additional local overlays:
The first overlay stage is responsible for extending the base nixpkgs:
1) =additions=
These are for the aforementioned added packages.
NOTE: The packages themselves are built in [[#h:6ed1a641-dba8-4e85-a62e-be93264df57a][Packages (pkgs)]]; here, we just add them to the overlay that we then use in the configuration.
2) =modification=
These are for packages that are on nixpkgs, but do not fit my usecase, meaning I need to perform modifications on them.
3) =nixpkgs-stable-versions=
These are simply mirrors of other branches of nixpkgs (mostly past stable branches). Useful for packages that are broken on nixpkgs, but do not need to be on bleeding edge anyways. Automatically fetches all inputs names =nixpkgs-<suffix>= and adds them under the name in =<suffix>=.
2) =nixpkgs-stable-versions=
These are simply mirrors of other branches of nixpkgs (mostly past stable branches). Useful for packages that are broken on nixpkgs, but do not need to be on bleeding edge anyways. Automatically fetches all inputs names =nixpkgs-<suffix>= and adds them under the name in =<suffix>=. They will be available under =pkgs.<suffix>=.
The second stage of overlays is responsible to replace packages in nixpkgs with stable versions. The benefit here is that I have a central place (this part of the config) where I can declare what needs to be stable - broken packages tend to be enduser packages, as packages with huge dependency chains will normally be caught earlier upstream if there is a failure (see [[#h:b562adaf-536c-4267-88a5-026d8a0cda61][Current issues]]). In effect, that means I can override package =xyz= right here, and then use =pkgs.xyz= in the rest of the config, whereas I would need to use =pkgs.<suffix>.xyz= if I were to only use =nixpkgs-stable-versions= from the first stage.
Note that packages with bigger dependencies should NOT be added here. Such as:
- chromium
- bluez
- pipewire
As doing so will trigger enormous rebuilds of e.g. =electron=.
The third stage takes care of further modifications that should be performed to the packages after they have been overridden in stages 1 and 2: These modifications are for packages that do not fit my usecase, meaning I need to perform modifications on them.
As part of the modifications, I add some of my own library functions to be used alongside the functions provided by =nixpkgs= and =home-manager=.
On the structure of overlays: as you notice, all of the attributes within overlays are functions which take =final= and =prev= as arguments. This is a convention (sometimes you also see =super= instead of =final=) that aims to tell you that =final= represents the =pkgs= set after it has gone over all modifications, while =prev= is the =pkgs= set before the current modification.
- So, in =additions=, the =final= set is the same as in =modifications=, but their =prev= sets might differ (in this case, I believe they will be the same since all modifications are done at the same step).
- So, in =additions=, the =final= set is the same as in =modifications=, but their =prev= sets differ.
- This starts to make a difference when you use multiple overlays and have one overlay depend on the modifications in another overlay.
- The =_= argument is used like in a number of other programing languages and signals that the argument is never actually used in the function.
@ -3168,99 +3184,164 @@ On the structure of overlays: as you notice, all of the attributes within overla
inherit (self) outputs;
inherit (outputs) lib;
in
{
flake = _:
{
flake = _:
{
overlays = {
default = final: prev:
let
additions = final: _: import "${self}/pkgs/flake" { pkgs = final; inherit self lib; }
overlays = let
nixpkgs-stable-versions = final: _:
let
nixpkgsInputs =
lib.filterAttrs
(name: _v: builtins.match "^nixpkgs-.*" name != null)
inputs;
rename = name: builtins.replaceStrings [ "nixpkgs-" ] [ "" ] name;
mkPkgs = src:
import src {
inherit (final.stdenv.hostPlatform) system;
config.allowUnfree = true;
};
in
builtins.listToAttrs (map
(name: {
name = rename name;
value = mkPkgs nixpkgsInputs.${name};
})
(builtins.attrNames nixpkgsInputs));
in rec {
default = additions;
additions = final: prev:
let
additions = final: _: import "${self}/pkgs/flake" { pkgs = final; inherit self lib; }
// {
swarsel-nix = import inputs.swarsel-nix {
pkgs = prev;
swarsel-nix = import inputs.swarsel-nix {
pkgs = prev;
};
zjstatus = inputs.zjstatus.packages.${prev.stdenv.hostPlatform.system}.default;
};
zjstatus = inputs.zjstatus.packages.${prev.system}.default;
in
(additions final prev)
// (nixpkgs-stable-versions final prev)
// (inputs.niri-flake.overlays.niri final prev)
// (inputs.noctalia.overlays.default final prev)
// (inputs.vbc-nix.overlays.default final prev)
// (inputs.nur.overlays.default final prev)
// (inputs.emacs-overlay.overlay final prev)
// (inputs.nix-topology.overlays.default final prev)
// (inputs.nix-index-database.overlays.nix-index final prev)
// (inputs.nixgl.overlay final prev)
// (inputs.nix-minecraft.overlay final prev)
// (inputs.nixos-extra-modules.overlays.default final prev);
stables = final: prev:
let
mkUsePkgsFrom = pkgsFrom: names:
builtins.listToAttrs (map
(name: {
inherit name;
value = pkgsFrom.${name};
})
names);
from = let
stablePackages = nixpkgs-stable-versions final prev;
in key:
stablePackages.${key} or (throw "Missing nixpkgs input nixpkgs-${key}");
in
(mkUsePkgsFrom (from "dev") [
# "swayosd"
"firezone-relay"
"firezone-server-web"
"firezone-server-api"
"firezone-server-domain"
])
// (mkUsePkgsFrom (from "stable24_05") [
"awscli2"
])
// (mkUsePkgsFrom (from "stable24_11") [
"python39"
"spotify"
"vieb"
])
// (mkUsePkgsFrom (from "stable25_05") [
"steam-fhsenv-without-steam"
"transmission_3"
])
// (mkUsePkgsFrom (from "stable") [
# "anki"
"azure-cli"
# "bat-extras.batgrep"
# "bluez"
"calibre"
# "chromium"
"dwarfs"
"gotenberg"
"khal"
"libreoffice"
"libreoffice-qt"
"nerd-fonts-symbols-only"
"noto-fonts"
"noto-fonts-cjk-sans"
"noto-fonts-color-emoji"
# "pipewire"
"podman"
"teams-for-linux"
# "vesktop"
"virtualbox"
]);
modifications = final: prev:
let
modifications = final: prev: {
# vesktop = prev.vesktop.override {
# withSystemVencord = true;
# };
lib = prev.lib // {
swarselsystems = self.outputs.swarselsystemsLib;
hm = self.outputs.homeLib;
};
modifications = final: prev: {
# vesktop = prev.vesktop.override {
# withSystemVencord = true;
# };
lib = prev.lib // {
swarselsystems = self.outputs.swarselsystemsLib;
hm = self.outputs.homeLib;
};
firefox = prev.firefox.override {
nativeMessagingHosts = [
prev.tridactyl-native
prev.browserpass
# prev.plasma5Packages.plasma-browser-integration
];
};
isync = prev.isync.override {
withCyrusSaslXoauth2 = true;
};
mgba = final.swarsel-mgba;
retroarch = prev.retroarch.withCores (cores: with cores; [
snes9x # snes
nestopia # nes
dosbox # dos
scummvm # scumm
vba-m # gb/a
mgba # gb/a
melonds # ds
dolphin # gc/wii
]);
firefox = prev.firefox.override {
nativeMessagingHosts = [
prev.tridactyl-native
prev.browserpass
# prev.plasma5Packages.plasma-browser-integration
];
};
nixpkgs-stable-versions = final: _:
let
nixpkgsInputs =
lib.filterAttrs
(name: _v: builtins.match "^nixpkgs-.*" name != null)
inputs;
isync = prev.isync.override {
withCyrusSaslXoauth2 = true;
};
rename = name: builtins.replaceStrings [ "nixpkgs-" ] [ "" ] name;
mgba = final.swarsel-mgba;
mkPkgs = src:
import src {
inherit (final) system;
config.allowUnfree = true;
};
in
builtins.listToAttrs (map
(name: {
name = rename name;
value = mkPkgs nixpkgsInputs.${name};
})
(builtins.attrNames nixpkgsInputs));
noctalia-shell = prev.noctalia-shell.override {
calendarSupport = true;
};
in
lib.recursiveUpdate
(
(additions final prev)
// (nixpkgs-stable-versions final prev)
// (inputs.niri-flake.overlays.niri final prev)
// (inputs.noctalia.overlays.default final prev)
// (inputs.vbc-nix.overlays.default final prev)
// (inputs.nur.overlays.default final prev)
// (inputs.emacs-overlay.overlay final prev)
// (inputs.nix-topology.overlays.default final prev)
// (inputs.nix-index-database.overlays.nix-index final prev)
// (inputs.nixgl.overlay final prev)
// (inputs.nix-minecraft.overlay final prev)
// (inputs.nixos-extra-modules.overlays.default final prev)
)
(modifications final prev);
retroarch = prev.retroarch.withCores (cores: with cores; [
snes9x # snes
nestopia # nes
dosbox # dos
scummvm # scumm
vba-m # gb/a
mgba # gb/a
melonds # ds
dolphin # gc/wii
]);
};
in
modifications final prev;
};
};
}
}
#+end_src
** Installer images (iso, kexec)
:PROPERTIES:
@ -8938,6 +9019,8 @@ A breakdown of the flags being set:
nixpkgs = {
overlays = [
outputs.overlays.default
outputs.overlays.stables
outputs.overlays.modifications
] ++ lib.optionals withHomeManager [
(final: prev:
let
@ -9669,7 +9752,7 @@ Enable OpenGL, Sound, Bluetooth and various drivers.
bluetooth = lib.mkIf config.swarselsystems.hasBluetooth {
enable = true;
package = pkgs.stable.bluez;
package = pkgs.bluez;
powerOnBoot = true;
settings = {
General = {
@ -9721,7 +9804,7 @@ Pipewire handles communication on Wayland. This enables several sound tools as w
services.pipewire = {
enable = true;
package = pkgs.stable.pipewire;
package = pkgs.pipewire;
pulse.enable = true;
jack.enable = true;
audio.enable = true;
@ -10515,13 +10598,17 @@ Most of the time I am using =power-saver=, however, it is good to be able to cho
:CUSTOM_ID: h:5db15758-17d8-4bde-811d-d11ccdd3f3d3
:END:
[[#h:388e71be-f00a-4d45-ade1-218ce942057d][SwayOSD]] provides a neat visual overlay when changing the system volume or brightness. However, the libinput backend needs some fixing, which is done here.
Nowadays, this is not used in favor of [[#h:96e05275-38df-401b-8809-d45d8f59e43c][Noctalia-shell]].
#+begin_src nix-ts :tangle modules/nixos/client/swayosd.nix
{ lib, pkgs, config, ... }:
{
options.swarselmodules.swayosd = lib.mkEnableOption "swayosd settings";
config = lib.mkIf config.swarselmodules.swayosd {
environment.systemPackages = [ pkgs.dev.swayosd ];
services.udev.packages = [ pkgs.dev.swayosd ];
environment.systemPackages = [ pkgs.swayosd ];
services.udev.packages = [ pkgs.swayosd ];
systemd.services.swayosd-libinput-backend = {
description = "SwayOSD LibInput backend for listening to certain keys like CapsLock, ScrollLock, VolumeUp, etc.";
documentation = [ "https://github.com/ErikReider/SwayOSD" ];
@ -10532,7 +10619,7 @@ Most of the time I am using =power-saver=, however, it is good to be able to cho
serviceConfig = {
Type = "dbus";
BusName = "org.erikreider.swayosd";
ExecStart = "${pkgs.dev.swayosd}/bin/swayosd-libinput-backend";
ExecStart = "${pkgs.swayosd}/bin/swayosd-libinput-backend";
Restart = "on-failure";
};
};
@ -10930,7 +11017,7 @@ I am using distrobox to quickly circumvent isses that I cannot immediately solve
virtualisation.podman = {
enable = true;
dockerCompat = true;
package = pkgs.stable.podman;
package = pkgs.podman;
};
};
}
@ -15991,7 +16078,7 @@ kanidm person credential create-reset-token <user>
services = {
${serviceName} = {
enable = true;
package = pkgs.dev.oauth2-proxy;
package = pkgs.update.oauth2-proxy;
cookie = {
domain = ".${mainDomain}";
secure = true;
@ -18845,19 +18932,19 @@ This has some state:
domain = {
settings.ERLANG_DISTRIBUTION_PORT = domainPort;
package = pkgs.dev.firezone-server-domain;
package = pkgs.firezone-server-domain;
};
api = {
externalUrl = "https://${serviceDomain}/api/";
address = "0.0.0.0";
port = apiPort;
package = pkgs.dev.firezone-server-api;
package = pkgs.firezone-server-api;
};
web = {
externalUrl = "https://${serviceDomain}/";
address = "0.0.0.0";
port = webPort;
package = pkgs.dev.firezone-server-web;
package = pkgs.firezone-server-web;
};
};
@ -18870,7 +18957,7 @@ This has some state:
publicIpv4 = proxyAddress4;
publicIpv6 = proxyAddress6;
openFirewall = lib.mkIf (!isProxied) true;
package = pkgs.dev.firezone-relay;
package = pkgs.firezone-relay;
};
};
# systemd.services.firezone-initialize =
@ -19227,7 +19314,11 @@ This section sets up all the imports that are used in the home-manager section.
nix.settings.experimental-features = "nix-command flakes";
nixpkgs = {
hostPlatform = "x86_64-darwin";
overlays = [ outputs.overlays.default ];
overlays = [
outputs.overlays.default
outputs.overlays.stables
outputs.overlays.modifications
];
config = {
allowUnfree = true;
};
@ -19408,7 +19499,7 @@ This sets the VirtualBox configuration. Guest should not be enabled if not direl
enable = true;
enableKvm = true;
addNetworkInterface = lib.mkIf config.virtualisation.virtualbox.host.enableKvm false;
package = pkgs.stable.virtualbox;
package = pkgs.virtualbox;
enableExtensionPack = true;
};
# leaving this here for future notice. setting guest.enable = true will make 'restarting sysinit-reactivation.target' take till timeout on nixos-rebuild switch
@ -19776,7 +19867,7 @@ When setting up a new machine:
environment.systemPackages = with pkgs; [
remmina
# gp-onsaml-gui
stable24_11.python39
python39
qemu
packer
gnumake
@ -20459,6 +20550,8 @@ Again, we adapt =nix= to our needs, enable the home-manager command for non-NixO
nixpkgs = lib.mkIf (!isNixos) {
overlays = [
outputs.overlays.default
outputs.overlays.stables
outputs.overlays.modifications
(final: prev:
let
additions = final: _: import "${self}/pkgs/config" {
@ -20611,7 +20704,7 @@ This holds packages that I can use as provided, or with small modifications (as
(aspellWithDicts (dicts: with dicts; [ de en en-computers en-science ]))
# browser
stable24_11.vieb
vieb
mgba
# utilities
@ -20668,7 +20761,7 @@ This holds packages that I can use as provided, or with small modifications (as
# element-desktop
nicotine-plus
stable25_05.transmission_3
transmission_3
mktorrent
hugo
@ -20729,13 +20822,7 @@ This holds packages that I can use as provided, or with small modifications (as
slurp
# the following packages are used (in some way) by waybar
# playerctl
pavucontrol
# stable.pamixer
# gnome.gnome-clocks
# wlogout
# jdiskreport
# monitor
#keychain
qalculate-gtk
@ -21192,8 +21279,7 @@ This section is for programs that require no further configuration. zsh Integrat
pkgs.bat-extras.batdiff
pkgs.bat-extras.batman
pkgs.bat-extras.batwatch
] ++ [
pkgs.stable.bat-extras.batgrep
pkgs.bat-extras.batgrep
];
# extraPackages = with pkgs.bat-extras; [ batdiff batman batgrep batwatch ];
};
@ -24217,7 +24303,7 @@ The `extraConfig` section here CANNOT be reindented. This has something to do wi
systemd.user.services.swayosd = confLib.overrideTarget "sway-session.target";
services.swayosd = {
enable = true;
package = pkgs.dev.swayosd;
package = pkgs.swayosd;
topMargin = 0.5;
};
};
@ -25604,7 +25690,7 @@ This service changes the screen hue at night. I am not sure if that really does
programs.anki = {
enable = true;
# # package = pkgs.anki;
package = pkgs.anki;
hideBottomBar = true;
hideBottomBarMode = "always";
hideTopBar = true;
@ -25782,7 +25868,7 @@ This service changes the screen hue at night. I am not sure if that really does
config = lib.mkIf config.swarselmodules.${moduleName} {
programs.${moduleName} = {
enable = true;
package = pkgs.stable.vesktop;
package = pkgs.vesktop;
settings = {
appBadge = false;
arRPC = false;
@ -26394,7 +26480,7 @@ Apart from configuring Noctalia, I here also add some systemd chains to make sur
fastfetch.enable = true;
noctalia-shell = {
enable = true;
package = pkgs.noctalia-shell.override { calendarSupport = true; };
package = pkgs.noctalia-shell;
systemd.enable = true;
settings = {
bar = {
@ -27072,7 +27158,7 @@ When setting up a new machine:
config = {
home = {
packages = with pkgs; [
stable.teams-for-linux
teams-for-linux
shellcheck
dig
docker
@ -27082,9 +27168,9 @@ When setting up a new machine:
prometheus.cli
tigervnc
# openstackclient
vscode-fhs
antigravity
vscode
dev.antigravity
rustdesk-vbc
];
@ -27215,7 +27301,7 @@ When setting up a new machine:
};
awscli = {
enable = true;
package = pkgs.stable24_05.awscli2;
package = pkgs.awscli2;
# settings = {
# "default" = { };
# "profile s3-imagebuilder-prod" = { };
@ -27613,7 +27699,7 @@ When setting up a new machine:
};
Service = {
ExecStart = "${pkgs.stable.teams-for-linux}/bin/teams-for-linux --disableGpu=true --minimized=true --trayIconEnabled=true";
ExecStart = "${pkgs.teams-for-linux}/bin/teams-for-linux --disableGpu=true --minimized=true --trayIconEnabled=true";
};
};