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";
|
2024-03-05 00:06:08 +00:00
|
|
|
version = nixpkgs.sourceInfo.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) (
|
2023-12-12 09:18:35 +00:00
|
|
|
nixpkgs.legacyPackages."${system}".callPackage ./list.nix { } variant nixpkgs.lastModifiedDate
|
2023-12-12 03:22:25 +00:00
|
|
|
);
|
2023-01-10 17:00:43 +00:00
|
|
|
};
|
|
|
|
patchedFlakeFor = system: import "${patchedPkgsFor system}/flake.nix";
|
2024-02-27 10:34:20 +00:00
|
|
|
patchedFlakeOutputsFor = system: (patchedFlakeFor system).outputs {
|
|
|
|
self = 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;
|
2024-03-05 00:06:08 +00:00
|
|
|
|
|
|
|
# sourceInfo includes fields (square brackets for the ones which are not always present):
|
|
|
|
# - [dirtyRev]
|
|
|
|
# - [dirtyShortRev]
|
|
|
|
# - lastModified
|
|
|
|
# - lastModifiedDate
|
|
|
|
# - narHash
|
|
|
|
# - outPath
|
|
|
|
# - [rev]
|
|
|
|
# - [revCount]
|
|
|
|
# - [shortRev]
|
|
|
|
# - submodules
|
|
|
|
#
|
|
|
|
# these values are used within nixpkgs:
|
|
|
|
# - to give a friendly name to the nixos system (`readlink /run/current-system` -> `...nixos-system-desko-24.05.20240227.dirty`)
|
|
|
|
# - to alias `import <nixpkgs>` so that nix uses the system's nixpkgs when called externally (supposedly).
|
|
|
|
#
|
|
|
|
# these values seem to exist both within the `sourceInfo` attrset and at the top-level.
|
|
|
|
# for a list of all implicit flake outputs (which is what these seem to be):
|
|
|
|
# $ nix-repl
|
|
|
|
# > lf .
|
|
|
|
# > <tab>
|
|
|
|
inherit (nixpkgs) sourceInfo;
|
|
|
|
} // nixpkgs.sourceInfo;
|
2023-01-10 17:00:43 +00:00
|
|
|
}
|