Skip to content

Trouble with required executable protoc #1257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
trodrigu opened this issue Sep 29, 2021 · 2 comments
Closed

Trouble with required executable protoc #1257

trodrigu opened this issue Sep 29, 2021 · 2 comments

Comments

@trodrigu
Copy link

Hello, I'm reaching out for help with a default.nix file. I'm trying to nix-build -A three-layer.components.exes.three-layer-exe https://github.com/trodrigu/three-layer on master and I'm running into the following error

==========
Error: couldn't find the executable "protoc" in your $PATH.
    Follow the installation instructions at https://google.github.io/proto-lens/installing-protoc.html .
==========
Missing executable "protoc"
CallStack (from HasCallStack):
  error, called at src/Data/ProtoLens/Setup.hs:416:13 in proto-lens-setup-0.4.0.2-Cbx7Qu7aR8y55lkeRKSlEN:Data.ProtoLens.Setup
builder for '/nix/store/l4mljbqzqv44wqy2hllnk8f8y3zsm2yy-three-layer-lib-three-layer-0.0.0.0.drv' failed with exit code 1
cannot build derivation '/nix/store/ly8rsadqyfavhmz8zq84nmw5hp31sral-three-layer-exe-three-layer-exe-0.0.0.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/ly8rsadqyfavhmz8zq84nmw5hp31sral-three-layer-exe-three-layer-exe-0.0.0.0.drv' failed

I'm not sure how to add this executable to my default.nix.

# default.nix
let
  # Read in the Niv sources
  sources = import ./nix/sources.nix {};
  # If ./nix/sources.nix file is not found run:
  #   niv init
  #   niv add input-output-hk/haskell.nix -n haskellNix

  # Fetch the haskell.nix commit we have pinned with Niv
  haskellNix = import sources.haskellNix {};
  # If haskellNix is not found run:
  #   niv add input-output-hk/haskell.nix -n haskellNix

  # Import nixpkgs and pass the haskell.nix provided nixpkgsArgs
  pkgs = import
    # haskell.nix provides access to the nixpkgs pins which are used by our CI,
    # hence you will be more likely to get cache hits when using these.
    # But you can also just use your own, e.g. '<nixpkgs>'.
    haskellNix.sources.nixpkgs-2009
    # These arguments passed to nixpkgs, include some patches and also
    # the haskell.nix functionality itself as an overlay.
    haskellNix.nixpkgsArgs;
in pkgs.haskell-nix.project {
  # 'cleanGit' cleans a source directory based on the files known by git
  src = pkgs.haskell-nix.haskellLib.cleanGit {
    name = "three-layer";
    src = ./.;
  };
  # Specify the GHC version to use.
  # compiler-nix-name = "ghc8102"; # Not required for `stack.yaml` based projects.
}
# stack.yml
resolver: lts-13.20

extra-deps:
  - ansi-terminal-0.9
  - co-log-0.3.0.0
  - co-log-core-0.2.0.0
  - chronos-1.0.5
  - torsor-0.1 # for chronos
  - elm-street-0.0.1
  - jwt-0.9.0
  - postgresql-simple-named-0.0.0.0
  - proto-lens-0.5.0.0
  - proto-lens-protoc-0.5.0.0
  - proto-lens-runtime-0.5.0.0
  - relude-0.5.0
  - servant-0.16.0.1
  - servant-server-0.16
  - servant-proto-lens-0.1.0.3
  - tomland-1.0.0
  - typerep-map-0.3.2
  - hsc2hs-0.68.4

# three-layer.cabal
cabal-version:       2.4
name:                three-layer
version:             0.0.0.0
synopsis:            Three layer cake Haskell implementation
description:         Please see the README on Github at <https://github.com/Holmusk/three-layer#readme>
homepage:            https://github.com/Holmusk/three-layer#readme
bug-reports:         https://github.com/Holmusk/three-layer/issues
author:              Holmusk
maintainer:          Holmusk <[email protected]>
copyright:           2018-2019 Holmusk
license:             BSD-3-Clause
license-file:        LICENSE
build-type:          Custom
extra-doc-files:     README.md
                     ChangeLog.md
extra-source-files:  proto/common.proto
                     proto/login.proto
tested-with:         GHC == 8.6.5

source-repository head
  type:                git
  location:            https://github.com/holmusk/three-layer.git

custom-setup
  setup-depends: Cabal
               , base
               , proto-lens-setup ^>= 0.4.0.2

common common-options
  build-depends:       base-noprelude ^>= 4.12.0.0
                     , relude ^>= 0.5.0

  ghc-options:         -Wall
                       -Wincomplete-uni-patterns
                       -Wincomplete-record-updates
                       -Wcompat
                       -Widentities
                       -Wredundant-constraints
                       -fhide-source-paths
                       -Wpartial-fields

  default-language:    Haskell2010
  default-extensions:  BangPatterns
                       ConstraintKinds
                       DataKinds
                       DeriveGeneric
                       DerivingStrategies
                       DerivingVia
                       FlexibleContexts
                       FlexibleInstances
                       GeneralizedNewtypeDeriving
                       InstanceSigs
                       KindSignatures
                       LambdaCase
                       MultiParamTypeClasses
                       OverloadedStrings
                       OverloadedLabels
                       RecordWildCards
                       ScopedTypeVariables
                       TypeApplications
                       TypeFamilies
                       TypeOperators

