pkgs/overlay: create selfExpr

adds a package that references nixpkgs
config of nixpkgs that created it is retained
This commit is contained in:
Wroclaw 2024-06-17 07:40:18 +02:00
parent 88f348a2c9
commit 9cd9d8fe3c

View file

@ -0,0 +1,21 @@
{ nixpkgsPath ? <nixpkgs> }:
self: super: {
selfExpr = let
config = builtins.removeAttrs self.config [ "_undeclared" ];
configJson = builtins.toJSON config;
in
self.writeTextFile {
name = "nixpkgs-self";
destination = "/default.nix";
text = ''
{ ... } @ args:
import ${builtins.toString nixpkgsPath} {
config = (builtins.fromJSON '''
${configJson}
''') // args.config or {};
} // builtins.removeAttrs args [ "config" ]
'';
};
}