Shop OBEX P1 Docs P2 Docs Learn Events
Testers Needed: Added support for AnyLinux™, SoonOSX™, and MaybeChromeOS™ for Parallax Tooling. — Parallax Forums

Testers Needed: Added support for AnyLinux™, SoonOSX™, and MaybeChromeOS™ for Parallax Tooling.

OH HAI! - tl;dr

Nix is a cross-platform package manager which works in much the same way as "brew" does for OSX (for those who are familiar)

I've been working on getting the parallax tooling into the official nix/nixos repos. Once it's in there officially there will be automatically built packages that will work on any Linux distribution, Mac OSX, and I believe also ChromeOS.

Nix deals with all dependencies OUTSIDE of the native OS which means that ChromeOS should come "for free"™ with no additional development.

Before I push the remaining packages to the official repos, I need some testing. Just because it compiles, doesn't mean I should ship it.


TODO
* Have people who have used the tooling test its functionality.
* Identify which version / tag I should be packaging (I'm currently master on almost everything).
* Complete the port to Mac OSX (currently only openspin is ported to OSX).
* Testing for ChromeOS.
* Push to the Official Distribution.
* What packages (if any) am I missing? Requests?


How can I help?
If you are running on *ANY* Linux, you can help. Really - any. It should work on anything that has a shell, curl... even ridiculously cut-down distributions.


So how does this work?
You install the package manager from an unprivileged user. The only places it writes will be in your user profile and a new directory called /nix where it stores the packages (it does this so if you have multiple users on a system you only have one copy).

To uninstall it, you just remove those. Unlike brew, it doesn't hose your base OS by writing in global locations like /usr/local


The first package (openspin) was accepted upstream which means that THAT package is already compiled and available as a binary package for both Linux and OSX.

Here's the page for the Linux build in Nix infrastructure:https://hydra.nixos.org/job/nixpkgs/trunk/openspin.x86_64-linux#tabs-status


So, just the Package Manager, right?
When everything is accepted upstream, installation will be two commands for end-users. One to install the package manager, one to install whatever tooling you want.

However, since I'm in development you'll need to install the package manager, and the build instructions for the propeller tooling (which is what I'm writing).


Show me!

Okay, this is a fresh minimal ubuntu build. This is how we install the package manager:
red@ubuntut0:~$ sudo apt install curl # because ubuntu doesn't have curl/git by default.
⋮
Setting up curl (7.58.0-2ubuntu3.5) ...
red@ubuntut0:~$ curl https://nixos.org/nix/install | sh
⋮
Installation finished!  To ensure that the necessary environment
variables are set, either log in again, or type

  . /home/red/.nix-profile/etc/profile.d/nix.sh

in your shell.
red@ubuntut0:~$ . /home/red/.nix-profile/etc/profile.d/nix.sh

Next up, installing the data needed to build the packages:
red@ubuntut0:~$ cd ~/.config
red@ubuntut0:~/.config$ mkdir -p nixpkgs/overlays
red@ubuntut0:~/.config$ cd nixpkgs/overlays
red@ubuntut0:~/.config/nixpkgs/overlays$
red@ubuntut0:~/.config/nixpkgs/overlays$ git clone https://github.com/redvers/parallax-tooling
Cloning into 'parallax-tooling'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 17 (delta 0), reused 14 (delta 0), pack-reused 0
Unpacking objects: 100% (17/17), done.

To install openspin (this is now an official package):
red@ubuntut0:~/.config/nixpkgs/overlays$ nix-env -iA nixpkgs.openspin
installing 'openspin-unstable-2018-10-02'
building '/nix/store/1dfgz7m7qfsarkvwq8z3cpg035nk4n88-user-environment.drv'...
created 19 symlinks in user environment
red@ubuntut0:~/.config/nixpkgs/overlays$ openspin
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2018 Parallax Inc. DBA Parallax Semiconductor.
Version 1.00.81 Compiled on Jan  1 1970 00:00:01
usage: openspin
         [ -h ]                 display this help
         [ -L or -I <path> ]    add a directory to the include path
         [ -o <path> ]          output filename
         [ -b ]                 output binary file format
         [ -e ]                 output eeprom file format
         [ -c ]                 output only DAT sections
         [ -d ]                 dump out doc mode
         [ -t ]                 output just the object file tree
         [ -f ]                 output a list of filenames for use in archiving
         [ -q ]                 quiet mode (suppress banner and non-error text)
         [ -v ]                 verbose output
         [ -p ]                 disable the preprocessor
         [ -a ]                 use alternative preprocessor rules
         [ -D <define> ]        add a define
         [ -M <size> ]          size of eeprom (up to 16777216 bytes)
         [ -s ]                 dump PUB & CON symbol information for top object
         [ -u ]                 enable unused method elimination
         <name.spin>            spin file to compile

To install spinsim (this hasn't been accepted upstream so will be compiled locally):
red@ubuntut0:~$ nix-env -iA nixpkgs.spinsim
installing 'spinsim-2018-06-19'
these derivations will be built:
  /nix/store/zmnm9fj8vpn451fxp352fyxrkg5b6ij7-source.drv
  /nix/store/4lajikrdwxz4h731gjyvfjy8a1x2f7a4-spinsim-2018-06-19.drv
these paths will be fetched (0.12 MiB download, 0.47 MiB unpacked):
  /nix/store/2y2xzxbxsj1mbn77zyjwra3c0mgkr007-unzip-6.0
copying path '/nix/store/2y2xzxbxsj1mbn77zyjwra3c0mgkr007-unzip-6.0' from 'https://cache.nixos.org'...
building '/nix/store/zmnm9fj8vpn451fxp352fyxrkg5b6ij7-source.drv'...
⋮
[code]
checking for references to /tmp/nix-build-spinsim-2018-06-19.drv-0 in /nix/store/30x5cgip7wncz35md4bw10nhpljdna4x-spinsim-2018-06-19...
building '/nix/store/7pb41a1p22hs0wd0gkgrbfvfhwyr7jw0-user-environment.drv'...
created 19 symlinks in user environment
red@ubuntut0:~$ spinsim
Spinsim Version 0.99
usage: spinsim [options] file
The options are as follows:
     -v# Set verbosity level
     -l <filename>  List executed instructions to <filename>
     -p  Use PASM Spin interpreter
     -#  Execute # instructions
     -P  Profile Spin opcode usage
     -m# Set the hub memory size to # K-bytes
     -t# Enable the Prop 2 mode.  # specifies options
     -b# Enable the serial port and set the baudrate to # (default 115200)
     -gdb Operate as a GDB target over stdin/stdout
     -L <filename> Log GDB remote comm to <filename>
     -r <filename> Replay GDB session from <filename>
     -e Use eeprom.dat
     -d Use debugger
     -pst Use PST mode

Installing spin2cpp (which includes fastspin):
red@ubuntut0:~$ nix-env -iA nixpkgs.spin2cpp
installing 'spin2cpp-2018-11-03'
these derivations will be built:
  /nix/store/83hqyzcs06iap5r6rapyr24kfzl2fgrf-source.drv
  /nix/store/ra9sb1hhhcmsq6dzpskkvclxhd2pz1yb-spin2cpp-2018-11-03.drv
building '/nix/store/83hqyzcs06iap5r6rapyr24kfzl2fgrf-source.drv'...
⋮
patching script interpreter paths in /nix/store/k8dj1n54jmb084m3gpap2yyy64hrn8d3-spin2cpp-2018-11-03
checking for references to /tmp/nix-build-spin2cpp-2018-11-03.drv-0 in /nix/store/k8dj1n54jmb084m3gpap2yyy64hrn8d3-spin2cpp-2018-11-03...
building '/nix/store/6mlrayd0xvmyapq5v5nyzk5psjczcibf-user-environment.drv'...
created 22 symlinks in user environment
red@ubuntut0:~$ fastspin
Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2018 Total Spectrum Software Inc.
Version 3.9.9-beta- Compiled on: Jan  1 1970
usage: fastspin [options] filename.spin | filename.bas
  [ -h ]              display this help
  [ -L or -I <path> ] add a directory to the include path
  [ -o <name> ]      set output filename to <name>
  [ -b ]             output binary file format
  [ -e ]             output eeprom file format
  [ -c ]             output only DAT sections
  [ -l ]             output DAT as a listing file
  [ -f ]             output list of file names
  [ -q ]             quiet mode (suppress banner and non-error text)
  [ -p ]             disable the preprocessor
  [ -D <define> ]    add a define
  [ -u ]             ignore for openspin compatibility (unused method elimination always enabled)
  [ -2 ]             compile for Prop2
  [ -O# ]            set optimization level:
          -O0 = no optimization
          -O1 = basic optimization
          -O2 = all optimization
  [ -w ]             compile for COG with Spin wrappers
  [ --code=cog ]     compile for COG mode instead of LMM
  [ --fcache=N ]     set FCACHE size to N (0 to disable)
  [ --fixedreal ]    use 16.16 fixed point in place of floats
red@ubuntut0:~$ spin2cpp
Spin to C++ converter version 3.9.9-beta-
Usage: spin2cpp [options] file.spin
Options:
  --asm:     output (user readable) PASM code
  --binary:  create binary file for download
  --cogspin: create PASM based Spin object (translate Spin to PASM)
  --ccode:   output C code instead of C++
  --cse:     perform common subexpression optimizations on C code
  --cc=CC:   use CC as the C++ compiler instead of PropGCC
  --code=x : PASM output only: control placement of code
             x can be cog (default) or hub (for LMM)
  --ctypes : use inferred pointer (and other) types in generated C/C++ code
  --data=x : PASM output only: control placement of data
             x can be cog or hub (default is hub)
  --dat:     output binary blob of DAT section only
  --eeprom:  create EEPROM binary file for download
  --elf:     create executable ELF file with propgcc
  --files:   print list of .cpp files to stdout
  --fixed:   use 16.16 fixed point in place of float
  --fcache=N: set size of FCACHE area
  --gas:     create inline assembly out of DAT area;
             with --dat, create gas .S file from DAT area
  --list:    produce a listing file
  --main:    include C++ main() function
  --noheader: skip the normal comment about spin2cpp version
  --nocse:   disable common subexpression optimizations on PASM code
  --noopt:   turn off all optimization in PASM output
  --nopre:   do not run preprocessor on the .spin file
  --nofcache: disable FCACHE (same as --fcache=0)
  --normalize: normalize case of all identifiers
  --p2:       use Propeller 2 instructions (experimental)
  --require:  require a specific version (or later) of spin2cpp
  --side:     create a SimpleIDE file for the C/C++ outputs
  -Dname=val: define a preprocessor symbol
  -g:         add debug info to output (original source for PASM output)
  -I dir:     add dir to the object search path
  -L dir:     same as -I
  -o file:    place final output in file
  -y:         debug parser
  --version:  print version and exit

... and really, the mother-lode:
red@ubuntut0:~$ nix-env -iA nixpkgs.propeller-gcc
⋮

Get a coffee for this one, it takes a while ;-)

Thanks,



Red

Comments

  • Is it expected that, to use Nix full-time, you would source /home/red/.nix-profile/etc/profile.d/nix.sh as part of your .bashrc file?
  • __red____red__ Posts: 470
    edited 2018-11-04 15:27
    Yes.

    The install will drop it in profile.d for those distributions that support that (hence the "To ensure that the necessary environment variables are set, either log in again, or type")

    What I love and adore about it is that even though the compile needs gcc, make, yacc, bison, texinfo... and all these other things... at the end of the compile, NONE of them persist so there's no danger of polluting your existing OS.

    The applications your add end up as symlinks in: ~/.nix-profile/bin/

    So, in my current example:
    red@ubuntut0:~/.nix-profile/bin$ ls
    dir-created          nix-instantiate          propeller-elf-g++         propeller-elf-objdump
    fastspin             nix-prefetch-url         propeller-elf-gcc         propeller-elf-ranlib
    gdbstub              nix-shell                propeller-elf-gcc-4.6.1   propeller-elf-readelf
    nix                  nix-store                propeller-elf-gcov        propeller-elf-size
    nix-build            propeller-elf-addr2line  propeller-elf-gdb         propeller-elf-strings
    nix-channel          propeller-elf-ar         propeller-elf-gprof       propeller-elf-strip
    nix-collect-garbage  propeller-elf-as         propeller-elf-image-size  propeller-load
    nix-copy-closure     propeller-elf-c++        propeller-elf-ld          spin2cpp
    nix-daemon           propeller-elf-c++filt    propeller-elf-ld.bfd      spinsim
    nix-env              propeller-elf-cpp        propeller-elf-nm          testlex
    nix-hash             propeller-elf-elfedit    propeller-elf-objcopy
    
  • I have a Mac laptop that I also use with Parallels Desktop for occasional Windows use. I could also install Ubuntu and add Nix as you've shown in this thread. I'm mostly interested in the MacOS versions. Would that be helpful?
  • Testing the Mac OSX would be invaluable. I'm pretty sure that only openspin will work though currently.

    I don't actually have a Mac so for developing it I had been reliant on uploading code and letting Nix's CI infrastructure build it for me. Confirmation that it works on a Mac would would be awesome!

    To test that you only need to:
    curl https://nixos.org/nix/install | sh
    

    Do whatever ". /home/red/.nix-profile/etc/profile.d/nix.sh" equivalent it asks you to do.
    nix-env -iA nixpkgs.openspin
    

  • __red__ wrote: »
    I don't actually have a Mac so for developing it

    For the record, this just changed. I just acquired a mac.
  • __red__ wrote: »
    Testing the Mac OSX would be invaluable. I'm pretty sure that only openspin will work though currently.

    I don't actually have a Mac so for developing it I had been reliant on uploading code and letting Nix's CI infrastructure build it for me. Confirmation that it works on a Mac would would be awesome!

    I ran the commands to configure nix and installed openspin on a macOS Mojave (10.14.1) system and it appears to work as you expected!
    [myMacUser@MacBook-Pro-2 ~/.nix-profile/bin]$ which openspin
    /Users/myMacUser/.nix-profile/bin/openspin   <== NEW openspin HAS BEEN INSTALLED HERE!!
    [myMacUser@MacBook-Pro-2 ~/.nix-profile/bin]$ openspin
    Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2018 Parallax Inc. DBA Parallax Semiconductor.
    Version 1.00.81 Compiled on Oct 25 2018 00:21:41
    usage: openspin
             [ -h ]                 display this help
             [ -L or -I <path> ]    add a directory to the include path
             [ -o <path> ]          output filename
             [ -b ]                 output binary file format
             [ -e ]                 output eeprom file format
             [ -c ]                 output only DAT sections
             [ -d ]                 dump out doc mode
             [ -t ]                 output just the object file tree
             [ -f ]                 output a list of filenames for use in archiving
             [ -q ]                 quiet mode (suppress banner and non-error text)
             [ -v ]                 verbose output
             [ -p ]                 disable the preprocessor
             [ -a ]                 use alternative preprocessor rules
             [ -D <define> ]        add a define
             [ -M <size> ]          size of eeprom (up to 16777216 bytes)
             [ -s ]                 dump PUB & CON symbol information for top object
             [ -u ]                 enable unused method elimination
             <name.spin>            spin file to compile
    
    [myMacUser@MacBook-Pro-2 ~/Documents/PropSpinCode/FindFreq]$ openspin -L /Users/myMacUser/Documets/PropSpinCode/SpinObjects FindFreq.spin
    Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2018 Parallax Inc. DBA Parallax Semiconductor.
    Version 1.00.81 Compiled on Oct 25 2018 00:21:41
    Compiling...
    FindFreq.spin
    |-FullDuplexSerial.spin
    Done.
    Program size is 1540 bytes
    

    dgately
  • dgately wrote: »
    I ran the commands to configure nix and installed openspin on a macOS Mojave (10.14.1) system and it appears to work as you expected!
    [myMacUser@MacBook-Pro-2 ~/Documents/PropSpinCode/FindFreq]$ openspin -L /Users/myMacUser/Documets/PropSpinCode/SpinObjects FindFreq.spin
    Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2018 Parallax Inc. DBA Parallax Semiconductor.
    Version 1.00.81 Compiled on Oct 25 2018 00:21:41
    Compiling...
    FindFreq.spin
    |-FullDuplexSerial.spin
    Done.
    Program size is 1540 bytes
    

    Oh, this is just GLORIOUS! Thank you!
  • Well, I’ve got the current Ubuntu LTS version installed in a virtual PC on my Mac. I’ve followed your instructions for installing the Nix stuff and I’ve installed openspin, spinsim, spin2cpp, fastspin, and propeller-bcc and they all seem to run. Now what?
  • Mike Green wrote: »
    Now what?

    Making sure it's actually functional is the big deal. I could only compile it, without the other platforms I couldn't actually test that it didn't core-dump / crash when running.

    Thanks for testing it - I'm going to commit to keeping it current AND...

    I've been digging into the chromebook porting aspect. It seems that the chromebooks are slowly getting project crostini rolled out which will allow this to run in chromebooks that have NOT been put into developer mode.

    Unfortunately, the chromebook I own is one that will never get that update so I can't test it against the "production" chromebooks, just the developer-mode ones.

    The chromebook stuff may fall back a little, but there is light on the horizon.
Sign In or Register to comment.