GithubHelp home page GithubHelp logo

nixos-tutorial's Introduction

check out the cheat sheet

outline

  • setup (5m)
  • nix-env package management (10m)
  • nix-shell isolated environments (10m)
  • NixOS declarative operating system configuration
    • introduction (5m)
    • service (5m)
    • network (5m)
    • user (5m)
  • conclusion (5m)

setup

nix-env package management

  • each user has a nix profile, pointing to the current user environment, that is a set of installed packages, managed via nix-env
  • only trusted channels are used by default, so updating the package lists is the only operation requiring root.
update package list sudo nix-channel --update
search nix search hello also try search.nixos.org/packages
install nix-env -iA nixos.hello run it with hello
uninstall nix-env -e hello running hello fails
rollback nix-env --rollback hello is back

nix-shell isolated environments

  • start a shell in an environment with some packages available, and run some commands in it:
    • nix-shell -p toilet
      • toilet NixOS
      • Ctrl+D to exit nix-shell
      • toilet NixOS fails
  • start a shell with packages and run a command in it:
    • nix-shell -p toilet --run 'toilet --gay hello'
  • try a python example
  • nix-shell on its own will load default.nix or shell.nix from the current directory, where you can define an environment for a project.

NixOS declarative operating system configuration

  • edit /etc/nixos/configuration.nix
    • eg. add services.openssh.enable = true; before the last }
  • nixos-rebuild switch to the new configuration
  • nixos-option services.openssh.enable to see the option's current value and documentation
  • find the option on search.nixos.org/options, click the result, click the link after "Declared in:" and see The Source
  • nixos-rebuild switch --rollback to previous configuration

let's try a few configuration options:

service

system

user

network

  • networking.hostName = "darkstar";
  • networking.firewall.allowedTCPPorts = [ 22 80 8000 ];

conclusion

  • declarative - say what you want, not how to get there
  • safe (atomic, rollback, isolated, consistent, hash-checked)
  • reliable (deterministic, reproducible)
  • fast (lazy, hash-based store, binary cache)
  • great for repeatable builds and declarative operating system configuration

nixos-tutorial's People

Contributors

brainrake avatar oliverevans96 avatar xurei avatar

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.