捆绑器的nix覆盖

时间:2018-03-09 15:39:42

标签: nix nixos

我想为Ruby import urllib def read_text (): quotes = open ("C:\Users\HP\Downloads\book\just.txt") contents_of_file = quotes.read() print("content_of_file") quotes.close() check_profanity(contents_of_file) def check_profanity(text_to_check): connection = urllib.urlopen("http://www.wdylike.appspot.com/?q="+text_to_check) output = connecting.read() print(output) connection.close() read_text() 包创建一个nix覆盖,因为nixpkgs(unstable)中当前上游的版本是旧版本而不是我需要的版本:

https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/bundler/default.nix

我正在尝试在nix-shell中运行一个名为bundler的本地派生,这取决于较新版本的foo

./ custom_packages.nix:

bundler

./ nixpkgs-version.json

{ system ? builtins.currentSystem }:

# Pinning Nixpkgs to a specific version.
let
  hostPkgs = import <nixpkgs> {};
  pinnedVersion = hostPkgs.lib.importJSON ./nixpkgs-version.json;
  pinnedPkgs = hostPkgs.fetchFromGitHub {
    owner = "NixOS";
    repo = "nixpkgs-channels";
    inherit (pinnedVersion) rev sha256;
  };

in
  with import pinnedPkgs {overlays = [
    (self: super: {
      bundler = self.callPackage ./pkgs/bundler/1_16_1 {};
    })
  ];};

rec {
  foo = callPackage ./pkgs/foo { };
}

./ PKGS /捆绑/ 1_16_1 / default.nix:

{
  "url": "https://github.com/nixos/nixpkgs-channels.git",
  "rev": "a66ce38acea505c4b3bfac9806669d2ad8b34efa",
  "date": "2018-03-04T07:45:36+00:00",
  "sha256": "1jrz6lkhx64mvm0h4gky9b6iaazivq69smppkx33hmrm4553dx5h",
  "fetchSubmodules": true
}

./ PKGS /富/ default.nix:

{ buildRubyGem, makeWrapper, ruby, coreutils }:

buildRubyGem rec {
  inherit ruby;
  name = "${gemName}-${version}";
  gemName = "bundler";
  version = "1.16.1";
  sha256 = "1s2nq4qnffxg3kwrk7cnwxcvfihlhxm9absl2l6d3qckf3sy1f22";
  dontPatchShebangs = true;

  postFixup = ''
    sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
  '';
}

运行nix shell:

{ mkShell, bundler }:

mkShell rec {
  name = "scribble-${version}";
  version = "1.0.0-beta";
  buildInputs = [bundler];
}

在构建$ nix-shell ./custom_packages.nix -A foo --command "bundle --version" --pure 时尝试在nix-shell中运行foo会产生错误,这会通知我bundler具有:bundler。这告诉我,我错误地将捆绑器识别为“标准”派生 - 但显然不是。我猜想在定义叠加层时使用attribute ‘source’ missing可能是错误的做法 - 但我不确定另一种方法。

任何人都可以建议我如何使用更新版本覆盖callPackage(理想情况下使用叠加层)。

仅供参考:我在macOS 10.12.6上使用nix包管理器

由于

0 个答案:

没有答案