niv icon indicating copy to clipboard operation
niv copied to clipboard

how to add a local source

Open symphorien opened this issue 5 years ago • 4 comments

I'm trying to find out how to add a local source:

$  niv add other -T local -t /home/symphorien/src/a
Adding package other
  FATAL: Could not read the output of 'nix-prefetch-url'. This is a bug. Please create a
  ticket:
  
    https://github.com/nmattia/niv/issues/new
  
  Thanks! I'll buy you a beer.
  command: 
  nix-prefetch-url/home/symphorien/src/a --name a
  stdout: 
  
  stderr: 
  error: unable to download '/home/symphorien/src/a': URL using bad/illegal format or missing URL (3)
  
  FATAL: One or more packages failed to update:
  other: ExitFailure 1
ERROR: ExitFailure 1
                                                                                                                                                                                                     
$  niv add other -T local /home/symphorien/src/a 
Invalid argument `/home/symphorien/src/a'

Usage: niv [-s|--sources-file FILE] COMMAND
                                                                                                                                                                                                     
$  niv add other /home/symphorien/src/a 
Invalid argument `/home/symphorien/src/a'

Usage: niv [-s|--sources-file FILE] COMMAND
                                                                                                                                                                                                     
$  niv add other -T local -s path=/home/symphorien/src/a
Adding package other
  FATAL: One or more packages failed to update:
  other: Update failed: Key could not be found: url_template
  CallStack (from HasCallStack):
    error, called at src/Niv/Update.hs:80:25 in niv-0.2.14-1IB6KFr90FY2Kts68ArwbO:Niv.Update
ERROR: ExitFailure 1

symphorien avatar Jul 25 '20 08:07 symphorien

Thanks for the report. I merged that in a bit of a rush, I'll try to sort this out ASAP!

nmattia avatar Jul 27 '20 08:07 nmattia

any update?

symphorien avatar Oct 08 '20 15:10 symphorien

@symphorien here's what I found that works

niv add local -n poetry2nix_local --path ~/src/poetry2nix
Adding package poetry2nix_local
  Writing new sources file
Done: Adding package poetry2nix_local

If we look at niv add --help, under experimental commands at the bottom, it lists:

Experimental commands:
  git                      Add a git dependency. Experimental.
  github                   Add a GitHub dependency
  local                    Add a local dependency. Experimental.

And from --help on local:

niv add local -h
Examples:

  niv add local ./foo/bar

Usage: niv add local [PACKAGE] [-n|--name NAME] [--path PATH]
  Add a local dependency. Experimental.

Available options:
  -n,--name NAME           Set the package name to <NAME>
  -h,--help                Show this help text

evanjs avatar Oct 17 '20 19:10 evanjs

Thanks it works great ! Is there a better way to convert a git source to a local source and vice versa than drop and then add ?

symphorien avatar Oct 19 '20 08:10 symphorien