flake(overlays): modularize with flake-parts

This commit is contained in:
NullBite 2025-02-24 19:18:01 -05:00
parent 89f107b407
commit cb4be12725
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A
5 changed files with 192 additions and 156 deletions

View File

@ -131,6 +131,7 @@
./flake ./flake
./lib/nixfiles/module.nix ./lib/nixfiles/module.nix
./pkgs/module.nix ./pkgs/module.nix
./overlays
]; ];
config = { config = {
@ -221,44 +222,6 @@
# inputs is already defined # inputs is already defined
lib = nixpkgs.lib; lib = nixpkgs.lib;
systems = ["x86_64-linux" "aarch64-linux"];
overlays = let
nix-minecraft-patched-overlay = let
normal = inputs.nix-minecraft-upstream.overlays.default;
quilt = inputs.nix-minecraft.overlays.default;
in
lib.composeExtensions
normal
(final: prev: let
x = quilt final prev;
in {
inherit (x) quiltServers quilt-server;
minecraftServers = prev.minecraftServers // x.quiltServers;
});
in [
(final: prev: let
packages = import ./pkgs {inherit (prev) pkgs;};
in {
inherit (packages) mopidy-autoplay google-fonts;
atool-wrapped = packages.atool;
})
# various temporary fixes that automatically revert
self.overlays.mitigations
# auto backports from nixpkgs unstable
self.overlays.backports
# modpacks (keeps modpack version in sync between hosts so i can reverse
# proxy create track map because it's broken)
self.overlays.modpacks
inputs.hyprwm-contrib.overlays.default
inputs.rust-overlay.overlays.default
inputs.nixfiles-assets.overlays.default
nix-minecraft-patched-overlay
];
# function to generate packages for each system # function to generate packages for each system
eachSystem = lib.genAttrs (import inputs.systems); eachSystem = lib.genAttrs (import inputs.systems);
@ -305,8 +268,6 @@
inherit system; inherit system;
}); });
overlays = import ./overlays self;
nixosConfigurations = { nixosConfigurations = {
iso = mkISOSystem "x86_64-linux"; iso = mkISOSystem "x86_64-linux";
}; # end nixosConfigurations }; # end nixosConfigurations

View File

@ -1,42 +1,68 @@
nixfiles: final: prev: {
let config,
pkgs-unstable = import nixfiles.inputs.nixpkgs-unstable { config.allowUnfree = true; inherit (final) system; }; lib,
inherit (final) callPackage kdePackages lib; self,
inputs,
...
}: let
# TODO legacy refactor
# not high priority, this still works well for this overlay.
nixfiles = self;
overlay = final: prev: let
pkgs-unstable = import nixfiles.inputs.nixpkgs-unstable {
config.allowUnfree = true;
inherit (final) system;
};
inherit (final) callPackage kdePackages lib;
backport = let backport = let
_callPackage = callPackage; _callPackage = callPackage;
in { pkgname, in
{
pkgname,
callPackage ? _callPackage, callPackage ? _callPackage,
new ? pkgs-unstable, new ? pkgs-unstable,
override ? {} } : let override ? {},
inherit (lib) getAttrFromPath; }: let
inherit (builtins) getAttr isString; inherit (lib) getAttrFromPath;
inherit (builtins) getAttr isString;
getAttr' = name: attrs: if isString pkgname then getAttr name attrs else getAttrFromPath name attrs; getAttr' = name: attrs:
oldPkg = getAttr' pkgname prev; if isString pkgname
newPkg = getAttr' pkgname pkgs-unstable; then getAttr name attrs
in if oldPkg.version == newPkg.version else getAttrFromPath name attrs;
then oldPkg oldPkg = getAttr' pkgname prev;
else (callPackage newPkg.override) override; newPkg = getAttr' pkgname pkgs-unstable;
in
if oldPkg.version == newPkg.version
then oldPkg
else (callPackage newPkg.override) override;
backport' = pkgname: backport { inherit pkgname; }; backport' = pkgname: backport {inherit pkgname;};
# defined locally to not pull in perl from unstable # defined locally to not pull in perl from unstable
stripJavaArchivesHook = final.makeSetupHook { stripJavaArchivesHook =
name = "strip-java-archives-hook"; final.makeSetupHook {
propagatedBuildInputs = [ final.strip-nondeterminism ]; name = "strip-java-archives-hook";
} ./strip-java-archives.sh; propagatedBuildInputs = [final.strip-nondeterminism];
}
in { ./strip-java-archives.sh;
vesktop = backport' "vesktop"; in {
obsidian = backport { pkgname="obsidian"; override.electron = final.electron_28; }; vesktop = backport' "vesktop";
prismlauncher-unwrapped = backport { obsidian = backport {
pkgname = "prismlauncher-unwrapped"; pkgname = "obsidian";
inherit (kdePackages) callPackage; override.electron = final.electron_28;
override = { };
# apple something idk why the package doesn't just ask for darwin and get it itself prismlauncher-unwrapped = backport {
# maybe i should make a pull request that changes the params to `darwin, Cocoa ? darwin.apple_sdk.frameworks.Cocoa` pkgname = "prismlauncher-unwrapped";
inherit (final.darwin.apple_sdk.frameworks) Cocoa; inherit (kdePackages) callPackage;
override = {
# apple something idk why the package doesn't just ask for darwin and get it itself
# maybe i should make a pull request that changes the params to `darwin, Cocoa ? darwin.apple_sdk.frameworks.Cocoa`
inherit (final.darwin.apple_sdk.frameworks) Cocoa;
};
}; };
}; };
in {
config.flake.overlays.backports = overlay;
} }

