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,35 +1,58 @@
nixfiles: final: prev: {
let config,
pkgs-unstable = import nixfiles.inputs.nixpkgs-unstable { config.allowUnfree = true; inherit (final) system; }; 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; 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 ? {},
}: let
inherit (lib) getAttrFromPath; inherit (lib) getAttrFromPath;
inherit (builtins) getAttr isString; inherit (builtins) getAttr isString;
getAttr' = name: attrs: if isString pkgname then getAttr name attrs else getAttrFromPath name attrs; getAttr' = name: attrs:
if isString pkgname
then getAttr name attrs
else getAttrFromPath name attrs;
oldPkg = getAttr' pkgname prev; oldPkg = getAttr' pkgname prev;
newPkg = getAttr' pkgname pkgs-unstable; newPkg = getAttr' pkgname pkgs-unstable;
in if oldPkg.version == newPkg.version in
if oldPkg.version == newPkg.version
then oldPkg then oldPkg
else (callPackage newPkg.override) override; 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 =
final.makeSetupHook {
name = "strip-java-archives-hook"; name = "strip-java-archives-hook";
propagatedBuildInputs = [ final.strip-nondeterminism ]; propagatedBuildInputs = [final.strip-nondeterminism];
} ./strip-java-archives.sh; }
./strip-java-archives.sh;
in { in {
vesktop = backport' "vesktop"; vesktop = backport' "vesktop";
obsidian = backport { pkgname="obsidian"; override.electron = final.electron_28; }; obsidian = backport {
pkgname = "obsidian";
override.electron = final.electron_28;
};
prismlauncher-unwrapped = backport { prismlauncher-unwrapped = backport {
pkgname = "prismlauncher-unwrapped"; pkgname = "prismlauncher-unwrapped";
inherit (kdePackages) callPackage; inherit (kdePackages) callPackage;
@ -39,4 +62,7 @@ in {
inherit (final.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
./modpacks.nix
];
config.flake.overlays = {
default = with cfg; composeManyExtensions [
backports backports
mitigations mitigations
]; ];
};
} }

View File

@ -1,39 +1,66 @@
nixfiles: final: prev: {
let config,
pkgsStable = import nixfiles.inputs.nixpkgs.outPath { inherit (prev) system; }; lib,
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; 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 # this also causes an infinite recursion and i have no idea why
# in nixfiles.inputs.nixpkgs.lib.filterAttrs (k: v: v != null) { # in nixfiles.inputs.nixpkgs.lib.filterAttrs (k: v: v != null) {
in { in {
nix-du = let nix-du = let
old = prev.nix-du; old = prev.nix-du;
new = (pkgsFromInput "nixpkgs-nix-du").nix-du; new = (pkgsFromInput "nixpkgs-nix-du").nix-du;
in pickNewer old new; in
pickNewer old new;
gimp-with-plugins = gimp-with-plugins-good; gimp-with-plugins = gimp-with-plugins-good;
@ -41,16 +68,22 @@ in {
stable = pkgsStable.nwg-displays; stable = pkgsStable.nwg-displays;
unstable = prev.nwg-displays; unstable = prev.nwg-displays;
now = 1739114541; now = 1739114541;
in hold now 7 stable unstable; in
hold now 7 stable unstable;
libreoffice = let libreoffice = let
stable = pkgsStable.libreoffice; stable = pkgsStable.libreoffice;
unstable = prev.libreoffice; unstable = prev.libreoffice;
now = 1739558971; now = 1739558971;
in hold now 7 stable unstable; in
hold now 7 stable unstable;
redlib = let redlib = let
redlib-new = final.callPackage nixfiles.packages.${prev.system}.redlib.override {}; redlib-new = final.callPackage nixfiles.packages.${prev.system}.redlib.override {};
inherit (prev) redlib; inherit (prev) redlib;
in pickNewer redlib-new redlib; in
pickNewer redlib-new redlib;
};
in {
config.flake.overlays.mitigations = overlay;
} }

View File

@ -1,11 +1,21 @@
nixfiles: final: prev: {
let config,
lib,
self,
inputs,
...
}: let
# TODO legacy refactor
# not high priority, this still works well for this overlay.
nixfiles = self;
overlay = final: prev: let
inherit (final) lib; inherit (final) lib;
inherit (lib) fakeHash; inherit (lib) fakeHash;
notlite = let notlite = let
commit = "0e42bfbc6189db5848252d7dc7a638103d9d44ee"; commit = "0e42bfbc6189db5848252d7dc7a638103d9d44ee";
packHash = "sha256-X9a7htRhJcSRXu4uDvzSjdjCyWg+x7Dqws9pIlQtl6A="; packHash = "sha256-X9a7htRhJcSRXu4uDvzSjdjCyWg+x7Dqws9pIlQtl6A=";
in final.fetchPackwizModpack { in
final.fetchPackwizModpack {
url = "https://gitea.protogen.io/nullbite/notlite/raw/commit/${commit}/pack.toml"; url = "https://gitea.protogen.io/nullbite/notlite/raw/commit/${commit}/pack.toml";
inherit packHash; inherit packHash;
}; };
@ -14,14 +24,17 @@ let
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 { in {
modpacks = { modpacks = {
inherit notlite notlite-ctm-static; inherit notlite notlite-ctm-static;
}; };
};
in {
config.flake.overlays.modpacks = overlay;
} }