Coder Social home page Coder Social logo

justinwoo / nix-shorts Goto Github PK

View Code? Open in Web Editor NEW
418.0 16.0 20.0 64 KB

A collection of short notes about Nix, down to what is immediately needed for users.

License: Creative Commons Attribution Share Alike 4.0 International

Nix 100.00%
nix

nix-shorts's Introduction

nix-shorts

A collection of short notes about Nix, down to what is immediately needed for users.

The aim of this collection is to provide some instantly usable information with clear code demonstrations.

While you can read the posts in this repo in any order, you might start from how to build your first derivation, to understand how Nix derivations work: https://github.com/justinwoo/nix-shorts/blob/master/posts/your-first-derivation.md

How to read articles in this repo

All articles are meant to be easy enough to approach with clear examples of terminal commands, code, or file setups. When project setups are needed, appropriate directories will be in this repo and referenced.

When applicable, usernames are replaced with your-user and hashes replaced with some-hash. E.g.

$ readlink ~/.nix-profile
/nix/var/nix/profiles/per-user/justin/profile
$ readlink -f ~/.nix-profile
/nix/store/mwgv8fzlr6n9kkb5nyz27fv1l66jc7nf-user-environment

...will be shown as

$ readlink ~/.nix-profile
/nix/var/nix/profiles/per-user/your-user/profile
$ readlink -f ~/.nix-profile
/nix/store/some-hash-user-environment

Contributing

Small fixes and elaborations can be contributed via PR. Content suggestions can be done via issues. However, many topics that are not critically important to a new user will not be written about here.

Installation of Nix

From nixos.org https://nixos.org/nixos/nix-pills/install-on-your-running-system.html#idm140737316665792:

To install Nix, run curl https://nixos.org/nix/install | sh as a non-root user
and follow the instructions. Alternatively, you may prefer to download the
installation script and verify its integrity using GPG signatures. Instructions
for doing so can be found here: https://nixos.org/nix/download.html.

For more esoteric information, readers should try looking through the Nix Pills.

FAQ

Why not Nix Pills?

Readers of Nix Pills should well know that the purpose of the Nix Pills are clearly stated multiple times in its contents:

These articles are not a tutorial on using Nix. Instead, we're going to walk through the Nix system to understand the fundamentals.

nix-shorts's People

Contributors

damiencassou avatar fruitiex avatar ghuntley avatar justinwoo avatar waxlamp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nix-shorts's Issues

permission error while creating the first derivation

I am getting this error while following https://github.com/justinwoo/nix-shorts/blob/master/posts/your-first-derivation.md, let me know if this is just a problem I'm having or if the documentation is outdated or incorrect.

Steps to reproduce

  • cat src/hi.txt
hello
  • cat default.nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv.mkDerivation {
  name = "basic-derivation";
  src = ./src;
  installPhase = ''
    ln -s $src $out
  '';
}
  • nix-build
this derivation will be built:
  /nix/store/20ld3w1q53cj4c2jaf66x58d3kpvrgbg-basic-derivation.drv
building '/nix/store/20ld3w1q53cj4c2jaf66x58d3kpvrgbg-basic-derivation.drv'...
unpacking sources
unpacking source archive /nix/store/54992nknd3av7j4p7fmsh96ja5hp1vli-src
source root is src
patching sources
configuring
no configure script, doing nothing
building
no Makefile, doing nothing
installing
post-installation fixup
chmod: changing permissions of '/nix/store/21wjryn7nbhxv6mv5179ry8rp366gdhk-basic-derivation': Operation not permitted
chmod: changing permissions of '/nix/store/21wjryn7nbhxv6mv5179ry8rp366gdhk-basic-derivation/hi.txt': Operation not permitted
error: --- Error ------------------------------------------------------------------------------------------------------------------------ nix-build
builder for '/nix/store/20ld3w1q53cj4c2jaf66x58d3kpvrgbg-basic-derivation.drv' failed with exit code 1; last 10 log lines:
  source root is src
  patching sources
  configuring
  no configure script, doing nothing
  building
  no Makefile, doing nothing
  installing
  post-installation fixup
  chmod: changing permissions of '/nix/store/21wjryn7nbhxv6mv5179ry8rp366gdhk-basic-derivation': Operation not permitted
  chmod: changing permissions of '/nix/store/21wjryn7nbhxv6mv5179ry8rp366gdhk-basic-derivation/hi.txt': Operation not permitted

Working with Nix Shell: clarification regarding easy-purescript-nix example

Hi,

thanks for this guide. As someone who is totally new to the "nixverse" I was a bit puzzled by the following very simple example, under https://github.com/justinwoo/nix-shorts/blob/master/posts/working-with-nix-shells.md#expressions-as-arguments:

But instead of only top level attributes, you can also put entire expressions in the -p argument. For example, with the easy-purescript-nix project:

$ nix-shell \
    -p 'let ep = import ./default.nix {}; in [ ep.purs ep.spago ]' \
   --run 'which purs; which spago; purs --version; spago version'
/nix/store/some-hash-purescript/bin/purs
/nix/store/some-hash-spago/bin/spago
0.13.3
0.9.0.0

So, if I understood correctly the command has to be run under a clone of the easy-purescript-nix repository. Perhaps adding the necessary git clone ... && cd ... instruction would be helpful.

I can make a small pull request for this if it makes sense.

Thanks!

nix-shorts on gemini

@justinwoo What do you think of making nix-shorts available on the gemini protocol?

some links

gemini://gemini.circumlunar.space/
gemini://gemini.circumlunar.space/docs/cheatsheet.gmi/
https://crates.io/crates/md2gemtext
gemini://idiomdrottning.org/gemini-pandoc

Sourcehut pages offers free gemini hosting.

I recommend lagrange, castor, or amfora gemini clients. They're all packaged in nixpkgs.

Explain the relation between nix-shell and shell.nix

In https://github.com/justinwoo/nix-shorts/blob/f75bc4108288f2bd63e7343d25a998f804b1b1e1/posts/working-with-nix-shells.md shell.nix is used in a nix-shell example. It would be good to explain what the shell.nix file as the file evaluated by default when nix-shell is executed in a directory. This is hinted at but could be more explicit.

It may also be worth explaining the behavior that default.nix is used as shell.nix if there is a default.nix but no shell.nix.

Explain that installing a set and a list have the same effect

In https://github.com/justinwoo/nix-shorts/blob/0517634d5c8482a9f0c5628f8be8521203966001/posts/install-packages-from-files.md#from-a-list-of-derivations it is explained in the subheading above that you can install a set of packages from a derivation using nix-env and then an example is shown with a list. It would be good to explain that nix-env will treat both code examples in the same way explicitly when installing packages to the user environment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.