gpt4 book ai didi

nixos - 在我的存储库中实现覆盖

转载 作者:行者123 更新时间:2023-12-04 16:09:55 27 4
gpt4 key购买 nike

我想要的是

https://nixos.org/nixpkgs/manual/#sec-pkg-overrideAttrs文件 overrideAttrs它可以与 top-level/all-packages.nix 一起使用.

所以我希望能够在我自己的 nixpkgs 覆盖中使用 overrideAttrs!

编码

rec {
frontend = pkgs.callPackage "${nixcloud-frontend}/release.nix" {
inherit nixcloud-editor;
};

AAA = frontend.overrideAttrs (oldAttrs: rec {
API_HOST="wss://";
});

helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec {
separateDebugInfo = true;
});

}

问题

但问题是评估 AAA不会工作:
nix-build nixcloud-pkgs.nix -A AAA
error: attribute ‘overrideAttrs’ missing, at /home/joachim/Desktop/projects/nixcloud/nixcloud-webservices/nixcloud-pkgs.nix:17:9

相反,评估 helloWithDebug作品:
nix-build nixcloud-pkgs.nix -A helloWithDebug
these derivations will be built:
/nix/store/x01q7lfqbwlj08iknph37jxh2bk3il68-hello-2.10.drv
these paths will be fetched (0.69 MiB download, 0.69 MiB unpacked):
/nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz

暗示

在 nixpkgs 我看到:
lib/customisation.nix用于 lib/default.nix我还不能说它是在哪里注入(inject)的。

黑客攻击

要查看堆栈,我刚刚将破坏代码添加到 lib/customisation.nix 中:
nix-build -I nixpkgs=../nixpkgs -A tests --show-trace                                                                 ~/Desktop/projects/nixos/nixpkgs
error: while evaluating anonymous function at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/top-level/impure.nix:15:1, called from undefined position:
while evaluating anonymous function at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/top-level/default.nix:20:1, called from /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/top-level/impure.nix:64:1:
while evaluating anonymous function at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:42:1, called from /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/top-level/default.nix:97:10:
while evaluating ‘dfold’ at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:60:27, called from /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:104:4:
while evaluating ‘go’ at /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:63:18, called from /home/joachim/Desktop/projects/nixos/nixpkgs/pkgs/stdenv/booter.nix:71:8:
while evaluating the file ‘/home/joachim/Desktop/projects/nixos/nixpkgs/lib/default.nix’:
syntax error, unexpected ID, expecting '.' or '=', at /home/joachim/Desktop/projects/nixos/nixpkgs/lib/customisation.nix:37:3

最佳答案

我最后做了什么

cat nixcloud-pkgs.nix
{ pkgs ? import <nixpkgs> {}
, nixcloud-backend ? pkgs.stdenv.lib.cleanSource ../nixcloud-backend
, nixcloud-frontend ? pkgs.stdenv.lib.cleanSource ../nixcloud-frontend
, nixcloud-editor ? pkgs.stdenv.lib.cleanSource ../nixcloud-editor
, nixcloud-container ? pkgs.stdenv.lib.cleanSource ../nixcloud-container
, ...
} @ args:
let
nc-backend = nixcloud-backend;
nc-frontend = nixcloud-frontend;

newpkgs = import pkgs.path { overlays = [ (self: super: {
nixcloud-backend = super.callPackage nc-backend { inherit newpkgs; };
nixcloud-frontend = super.callPackage "${nc-frontend}/release.nix" {
inherit nixcloud-editor;
};

} ) ]; };
in newpkgs

评估这个
nix-build nixcloud-pkgs.nix -A nixcloud-frontend

使用覆盖
cat nixcloud-pkgs.nix
{ pkgs ? import <nixpkgs> {}
, nixcloud-backend ? pkgs.stdenv.lib.cleanSource ../nixcloud-backend
, nixcloud-frontend ? pkgs.stdenv.lib.cleanSource ../nixcloud-frontend
, nixcloud-editor ? pkgs.stdenv.lib.cleanSource ../nixcloud-editor
, nixcloud-container ? pkgs.stdenv.lib.cleanSource ../nixcloud-container
, ...
} @ args:
let
nc-backend = nixcloud-backend;
nc-frontend = nixcloud-frontend;

newpkgs = import pkgs.path { overlays = [ (self: super: {
nixcloud-backend = super.callPackage nc-backend { inherit newpkgs; };
nixcloud-frontend = supber.callPackage "${nc-frontend}/release.nix" {
inherit nixcloud-editor;
};

} ) ]; };
in newpkgs.nixcloud-frontend.override (oldAttrs: rec {
API_HOST="wss://....";
})

评估这个
nix-build nixcloud-pkgs.nix

文件

另请参阅 https://github.com/NixOS/nixpkgs/pull/26321讨论这个的地方

关于nixos - 在我的存储库中实现覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44316127/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com