library
  import:              common-options
  hs-source-dirs:      src
  exposed-modules:     Prelude
                       Lib
                         -- application monad
                         Lib.App
                           Lib.App.Env
                           Lib.App.Error
                           Lib.App.Monad

                         Lib.Config

                         -- core modules
                         Lib.Core.Admin
                         Lib.Core.Email
                         Lib.Core.Id
                         Lib.Core.Jwt
                         Lib.Core.Password
                         Lib.Core.Session
                         Lib.Core.User

                         Lib.Db
                           Lib.Db.Functions
                           Lib.Db.Schema
                           Lib.Db.User

                         -- effects
                         Lib.Effects.Jwt
                         Lib.Effects.Log
                         Lib.Effects.Measure
                         Lib.Effects.Session

                         -- Server
                         Lib.Server
                           Lib.Server.Auth
                           Lib.Server.Types

                         Lib.Time
  other-modules:       Proto.Common
                       Proto.Common_Fields
                       Proto.Login
                       Proto.Login_Fields
  autogen-modules:     Proto.Common
                       Proto.Common_Fields
                       Proto.Login
                       Proto.Login_Fields

  build-tool-depends:  proto-lens-protoc:proto-lens-protoc
  build-depends:       aeson >= 1.4
                     , bcrypt ^>= 0.0.11
                     , bytestring ^>= 0.10
                     , case-insensitive ^>= 1.2
                     , co-log ^>= 0.3.0
                     , containers >= 0.6
                     , ekg ^>= 0.4.0.15
                     , ekg-core ^>= 0.1.1.6
                     , elm-street
                     , http-api-data ^>= 0.4
                     , http-types ^>= 0.12
                     , jwt ^>= 0.9.0
                     , lens ^>= 4.17
                     , mtl ^>= 2.2.2
                     , postgresql-simple ^>= 0.6.1
                     , postgresql-simple-named ^>= 0.0.0.0
                     , proto-lens ^>= 0.5.0.0
                     , proto-lens-protoc ^>= 0.5.0.0
                     , proto-lens-runtime ^>= 0.5.0.0
                     , random ^>= 1.1
                     , resource-pool
                     , servant ^>= 0.16
                     , servant-proto-lens ^>= 0.1.0.3
                     , servant-server ^>= 0.16
                     , text
                     , time >= 1.8 && < 1.10
                     , tomland ^>= 1.0.0
                     , unordered-containers
                     , warp ^>= 3.2

executable generate-elm
  import:              common-options
  hs-source-dirs:      generate-elm
  main-is:             Main.hs
  other-modules:       Paths_three_layer
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  build-depends:       three-layer
                     , elm-street

executable three-layer-exe
  import:              common-options
  hs-source-dirs:      app
  main-is:             Main.hs
  other-modules:       Paths_three_layer
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  build-depends:       three-layer

test-suite three-layer-test
  import:              common-options
  type:                exitcode-stdio-1.0
  hs-source-dirs:      test

  main-is:             Spec.hs
  other-modules:       Test.Auth
                       Test.Assert
                       Test.Common
                       Test.Core.Jwt
                       Test.Core.Password

  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  build-depends:       three-layer
                     , bcrypt
                     , hedgehog
                     , ekg-core
                     , hspec
                     , mtl
                     , hedgehog ^>= 0.6.1
                     , hspec
                     , hspec-core
                     , resource-pool
                     , unordered-containers

I think it would be cool to niv add it and import it somehow but it wasn't obvious for me. Any suggestions would be appreciated, thanks!

@michaelpj
Copy link
Collaborator

Dupe: #241

@trodrigu
Copy link
Author

Fixed after updating my default.nix to the following

let
  # Read in the Niv sources
  sources = import ./nix/sources.nix {};
  # If ./nix/sources.nix file is not found run:
  #   niv init
  #   niv add input-output-hk/haskell.nix -n haskellNix

  # Fetch the haskell.nix commit we have pinned with Niv
  haskellNix = import sources.haskellNix {};
  # If haskellNix is not found run:
  #   niv add input-output-hk/haskell.nix -n haskellNix

  # Import nixpkgs and pass the haskell.nix provided nixpkgsArgs
  pkgs = import
    # haskell.nix provides access to the nixpkgs pins which are used by our CI,
    # hence you will be more likely to get cache hits when using these.
    # But you can also just use your own, e.g. '<nixpkgs>'.
    haskellNix.sources.nixpkgs-2009
    # These arguments passed to nixpkgs, include some patches and also
    # the haskell.nix functionality itself as an overlay.
    haskellNix.nixpkgsArgs;
in
pkgs.haskell-nix.project {
  src = pkgs.haskell-nix.haskellLib.cleanGit {
    name = "three-layer";
    src = ./.;
  };
  # protobuf build tools are added here for the protoc executable
  modules = [
    {
      packages = {
        three-layer.components.library.build-tools = [ pkgs.protobuf ];
        three-layer.components.exes.three-layer-exe.build-tools = [ pkgs.protobuf ];
        three-layer.components.exes.three-layer-test.build-tools = [ pkgs.protobuf ];
      };
    }
  ];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants