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
./lib/nixfiles/module.nix
./pkgs/module.nix
./overlays
];
config = {
@ -221,44 +222,6 @@
# inputs is already defined
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
eachSystem = lib.genAttrs (import inputs.systems);
@ -305,8 +268,6 @@
inherit system;
});
overlays = import ./overlays self;
nixosConfigurations = {
iso = mkISOSystem "x86_64-linux";
}; # end nixosConfigurations

View File

@ -1,42 +1,68 @@
nixfiles: final: prev:
let
pkgs-unstable = import nixfiles.inputs.nixpkgs-unstable { config.allowUnfree = true; inherit (final) system; };
inherit (final) callPackage kdePackages lib;
{
config,
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
_callPackage = callPackage;
in { pkgname,
backport = let
_callPackage = callPackage;
in
{
pkgname,
callPackage ? _callPackage,
new ? pkgs-unstable,
override ? {} } : let
inherit (lib) getAttrFromPath;
inherit (builtins) getAttr isString;
override ? {},
}: let
inherit (lib) getAttrFromPath;
inherit (builtins) getAttr isString;
getAttr' = name: attrs: if isString pkgname then getAttr name attrs else getAttrFromPath name attrs;
oldPkg = getAttr' pkgname prev;
newPkg = getAttr' pkgname pkgs-unstable;
in if oldPkg.version == newPkg.version
then oldPkg
else (callPackage newPkg.override) override;
getAttr' = name: attrs:
if isString pkgname
then getAttr name attrs
else getAttrFromPath name attrs;
oldPkg = getAttr' pkgname prev;
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
stripJavaArchivesHook = final.makeSetupHook {
name = "strip-java-archives-hook";
propagatedBuildInputs = [ final.strip-nondeterminism ];
} ./strip-java-archives.sh;
in {
vesktop = backport' "vesktop";
obsidian = backport { pkgname="obsidian"; override.electron = final.electron_28; };
prismlauncher-unwrapped = backport {
pkgname = "prismlauncher-unwrapped";
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;
# defined locally to not pull in perl from unstable
stripJavaArchivesHook =
final.makeSetupHook {
name = "strip-java-archives-hook";
propagatedBuildInputs = [final.strip-nondeterminism];
}
./strip-java-archives.sh;
in {
vesktop = backport' "vesktop";
obsidian = backport {
pkgname = "obsidian";
override.electron = final.electron_28;
};
prismlauncher-unwrapped = backport {
pkgname = "prismlauncher-unwrapped";
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
inherit (nixfiles.inputs.nixpkgs) lib;
# this name is awful. maybe i don't know anything about functional
# programming or something, but the naming isn't very self explanatory
# - why is it "compose" instead of "combine"
# - why is it "extensions" instead of "overlays"
{
config,
lib,
...
}: let
inherit (lib) composeManyExtensions;
in rec {
backports = import ./backports.nix nixfiles;
mitigations = import ./mitigations.nix nixfiles;
modpacks = import ./modpacks.nix nixfiles;
default = composeManyExtensions [
backports
mitigations
cfg = config.flake.overlays;
in {
imports = [
./mitigations.nix
./backports.nix
./modpacks.nix
];
config.flake.overlays = {
default = with cfg; composeManyExtensions [
backports
mitigations
];
};
}

View File

@ -1,56 +1,89 @@
nixfiles: final: prev:
let
pkgsStable = import nixfiles.inputs.nixpkgs.outPath { inherit (prev) system; };
updateTime = nixfiles.inputs.nixpkgs-unstable.lastModified;
{
config,
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;
inherit (final) lib callPackage fetchFromGitHub;
inherit (lib) recurseIntoAttrs optionalAttrs
versionOlder versionAtLeast;
inherit (final) lib callPackage fetchFromGitHub;
inherit
(lib)
recurseIntoAttrs
optionalAttrs
versionOlder
versionAtLeast
;
pkgsFromFlake = flake: (import flake.outPath) { inherit (prev) system; };
pkgsFromInput = name: pkgsFromFlake nixfiles.inputs.${name};
pickFixed = ours: theirs: if versionAtLeast ours.version theirs.version then ours else theirs;
pickNewer = ours: theirs: if versionOlder theirs.version ours.version then ours else theirs;
pkgsFromFlake = flake: (import flake.outPath) {inherit (prev) system;};
pkgsFromInput = name: pkgsFromFlake nixfiles.inputs.${name};
pickFixed = ours: 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;
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
badPlugins = [ "gap" ];
itemInList = list: item: lib.any (x: x==item) list;
pluginFilter = name: value: (value.type or null == "derivation") && (!(itemInList badPlugins name)) && (!value.meta.broken);
filteredPlugins = lib.filterAttrs pluginFilter prev.gimpPlugins;
plugins = lib.mapAttrsToList (_: v: v) filteredPlugins;
in prev.gimp-with-plugins.override { inherit plugins; };
gimp-with-plugins-good = let
badPlugins = ["gap"];
itemInList = list: item: lib.any (x: x == item) list;
pluginFilter = name: value: (value.type or null == "derivation") && (!(itemInList badPlugins name)) && (!value.meta.broken);
filteredPlugins = lib.filterAttrs pluginFilter prev.gimpPlugins;
plugins = lib.mapAttrsToList (_: v: v) filteredPlugins;
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
# in nixfiles.inputs.nixpkgs.lib.filterAttrs (k: v: v != null) {
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;
};
in {
nix-du = let
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;
config.flake.overlays.mitigations = overlay;
}

View File

@ -1,27 +1,40 @@
nixfiles: 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;
};
{
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 (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 {
pname = "ctm-static";
version = "0.0.0";
src = final.emptyDirectory;
nativeBuildInputs = [ final.unzip ];
buildPhase = ''
unzip "${notlite}/mods/create-track-map-*.jar" 'assets/littlechasiu/ctm/static/*'
cp -r assets/littlechasiu/ctm/static/. $out/
'';
notlite-ctm-static = final.stdenvNoCC.mkDerivation {
pname = "ctm-static";
version = "0.0.0";
src = final.emptyDirectory;
nativeBuildInputs = [final.unzip];
buildPhase = ''
unzip "${notlite}/mods/create-track-map-*.jar" 'assets/littlechasiu/ctm/static/*'
cp -r assets/littlechasiu/ctm/static/. $out/
'';
};
in {
modpacks = {
inherit notlite notlite-ctm-static;
};
};
in {
modpacks = {
inherit notlite notlite-ctm-static;
};
config.flake.overlays.modpacks = overlay;
}