View File

@ -1,17 +1,20 @@
nixfiles: {
let config,
inherit (nixfiles.inputs.nixpkgs) lib; lib,
# this name is awful. maybe i don't know anything about functional ...
# programming or something, but the naming isn't very self explanatory }: let
# - why is it "compose" instead of "combine"
# - why is it "extensions" instead of "overlays"
inherit (lib) composeManyExtensions; inherit (lib) composeManyExtensions;
in rec { cfg = config.flake.overlays;
backports = import ./backports.nix nixfiles; in {
mitigations = import ./mitigations.nix nixfiles; imports = [
modpacks = import ./modpacks.nix nixfiles; ./mitigations.nix
default = composeManyExtensions [ ./backports.nix
backports ./modpacks.nix
mitigations
]; ];
config.flake.overlays = {
default = with cfg; composeManyExtensions [
backports
mitigations
];
};
} }

View File

@ -1,56 +1,89 @@
nixfiles: final: prev: {
let config,
pkgsStable = import nixfiles.inputs.nixpkgs.outPath { inherit (prev) system; }; lib,
updateTime = nixfiles.inputs.nixpkgs-unstable.lastModified; self,
inputs,
...
}: let
# TODO legacy refactor
# not high priority, this still works well for this overlay.
nixfiles = self;
overlay = final: prev: let
pkgsStable = import nixfiles.inputs.nixpkgs.outPath {inherit (prev) system;};
updateTime = nixfiles.inputs.nixpkgs-unstable.lastModified;
inherit (final) lib callPackage fetchFromGitHub; inherit (final) lib callPackage fetchFromGitHub;
inherit (lib) recurseIntoAttrs optionalAttrs inherit
versionOlder versionAtLeast; (lib)
recurseIntoAttrs
optionalAttrs
versionOlder
versionAtLeast
;
pkgsFromFlake = flake: (import flake.outPath) { inherit (prev) system; }; pkgsFromFlake = flake: (import flake.outPath) {inherit (prev) system;};
pkgsFromInput = name: pkgsFromFlake nixfiles.inputs.${name}; pkgsFromInput = name: pkgsFromFlake nixfiles.inputs.${name};
pickFixed = ours: theirs: if versionAtLeast ours.version theirs.version then ours else theirs; pickFixed = ours: theirs:
pickNewer = ours: theirs: if versionOlder theirs.version ours.version then ours else theirs; if versionAtLeast ours.version theirs.version
then ours
else theirs;
pickNewer = ours: theirs:
if versionOlder theirs.version ours.version
then ours
else theirs;
hold = now: days: ours: theirs: let hold = now: days: ours: theirs: let
seconds = days * 24 * 60 * 60; seconds = days * 24 * 60 * 60;
endTimestamp = now + seconds; endTimestamp = now + seconds;
in if now < endTimestamp then ours else theirs; in
if now < endTimestamp
then ours
else theirs;
optionalPkg = cond: val: if cond then val else null; optionalPkg = cond: val:
if cond
then val
else null;
gimp-with-plugins-good = let gimp-with-plugins-good = let
badPlugins = [ "gap" ]; badPlugins = ["gap"];
itemInList = list: item: lib.any (x: x==item) list; itemInList = list: item: lib.any (x: x == item) list;
pluginFilter = name: value: (value.type or null == "derivation") && (!(itemInList badPlugins name)) && (!value.meta.broken); pluginFilter = name: value: (value.type or null == "derivation") && (!(itemInList badPlugins name)) && (!value.meta.broken);
filteredPlugins = lib.filterAttrs pluginFilter prev.gimpPlugins; filteredPlugins = lib.filterAttrs pluginFilter prev.gimpPlugins;
plugins = lib.mapAttrsToList (_: v: v) filteredPlugins; plugins = lib.mapAttrsToList (_: v: v) filteredPlugins;
in prev.gimp-with-plugins.override { inherit plugins; }; in
prev.gimp-with-plugins.override {inherit plugins;};
# this also causes an infinite recursion and i have no idea why
# in nixfiles.inputs.nixpkgs.lib.filterAttrs (k: v: v != null) {
in {
nix-du = let
old = prev.nix-du;
new = (pkgsFromInput "nixpkgs-nix-du").nix-du;
in
pickNewer old new;
# this also causes an infinite recursion and i have no idea why gimp-with-plugins = gimp-with-plugins-good;
# in nixfiles.inputs.nixpkgs.lib.filterAttrs (k: v: v != null) {
nwg-displays = let
stable = pkgsStable.nwg-displays;
unstable = prev.nwg-displays;
now = 1739114541;
in
hold now 7 stable unstable;
libreoffice = let
stable = pkgsStable.libreoffice;
unstable = prev.libreoffice;
now = 1739558971;
in
hold now 7 stable unstable;
redlib = let
redlib-new = final.callPackage nixfiles.packages.${prev.system}.redlib.override {};
inherit (prev) redlib;
in
pickNewer redlib-new redlib;
};
in { in {
nix-du = let config.flake.overlays.mitigations = overlay;
old = prev.nix-du;
new = (pkgsFromInput "nixpkgs-nix-du").nix-du;
in pickNewer old new;
gimp-with-plugins = gimp-with-plugins-good;
nwg-displays = let
stable = pkgsStable.nwg-displays;
unstable = prev.nwg-displays;
now = 1739114541;
in hold now 7 stable unstable;
libreoffice = let
stable = pkgsStable.libreoffice;
unstable = prev.libreoffice;
now = 1739558971;
in hold now 7 stable unstable;
redlib = let
redlib-new = final.callPackage nixfiles.packages.${prev.system}.redlib.override {};
inherit (prev) redlib;
in pickNewer redlib-new redlib;
} }

View File

@ -1,27 +1,40 @@
nixfiles: final: prev: {
let config,
inherit (final) lib; lib,
inherit (lib) fakeHash; self,
notlite = let inputs,
commit = "0e42bfbc6189db5848252d7dc7a638103d9d44ee"; ...
packHash = "sha256-X9a7htRhJcSRXu4uDvzSjdjCyWg+x7Dqws9pIlQtl6A="; }: let
in final.fetchPackwizModpack { # TODO legacy refactor
url = "https://gitea.protogen.io/nullbite/notlite/raw/commit/${commit}/pack.toml"; # not high priority, this still works well for this overlay.
inherit packHash; nixfiles = self;
}; overlay = final: prev: let
inherit (final) lib;
inherit (lib) fakeHash;
notlite = let
commit = "0e42bfbc6189db5848252d7dc7a638103d9d44ee";
packHash = "sha256-X9a7htRhJcSRXu4uDvzSjdjCyWg+x7Dqws9pIlQtl6A=";
in
final.fetchPackwizModpack {
url = "https://gitea.protogen.io/nullbite/notlite/raw/commit/${commit}/pack.toml";
inherit packHash;
};
notlite-ctm-static = final.stdenvNoCC.mkDerivation { notlite-ctm-static = final.stdenvNoCC.mkDerivation {
pname = "ctm-static"; pname = "ctm-static";
version = "0.0.0"; version = "0.0.0";
src = final.emptyDirectory; src = final.emptyDirectory;
nativeBuildInputs = [ final.unzip ]; nativeBuildInputs = [final.unzip];
buildPhase = '' buildPhase = ''
unzip "${notlite}/mods/create-track-map-*.jar" 'assets/littlechasiu/ctm/static/*' unzip "${notlite}/mods/create-track-map-*.jar" 'assets/littlechasiu/ctm/static/*'
cp -r assets/littlechasiu/ctm/static/. $out/ cp -r assets/littlechasiu/ctm/static/. $out/
''; '';
};
in {
modpacks = {
inherit notlite notlite-ctm-static;
};
}; };
in { in {
modpacks = { config.flake.overlays.modpacks = overlay;
inherit notlite notlite-ctm-static;
};
} }