dream2nix
                                
                                
                                
                                    dream2nix copied to clipboard
                            
                            
                            
                        Racket: programs installed into /bin don't work
nix shell github:winny-/ssh-hack/runAsLibrary- Try to run 
ssh-hack - Notice 
racket -l ssh-hackworks (the library has a main entrypoint) 
winston@stargate ~ $ nix shell github:winny-/ssh-hack/runAsLibrary
winston@stargate ~ $ ssh-hack
standard-module-name-resolver: collection not found
  for module path: (lib "ssh-hack/main.rkt")
  collection: "ssh-hack"
  in collection directories:
   /home/winston/.local/share/racket/8.6/collects
   /nix/store/bk1xqmzk9aq23zqq2yw0xazvjjk84jyg-racket-8.6/share/racket/collects/
   ... [165 additional linked and package directories]
1 winston@stargate ~ $ which ssh-hack
/nix/store/bdn3cjqs7a2sy0ffx3b4ygn2cf94x20x-racket-with-ssh-hack-env/etc/8.6/bin/ssh-hack
winston@stargate ~ $
                                    
                                    
                                    
                                
I can reproduce this bug starting with https://github.com/nix-community/dream2nix/commit/427258be by @zainab-ali.
On https://github.com/nix-community/dream2nix/commit/850d8b1c and before, everything works fine.
@zainab-ali do you have an idea of how to fix this? From looking through an strace of the failing case, standard-module-name-resolver is presently looking through some of the paths in Racket's config.rktd while neglecting some of the added paths in the PLTCONFIGDIR's config.rktd.
Sorry for the delay! I think I have a solution in https://github.com/zainab-ali/dream2nix/commit/a9e9d1ebe82af2b1733383632d46445eb6569eaf. @winny- , let me know if it works for you and I'll PR the fix.
Problem
The ssh-hack binary isn't present on the PATH.  @winny- , do you know how ssh-hack is added to yours?
Here's what I get when I enter the shell:
λ> pwd
/home/zainab/racket/ssh-hack
λ> nix shell github:winny-/ssh-hack/runAsLibrary
λ> which ssh-hack
which: no ssh-hack in (/nix/store/bdn3cjqs7a2sy0ffx3b4ygn2cf94x20x-racket-with-ssh-hack-env/bin:/nix/store/bdn3cjqs7a2sy0ffx3b4ygn2cf94x20x-racket-with-ssh-hack-env/bin:/run/wrappers/bin:/home/zainab/.nix-profile/bin:/etc/profiles/per-user/zainab/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:~/.local/bin)
It isn't present in the bin directory:
λ> tree /nix/store/bdn3cjqs7a2sy0ffx3b4ygn2cf94x20x-racket-with-ssh-hack-env/bin/
/nix/store/bdn3cjqs7a2sy0ffx3b4ygn2cf94x20x-racket-with-ssh-hack-env/bin/
├── drracket
├── gracket
├── gracket-text
├── mred
├── mred-text
├── mzc
├── mzpp
├── mzscheme
├── mztext
├── pdf-slatex
├── plt-games
├── plt-help
├── plt-r5rs
├── plt-r6rs
├── plt-web-server
├── racket
├── raco
├── scribble
├── setup-plt
├── slatex
├── slideshow
└── swindle
0 directories, 22 files
However, it is present in etc/8.6/bin:
λ> tree /nix/store/bdn3cjqs7a2sy0ffx3b4ygn2cf94x20x-racket-with-ssh-hack-env/etc/8.6/bin/
/nix/store/bdn3cjqs7a2sy0ffx3b4ygn2cf94x20x-racket-with-ssh-hack-env/etc/8.6/bin/
└── ssh-hack
0 directories, 1 file
Cause
This change changes the location of generated binaries to a versioned bin directory etc/8.6/bin. However, we only copy over the unversioned etc/bin .
Solution
https://github.com/zainab-ali/dream2nix/commit/a9e9d1ebe82af2b1733383632d46445eb6569eaf modifies the builder to copy over the versioned bin directory too.
I now get:
λ> nix shell  --override-input dream2nix github:zainab-ali/dream2nix/a9e9d1ebe82af2b1733383632d46445eb6569eaf --show-trace
warning: not writing modified lock file of flake 'git+file:///home/zainab/racket/ssh-hack':
• Updated input 'dream2nix':
    'github:nix-community/dream2nix/0c064fa9dd025069cc215b0a8b4eb5ea734aceb0' (2023-06-06)
  → 'github:zainab-ali/dream2nix/a9e9d1ebe82af2b1733383632d46445eb6569eaf' (2023-07-16)
• Updated input 'dream2nix/nixpkgsV1':
    'github:NixOS/nixpkgs/5eb98948b66de29f899c7fe27ae112a47964baf8' (2023-03-11)
  → 'github:NixOS/nixpkgs/dfdbcc428f365071f0ca3888f6ec8c25c3792885' (2023-07-14)
λ> which ssh-hack
/nix/store/pb6nyh9iggw8jz10fjfll7349f005xwf-racket-with-ssh-hack-env/bin/ssh-hack
λ> ssh-hack
ssh-hack: expects 1 <alias> on the command line, given 0 arguments
λ> ssh-hack --help
usage: ssh-hack [ <option> ... ] <alias>
<option> is one of
  -l, --list
     List possible services
  -c <alternate-config-path>, --config <alternate-config-path>
     Specify alternate config path
  -d, --dimensions
     Print out the dimensions of the terminal.
  --help, -h
     Show this help
  --
     Do not treat any remaining argument as a switch (at this level)
 Multiple single-letter switches can be combined after
 one `-`. For example, `-h-` is the same as `-h --`.
λ> ssh-hack -c example-ssh-hack.rktd -l
USERNAME at [email protected] [nao,alt]
squarerobin at [email protected] [squarerobin]
USERNAME at [email protected] [ascension,run]
USERNAME at [email protected] [hardfought-au,hf-au]
USERNAME at [email protected] [sm]
USERNAME at [email protected] [hardfought-eu,hf-eu]
USERNAME at [email protected] [hardfought,hf,hardfought-us,hf-us]
                                    
                                    
                                    
                                
Sorry for the delay! I think I have a solution in zainab-ali@a9e9d1e. @winny- , let me know if it works for you and I'll PR the fix.
Hey there!  Just tested and verified your branch fixes ssh-hack invocation on my machine as well.  Thanks for looking into this.  If there is any additional testing or teamwork needed, please feel free to @ me in the PR.
I think this can be closed now.
Oh... not sure what legacy branch is. I'll leave this open because I do not believe that's the default branch.