shajra / nix-example Goto Github PK
View Code? Open in Web Editor NEWa way to develop software with Nix
a way to develop software with Nix
This is an awesome guide. Nix is always in need of some extra documentation :)
Feedback:
For nix-shell you could have alternatively used "nix-shell -p hello" which is just a little less boiler-plate than doing an import expression on nixpkgs.
This is a little shell.nix that I use as a template for most projects. It's a little nicer than creating an overlay over all of nixpkgs, and should evaluate much faster. 'ghcWithPackages' also plays nicely with hoogle and similar tools.
https://pastebin.com/JPqQuLRr
You may be interested in this tool I've made: https://github.com/jyp/styx
If you have feedback on it I'd love to hear it!
Might be nice to first check for direnv.nix, and if it exists just do a normal instantiate + realize (i.e. no IN_NIX_SHELL or anything) and take its $out
as an envrc file directly.
On Ubuntu 16.04.2 amd64
I can do build successfully with nix-build
but nix-shell
throws this error:
$ nix-shell --show-trace
error: while evaluating the attribute ‘env.haskell’ at /home/.../example-nix/modules/pkgs-make/default.nix:54:25:
while evaluating the attribute ‘env’ at /home/.../example-nix/modules/pkgs-make/haskell.nix:133:12:
while evaluating ‘makeOverridable’ at /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/lib/customisation.nix:54:24, called from /home/.../example-nix/modules/pkgs-make/haskell.nix:112:10:
while evaluating anonymous function at /home/.../example-nix/modules/pkgs-make/haskell.nix:39:14, called from /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/lib/customisation.nix:56:12:
while evaluating ‘makeOverridable’ at /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/lib/customisation.nix:54:24, called from /home/.../example-nix/modules/pkgs-make/haskell.nix:39:20:
while evaluating anonymous function at /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/development/haskell-modules/generic-builder.nix:5:1, called from /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/lib/customisation.nix:56:12:
while evaluating ‘mkDerivation’ at /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/stdenv/generic/default.nix:111:5, called from /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/development/haskell-modules/generic-builder.nix:170:1:
while evaluating ‘checkValidity’ at /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/stdenv/generic/default.nix:211:23, called from /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/stdenv/generic/default.nix:238:22:
while evaluating ‘hasDeniedUnfreeLicense’ at /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/stdenv/generic/default.nix:72:28, called from /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/stdenv/generic/default.nix:212:12:
while evaluating ‘isUnfree’ at /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/stdenv/generic/default.nix:57:14, called from /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/stdenv/generic/default.nix:75:5:
while evaluating ‘toList’ at /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/lib/lists.nix:198:12, called from /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/stdenv/generic/default.nix:75:15:
while evaluating the attribute ‘meta.license’ at /nix/store/977dc6s2lxnysa3gbvnjm1s4sk7i5gah-nixpkgs-fa03b8279fa9b544c29c97eaa5263163b6716046-src/pkgs/development/haskell-modules/generic-builder.nix:327:19:
while evaluating the attribute ‘nix.licenses.bsd3’ at /home/.../example-nix/modules/pkgs-make/lib/default.nix:10:9:
attribute ‘bsd3’ missing, at /home/.../example-nix/modules/pkgs-make/haskell.nix:116:23
building path(s) ‘/nix/store/3gi65cgl8bi20i563ki6a4b0ifai7x2w-example-app-cabal2nix’
dyld: Library not loaded: /usr/lib/system/libsystem_coretls.dylib
Referenced from: /nix/store/n9lvzry997gqab2lqlqzvzjfi1k4icj1-Libsystem-osx-10.11.6/lib/libSystem.B.dylib
Reason: image not found
builder for ‘/nix/store/c0zrp51bh777asgnx4wh68blvsgb1p4g-example-app-cabal2nix.drv’ failed due to signal 6 (Abort trap: 6)
error: build of ‘/nix/store/c0zrp51bh777asgnx4wh68blvsgb1p4g-example-app-cabal2nix.drv’ failed
(use ‘--show-trace’ to show detailed location information)
I thought the "--color-output" of jq looked nice. I could remove it. But I guess it feels like a silly challenge to learn more how colorizing works.
I may just break down and remove "--colorize-output" switch.
This was originally brought up in #4, so there's some comments there.
might mention nixops, and perhaps explicitly call out the nix ecosystem in passing here: https://github.com/shajra/example-nix/tree/master/tutorials/0-nix-intro
in general I really liked this section, though another thing could add is some gotchas with paths (./ -> ./. to get current directory)
https://youtu.be/dlRuMdm6pRU?t=365 this talk is also sort of a nice low level complement to gabriel gonzalez more high level overview of nix tradeoffs
I also use spacemacs with direnv, this might be too tangential to put in the repo, but I've found spacemacs dev cycle has slowed a bit and the "develop/master branch" is actually more stable than the stable branch (e.g. treemacs is like neotree but doesnt go haywire when using spacemacs layout system, js layer is more up to date, etc.).
"by default built from of NIX_PATH" in the "Calling nix" section.
Very nice resource. Keep up the good work! 🙂
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.