From 9cd9d8fe3cca6b03618ca3a7014f55f63983737f Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Mon, 17 Jun 2024 07:40:18 +0200 Subject: [PATCH] pkgs/overlay: create selfExpr adds a package that references nixpkgs config of nixpkgs that created it is retained --- pkgs/overlays/selfExpr.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pkgs/overlays/selfExpr.nix diff --git a/pkgs/overlays/selfExpr.nix b/pkgs/overlays/selfExpr.nix new file mode 100644 index 0000000..391f32c --- /dev/null +++ b/pkgs/overlays/selfExpr.nix @@ -0,0 +1,21 @@ +{ nixpkgsPath ? }: + +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" ] + ''; + }; +}