2023-01-10 17:00:43 +00:00
|
|
|
{
|
|
|
|
inputs = {
|
2023-05-15 09:59:18 +00:00
|
|
|
# user is expected to define this from their flake via `inputs.nixpkgs.follows = ...`
|
2023-01-15 04:27:42 +00:00
|
|
|
nixpkgs = {};
|
2023-01-10 17:00:43 +00:00
|
|
|
};
|
2023-12-11 22:12:42 +00:00
|
|
|
outputs = { self, nixpkgs, variant ? "master" }@inputs:
|
2023-01-10 17:00:43 +00:00
|
|
|
let
|
|
|
|
patchedPkgsFor = system: nixpkgs.legacyPackages.${system}.applyPatches {
|
|
|
|
name = "nixpkgs-patched-uninsane";
|
2023-10-11 19:12:29 +00:00
|
|
|
version = self.lastModifiedDate;
|
2023-01-10 17:00:43 +00:00
|
|
|
src = nixpkgs;
|
2023-12-12 03:22:25 +00:00
|
|
|
patches = builtins.filter (p: p != null) (
|
|
|
|
nixpkgs.legacyPackages."${system}".callPackage ./list.nix { } variant self.lastModifiedDate
|
|
|
|
);
|
2023-01-10 17:00:43 +00:00
|
|
|
};
|
|
|
|
patchedFlakeFor = system: import "${patchedPkgsFor system}/flake.nix";
|
|
|
|
patchedFlakeOutputsFor = system:
|
2023-12-11 21:07:17 +00:00
|
|
|
(patchedFlakeFor system).outputs { self = self._forSystem system; };
|
2023-08-05 09:32:50 +00:00
|
|
|
|
|
|
|
extractBuildPlatform = nixosSystemArgs:
|
2023-12-11 21:07:17 +00:00
|
|
|
builtins.foldl'
|
|
|
|
(acc: mod: ((mod.nixpkgs or {}).buildPlatform or {}).system or acc)
|
|
|
|
(nixosSystemArgs.system or null)
|
|
|
|
(nixosSystemArgs.modules or []);
|
2023-01-10 17:00:43 +00:00
|
|
|
in
|
|
|
|
{
|
2023-12-11 21:07:17 +00:00
|
|
|
# i attempt to mirror the non-patched nixpkgs flake outputs,
|
|
|
|
# however the act of patching is dependent on the build system (can't be done in pure nix),
|
|
|
|
# hence a 100% compatible interface has to be segmented by `system`:
|
|
|
|
_forSystem = system: {
|
|
|
|
inherit (patchedFlakeOutputsFor system) lib;
|
|
|
|
legacyPackages = builtins.mapAttrs
|
|
|
|
(system': _:
|
|
|
|
(patchedFlakeOutputsFor (if system != null then system else system'))
|
|
|
|
.legacyPackages."${system'}"
|
|
|
|
)
|
|
|
|
nixpkgs.legacyPackages;
|
|
|
|
};
|
|
|
|
|
|
|
|
# although i can't expose all of the patched nixpkgs outputs without knowing the `system` to use for patching,
|
|
|
|
# several outputs learn about the system implicitly, so i can expose those:
|
|
|
|
lib.nixosSystem = args: (
|
|
|
|
self._forSystem (extractBuildPlatform args)
|
|
|
|
).lib.nixosSystem args;
|
2023-05-15 09:59:18 +00:00
|
|
|
|
2023-12-11 21:07:17 +00:00
|
|
|
legacyPackages = (self._forSystem null).legacyPackages;
|
2023-01-10 17:00:43 +00:00
|
|
|
};
|
|
|
|
}
|