這可能很簡單,但是在嘗試了解我需要將 stack/cabal 與 haskell 一起使用的兩個小時后,我沒有管理如何在運行時提供我的 python 包所需的完整 pandoc 安裝......
我的實際薄片是
{
description = "Application packaged using poetry2nix";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
inputs.poetry.url = "github:nix-community/poetry2nix";
outputs = inputs@{ self, nixpkgs, flake-utils, poetry }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ poetry.overlay ]; };
inherit (pkgs) poetry2nix;
in {
defaultPackage = poetry2nix.mkPoetryApplication {
projectDir = ./.;
python = pkgs.python39;
propagatedBuildInputs = [
pkgs.haskellPackages.pandoc_2_14_2
pkgs.graphviz
pkgs.bash
pkgs.wget
pkgs.findutils
];
};
}
);
}
nix build在薄片上回傳此錯誤。
? nix build
warning: Git tree '/home/reyman/Projets/notebook-wiki' is dirty
error: builder for '/nix/store/v4kl1d521p30d29zp7c55mcpiwqpzgkf-pandoc-2.14.2.drv' failed with exit code 1;
last 10 log lines:
> confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:65:5 in Cabal-3.2.1.0:Distribution.Simple.UserHooks
> configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:180:19 in Cabal-3.2.1.0:Distribution.Simple
> defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:116:27 in Cabal-3.2.1.0:Distribution.Simple
> defaultMain, called at Setup.hs:2:8 in main:Main
> Setup: Encountered missing or private dependencies:
> citeproc ==0.5.*,
> doctemplates ==0.10.*,
> skylighting ==0.11.*,
> skylighting-core ==0.11.*
>
For full logs, run 'nix log /nix/store/v4kl1d521p30d29zp7c55mcpiwqpzgkf-pandoc-2.14.2.drv'.
error: 1 dependencies of derivation '/nix/store/vkiqdmii0cfi6vzsx0whrxmnwi20kplz-python3.9-notebook-wiki-0.0.1.drv' failed to build
我嘗試添加pkgs.haskellPackages.citeproc沒有成功,所以這是haskellPackages的依賴問題。
更新 1:
好的,我開始了漫長的創作之路:
- 一個編譯 pandoc 的薄片 (A)。
- 一片 (B) 與我使用 (A) 的 python 腳本
(A) 的步驟如下:
a) 安裝 haskell.nix : nix build -f https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz pkgs.haskell-nix.nix-tools.ghc884 --out-link nt
b) 克隆 pandoc
c)flake.nix在同一個檔案夾中創建一個帶有代碼底部的薄片
d) 運行 nix build
{
description = "PandocProject";
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils, haskellNix }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
overlays = [ haskellNix.overlay
(final: prev: {
# This overlay adds our project to pkgs
pandocProject = final.haskell-nix.cabalProject {
cabalProjectFreeze = null;
cabalProject = null;
cabalProjectLocal = null;
compiler-nix-name = "ghc8104";
name = "pandocProject";
src = final.fetchFromGitHub {
name = "pandoc";
owner = "jgm";
repo = "pandoc";
rev = "d05460d00d7c9af3b4913f1760ea385a7d855d84";
sha256 = "1a3kwag6j13b42zhzxiwlzabsc6c9jppiwv9j8gbnf2k1yb84kdm";
};
pkg-def-extras = with final.haskell.lib; [];
};
})
];
pkgs = import nixpkgs { inherit system overlays; };
flake = pkgs.pandocProject.flake {};
in flake // {
# Built by `nix build .`
defaultPackage = flake.packages."pandoc:exe:pandoc";
});
}
現在,我正在嘗試將poetry2nix flakes 和這個pandoc flakes 聯系起來。
uj5u.com熱心網友回復:
當您想“鏈接”兩個薄片時,最好的方法是使用overlays。我已經修改了你的薄片并將它們發布在這個答案下面。現在你只需要修改片 B,這樣它就會使用片 A 的疊加,但這更像是一個haskell.nix問題。值得注意的是“技巧”,我已經使用了合并兩個疊加層,以便將片 A 中的詩歌 2nix 疊加傳播到片 B。
片狀A:
{
description = "Application packaged using poetry2nix";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
inputs.poetry.url = "github:nix-community/poetry2nix";
outputs = inputs@{ self, nixpkgs, flake-utils, poetry }:
let
overlay = final: prev: ({
# FIXME: Change to some more verbose name
somePythonApp = final.poetry2nix.mkPoetryApplication {
projectDir = ./.;
python = prev.python39;
propagatedBuildInputs = [
prev.haskellPackages.pandoc_2_14_2
prev.graphviz
prev.bash
prev.wget
prev.findutils
];
};
} //
# This is kind of ugly, but required as it is not possible to return array in flake
# It merges poetry overlay with this overlay
(poetry.overlay final prev));
in
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ overlay ]; };
in
{
defaultPackage = pkgs.somePythonApp;
}
) // {
# Provide overlay outside of flake-utils so that it will not have
# system prefix.
inherit overlay;
};
}
片狀B:
{
description = "PandocProject";
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.my-cool-python-script.url = "path:/home/mateusz/so/flakeA"; # FIXME: Change to your url
outputs = { self, nixpkgs, flake-utils, haskellNix, my-cool-python-script }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
overlays = [
my-cool-python-script.overlay
haskellNix.overlay
(final: prev: {
# This overlay adds our project to pkgs
pandocProject = final.haskell-nix.cabalProject {
cabalProjectFreeze = null;
cabalProject = null;
cabalProjectLocal = null;
# In the `final` attribute there is your python script !
# Not sure how you want to use it
# It is avaible as `final.somePythonApp`
compiler-nix-name = "ghc8104";
name = "pandocProject";
src = final.fetchFromGitHub {
name = "pandoc";
owner = "jgm";
repo = "pandoc";
rev = "d05460d00d7c9af3b4913f1760ea385a7d855d84";
sha256 = "1a3kwag6j13b42zhzxiwlzabsc6c9jppiwv9j8gbnf2k1yb84kdm";
};
pkg-def-extras = with final.haskell.lib; [ ];
};
})
];
pkgs = import nixpkgs { inherit system overlays; };
flake = pkgs.pandocProject.flake { };
in
flake // {
# Built by `nix build .`
defaultPackage = flake.packages."pandoc:exe:pandoc";
});
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/359171.html
