overlays/selfExpr: allow providing options
This commit is contained in:
parent
672807280e
commit
9e59fd06af
1 changed files with 32 additions and 10 deletions
|
@ -1,21 +1,43 @@
|
||||||
{ nixpkgsPath ? <nixpkgs> }:
|
{ nixpkgsPath ? <nixpkgs> }:
|
||||||
|
|
||||||
|
let
|
||||||
|
defaultNixpkgsPath = nixpkgsPath;
|
||||||
|
in
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
selfExpr = let
|
selfExpr = let
|
||||||
config = builtins.removeAttrs self.config [ "_undeclared" ];
|
config = builtins.removeAttrs self.config [ "_undeclared" ];
|
||||||
configJson = builtins.toJSON config;
|
configJson = builtins.toJSON config;
|
||||||
in
|
|
||||||
self.writeTextFile {
|
getSelfExpr = {
|
||||||
name = "nixpkgs-self";
|
useConfig ? true,
|
||||||
destination = "/default.nix";
|
nixpkgsPath ? defaultNixpkgsPath,
|
||||||
text = ''
|
...
|
||||||
|
}: let
|
||||||
|
configText = ''
|
||||||
|
config = (builtins.fromJSON '''
|
||||||
|
${configJson}
|
||||||
|
''') // args.config or {};
|
||||||
|
'';
|
||||||
|
|
||||||
|
removedAttrNames = self.lib.optional useConfig "config";
|
||||||
|
removedAttrNamesText = builtins.toJSON removedAttrNames;
|
||||||
|
in ''
|
||||||
{ ... } @ args:
|
{ ... } @ args:
|
||||||
|
|
||||||
import ${builtins.toString nixpkgsPath} {
|
import ${builtins.toString nixpkgsPath} {
|
||||||
config = (builtins.fromJSON '''
|
${self.lib.optionalString useConfig configText}
|
||||||
${configJson}
|
} // builtins.removeAttrs args (builtins.fromJSON '''
|
||||||
''') // args.config or {};
|
${removedAttrNamesText}
|
||||||
} // builtins.removeAttrs args [ "config" ]
|
''')
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
|
mkNixpkgsChannel = args: self.writeTextFile {
|
||||||
|
name = args.name or "nixpkgs-self";
|
||||||
|
destination = "/default.nix";
|
||||||
|
text = getSelfExpr args;
|
||||||
|
} // {
|
||||||
|
__functor = _: args: mkNixpkgsChannel args;
|
||||||
|
};
|
||||||
|
in mkNixpkgsChannel {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue