2024-06-17 07:40:18 +02:00
|
|
|
{ nixpkgsPath ? <nixpkgs> }:
|
|
|
|
|
2024-06-18 10:16:26 +02:00
|
|
|
let
|
|
|
|
defaultNixpkgsPath = nixpkgsPath;
|
|
|
|
in
|
|
|
|
|
2024-06-17 07:40:18 +02:00
|
|
|
self: super: {
|
|
|
|
selfExpr = let
|
|
|
|
config = builtins.removeAttrs self.config [ "_undeclared" ];
|
|
|
|
configJson = builtins.toJSON config;
|
2024-06-18 10:16:26 +02:00
|
|
|
|
|
|
|
getSelfExpr = {
|
|
|
|
useConfig ? true,
|
|
|
|
nixpkgsPath ? defaultNixpkgsPath,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
configText = ''
|
|
|
|
config = (builtins.fromJSON '''
|
|
|
|
${configJson}
|
|
|
|
''') // args.config or {};
|
|
|
|
'';
|
|
|
|
|
|
|
|
removedAttrNames = self.lib.optional useConfig "config";
|
|
|
|
removedAttrNamesText = builtins.toJSON removedAttrNames;
|
|
|
|
in ''
|
2024-06-17 07:40:18 +02:00
|
|
|
{ ... } @ args:
|
|
|
|
|
2024-07-07 09:08:49 +02:00
|
|
|
import ${nixpkgsPath} (
|
|
|
|
{
|
|
|
|
${self.lib.optionalString useConfig configText}
|
|
|
|
} // builtins.removeAttrs args (builtins.fromJSON '''
|
|
|
|
${removedAttrNamesText}
|
|
|
|
''')
|
|
|
|
)
|
2024-06-17 07:40:18 +02:00
|
|
|
'';
|
2024-06-18 10:16:26 +02:00
|
|
|
|
|
|
|
mkNixpkgsChannel = args: self.writeTextFile {
|
|
|
|
name = args.name or "nixpkgs-self";
|
|
|
|
destination = "/default.nix";
|
|
|
|
text = getSelfExpr args;
|
|
|
|
} // {
|
|
|
|
__functor = _: args: mkNixpkgsChannel args;
|
|
|
|
};
|
|
|
|
in mkNixpkgsChannel {};
|
2024-06-17 07:40:18 +02:00
|
|
|
}
|