AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[nix](unix)

Martin Hope
l0b0
Asked: 2022-10-05 17:43:44 +0800 CST

users.users.<name>.packages vs home-manager 包

  • 1

两者之间有什么实际区别吗

users.users.default.packages = [
  pkgs.foo
];

和

home-manager = {
  users.default = {
    config,
    pkgs,
    nixpkgs,
    lib,
    specialArgs,
    options,
    modulesPath,
    nixosConfig,
    osConfig,
  }: {
    home = {
      packages = [
        pkgs.foo
      ];
    };

  };
  useGlobalPkgs = true;
};
nix home-manager
  • 1 个回答
  • 37 Views
Martin Hope
l0b0
Asked: 2022-10-01 04:29:07 +0800 CST

如何在 nixpkgs 中使用新的 `pythonOutputDistHook`?

  • 1

我已经尝试了很多方法来让我的项目创建一个result-dist带有轮子的文件夹,我可以发布到 PyPI。不知何故,即使我使用的是 nixpkgs 版本pythonOutputDistHook,我也只能得到一个result文件夹,而不是result-dist文件夹。

到目前为止我的调查:

  1. pythonOutputDistHook是可选的,基于withDistOutput.

  2. withDistOutput如果format包含 之一,则为真["pyproject" "setuptools" "flit"]。

  3. format ? "setuptools"而且我的代码没有设置format,所以pythonOutputDistHook应该包括在内。

  4. 我已经验证了pythonOutputDistHook它在我的 nixpkgs中:

    $ cd nixpkgs
    $ git checkout 9c14978f845f33b152f722709caf42148580a30c
    HEAD is now at 9c14978f845 Merge master into staging-next
    $ git grep pythonOutputDistHook
    pkgs/development/interpreters/python/hooks/default.nix:  pythonOutputDistHook = callPackage ({ }:
    pkgs/development/interpreters/python/mk-python-derivation.nix:, pythonOutputDistHook
    pkgs/development/interpreters/python/mk-python-derivation.nix:      pythonOutputDistHook
    pkgs/top-level/python-packages.nix:    pythonOutputDistHook
    

有没有什么东西会pkgs在其中一个 Nix 文件中注入不同的参数?

nix
  • 1 个回答
  • 20 Views
Martin Hope
andreoss
Asked: 2022-01-15 04:59:25 +0800 CST

使用 nix-shell 时如何保留 PS1?

  • 0

nix-shell将 PS1 更改为自己的格式。

 [nix-shell:~/snm]$ 

我尝试在 ~/.bashrc 中添加对“$IN_NIX_SHELL”的检查,但没有奏效。

我发现的唯一解决方法是运行

nix-shell --run bash
nix nixos
  • 1 个回答
  • 291 Views
Martin Hope
l0b0
Asked: 2021-09-11 02:46:49 +0800 CST

如何在没有 Nix 重建的情况下暂时禁用自动升级?

  • 0

在计量连接上,能够禁用而无需重建整个系统并用完几 GB/天/$$$ 的信用额度,这将非常方便。system.autoUpgrade这可能吗?

nix nixos
  • 1 个回答
  • 108 Views
Martin Hope
Chris Stryczynski
Asked: 2020-02-29 12:08:10 +0800 CST

如何确定 Hydra 中为 Nix nixpkgs 缓存的软件包版本?

  • 5

我试图用旧的 nixpkgs 通道/分支(18.03)构建一个旧的 Haskell 项目。

在我第一次尝试构建它时,我将编译器版本指定为ghc843......但是在构建时 - 当我期望它来自缓存时,它似乎正在构建所有外部库。

幸运的是,我记得我之前遇到过这个问题:调试为什么 nix 在应该在 nixpkgs 二进制缓存中构建一个包时不必要地构建一个包?

问题基本上出在哪里,我使用的是 ghc 的“非默认”版本(Hydra 不会构建/缓存)。

所以现在我的问题是,我怎样才能找出什么是“默认”编译器版本——或者是 Hydra 构建/缓存的那个?

{
  nixpkgs ? import <nixpkgs> {}
, sources ? import ./nix/sources.nix
, compiler ? "ghc843" } :
let
  niv = import sources.nixpkgs {
    overlays = [
      (_ : _ : { niv = import sources.niv {}; })
    ] ;
    config = {};
  };
  pkgs = niv.pkgs;
  myHaskellPackages = pkgs.haskell.packages.${compiler}.override {
  };
in
(myHaskellPackages.callCabal2nix "abc" (./.) {})

碰巧我尝试ghc823了这似乎是默认设置(或者至少在 Hydra 中缓存了资产)。


我想出了如何使用 nix repl 列出可用的 ghc 编译器版本,如下所示:

nix-repl> yolo = (import nix/sources.nix {}) 
nix-repl> yolo.blablaTestTabCompletion
nix-repl> yolo2 = (import yolo.nixpkgs {})
nix-repl> yolo2.haskell.packages.
yolo2.haskell.packages.ghc7103         yolo2.haskell.packages.ghc843
yolo2.haskell.packages.ghc7103Binary   yolo2.haskell.packages.ghcHEAD
yolo2.haskell.packages.ghc802          yolo2.haskell.packages.ghcjs
yolo2.haskell.packages.ghc821Binary    yolo2.haskell.packages.ghcjsHEAD
yolo2.haskell.packages.ghc822          yolo2.haskell.packages.integer-simple
yolo2.haskell.packages.ghc841
nix nixos
  • 1 个回答
  • 678 Views
Martin Hope
Chris Stryczynski
Asked: 2020-02-21 10:35:22 +0800 CST

如何将频道回滚到上一代 Nixos?

  • 3
$ sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
...
 600   2020-01-25 21:01:11   
 601   2020-02-03 13:44:19   
 602   2020-02-09 14:06:20   
 603   2020-02-09 14:11:11   
 604   2020-02-11 00:02:43   
 605   2020-02-13 12:26:22   
 606   2020-02-16 16:40:02   (current)

我怎样才能获得 Nixos 一代的提交/频道生成(这是一件事吗?) - 并可能将频道回滚到它?

或者换句话说,我怎样才能将我的“通道状态”回滚到第 605 代时的状态?


为什么我想知道是因为我做了一个sudo nix-channel --update,sudo nixos-rebuild switch几天前 - 无论发生什么包更新 - 导致系统不稳定。

所以为了缓解这种情况,我启动并继续使用老一代(605)。

我现在想更新我的 Nixos 系统配置中的特定包,并将更改基于605而不是最新的606.


我确实找到了https://stackoverflow.com/questions/39090387/how-to-undo-nix-channel-update ( nix-channel --rollback..) 但是我可能已经更新了几次频道 - 所以“最后一个”频道状态可能不是什么我需要。

我确实注意到您可以指定通道代号作为此命令的参数 - 但我不确定它与 nixos 代之间的关系是什么?它似乎与我尝试605的结果不同:

sudo nix-channel --rollback 605
error: generation 605 does not exist
error: program '/nix/store/cs47wjxwiqgyl1nkjnksyf3s2rb93piq-nix-2.3.2/bin/nix-env' failed with exit code 1
nix nixos
  • 2 个回答
  • 1330 Views
Martin Hope
Chris Stryczynski
Asked: 2020-01-15 12:07:51 +0800 CST

如何列出构建生成中引用的所有 nix 存储路径?

  • 1

我正在尝试调试一个问题,其中一台机器上的 nixos 配置在路径中具有可访问的应用程序(它在 中列出/run/current-system/sw/bin),而在具有相同 nixos 配置(减号hardware-configuration.nix等)的另一台机器上却没有。

如何查询 Nixos 一代的所有商店路径?这将通过在机器之间进行比较来帮助我调试问题。

nix nixos
  • 1 个回答
  • 377 Views
Martin Hope
Szilan
Asked: 2019-12-26 04:56:37 +0800 CST

通过 nix home-manager 定义的 vimrc 中的空字符串语法

  • 0

我想使用 home-manager 在带有 extraConfig 选项的 nix-expression 中声明我的 vim 配置。我正在尝试从 coc.nvim 运行示例 .vimrc 配置,其中一行显示:

设置状态行^=%{coc#status()}%{get(b:,'coc_current_function','')}

在最小的 home.nix 中,我将其设置为:

{ config, pkgs, ... }:

{
  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;

  home.packages = [ 
    pkgs.nodejs
  ];

programs.vim = { 
    enable = true;
    plugins = [
      pkgs.vimPlugins.coc-nvim
    ];
    extraConfig = ''
" Add status line support, for integration with other plugin, checkout `:h coc-status`
set statusline^=%{coc"status()}%{get(b:,'coc_current_function','')}
      '';
  };
}

不幸的是,空的 vim 字符串关闭了多行 nix 字符串并留下home-manager build switch:

error: syntax error, unexpected ')', expecting ';', at /home/demo/.config/nixpkgs/home.nix:18:66

我已经尝试在 get 函数中替换''with "",但 vim 不喜欢这样:

E540: Unclosed expression sequence: statusline^=%{coc
nix vimrc
  • 1 个回答
  • 180 Views
Martin Hope
Chris Stryczynski
Asked: 2019-12-19 13:51:55 +0800 CST

如何在 nix 派生中克隆私有 git 存储库

  • 4
{
  nixpkgs ? import <nixpkgs> {}
}:nixpkgs.pkgs.fetchgitPrivate {
        url = "ssh://[email protected]/trycatchchris/blog.git";
        rev = "0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716";
        sha256 = "02951e82c1183aaf1ce4b9669bf9ae32e50c4c641550797eed37739cd4528b58";
      }

我有上面的 nix 表达式,其中 repo 是一个私有 git 存储库。

我确实可以通过我的用户的公钥访问此存储库。

如果我尝试常规nix-build:

nix-build
trace: Please set your nix-path such that ssh-config-file points to a file that will allow ssh to access private repositories. The builder will not be able to see any running ssh agent sessions unless ssh-auth-sock is also set in the nix-path.

Note that the config file and any keys it points to must be readable by the build user, which depending on your nix configuration means making it readable by the build-users-group, the user of the running nix-daemon, or the user calling the nix command which started the build. Similarly, if using an ssh agent ssh-auth-sock must point to a socket the build user can access.

You may need StrictHostKeyChecking=no in the config file. Since ssh will refuse to use a group-readable private key, if using build-users you will likely want to use something like IdentityFile /some/directory/%u/key and have a directory for each build user accessible to that user.

these derivations will be built:
  /nix/store/hlnshdb0ckckih46cv66xj8pyqds6w7y-blog-0f5fe7e.drv
building '/nix/store/hlnshdb0ckckih46cv66xj8pyqds6w7y-blog-0f5fe7e.drv'...
exporting ssh://[email protected]/trycatchchris/blog.git (rev 0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716) into /nix/store/mkinydhkdyg6dyw7fp399m90qw5bsbqd-blog-0f5fe7e
Initialized empty Git repository in /nix/store/mkinydhkdyg6dyw7fp399m90qw5bsbqd-blog-0f5fe7e/.git/
Can't open user config file /var/lib/empty/config: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Can't open user config file /var/lib/empty/config: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Unable to checkout 0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716 from ssh://[email protected]/trycatchchris/blog.git.
builder for '/nix/store/hlnshdb0ckckih46cv66xj8pyqds6w7y-blog-0f5fe7e.drv' failed with exit code 1
error: build of '/nix/store/hlnshdb0ckckih46cv66xj8pyqds6w7y-blog-0f5fe7e.drv' failed

我尝试过使用 ssh 代理以及(来自https://github.com/NixOS/nixpkgs/issues/4004#issuecomment-236434045):

创建一个ssh包含以下内容的文件:

Host gitlab.com
  StrictHostKeyChecking No
  UserKnownHostsFile /dev/null
  IdentityFile /home/chris/.ssh/id_rsa

并运行:

nix-build -I ssh-config-file=$PWD/ssh           
these derivations will be built:
  /nix/store/ng4qdayni3a69b57kfmrvf4ba03ryfv9-blog-0f5fe7e.drv
building '/nix/store/ng4qdayni3a69b57kfmrvf4ba03ryfv9-blog-0f5fe7e.drv'...
exporting ssh://[email protected]/trycatchchris/blog.git (rev 0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716) into /nix/store/mkinydhkdyg6dyw7fp399m90qw5bsbqd-blog-0f5fe7e
Initialized empty Git repository in /nix/store/mkinydhkdyg6dyw7fp399m90qw5bsbqd-blog-0f5fe7e/.git/
Can't open user config file /home/chris/temp/wiptemp/11/ssh: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Can't open user config file /home/chris/temp/wiptemp/11/ssh: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Unable to checkout 0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716 from ssh://[email protected]/trycatchchris/blog.git.
builder for '/nix/store/ng4qdayni3a69b57kfmrvf4ba03ryfv9-blog-0f5fe7e.drv' failed with exit code 1
error: build of '/nix/store/ng4qdayni3a69b57kfmrvf4ba03ryfv9-blog-0f5fe7e.drv' failed

然而这也失败了......我如何使用上述方法或其他方法克隆私人仓库?

nix
  • 1 个回答
  • 2711 Views
Martin Hope
Jonathan
Asked: 2019-12-06 11:32:48 +0800 CST

在 Nix 中,如何构建具有 Python 安装后脚本的包?

  • 1

我正在尝试为Foliate进行 Nix 派生,这是我的第一个真正的派生,所以我还不知道我在做什么。

这是我到目前为止所拥有的。它构建并安装,但失败并出现以下错误:

Running custom install script '/build/source/build-aux/meson/postinstall.py'
Failed to run install script '/build/source/build-aux/meson/postinstall.py'
FAILED: meson-install
/nix/store/2b4cdbcs1xbqjna5dr4qrr1p9p9bgm98-meson-0.51.2/bin/meson install --no-rebuild
ninja: build stopped: subcommand failed.
builder for '/nix/store/32vn9xlxlk9zb7vmpm90bz5i5qq59fjc-foliate-1.5.3.drv' failed with exit code 1
error: build of '/nix/store/32vn9xlxlk9zb7vmpm90bz5i5qq59fjc-foliate-1.5.3.drv' failed

我尝试添加python3为构建依赖项,但这似乎不起作用。我错过了什么?

另外,还有其他方法可以改进或简化这种推导吗?

nix nixos
  • 1 个回答
  • 594 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve