% Packaging 101 % Tokyo NixOS Meetup % 2016, 18 February
- Nix 1.11 released
- Nix Funding: remove perl from Nix, successly founded!
- New Nix Command line coming ヽ(=´▽`=)ノ
- dockerTools: build docker images from Nix expressions
- Multiple outputs PR on the point of being merged
- NixOS on Digital Ocean
- Using Nix instead of Docker
- What are NixOS cons
- Migration to NixOS
- Setting up your own build farm (Repository)
- Using Nix as the package manager for a new language
- Flattening pkgs tree
- Wiki is dead
- CVE-2015-7547 stdenv-changing fix merged on master and 15.09
- OSC Tokyo Spring on Feb 26 - 27, everybody welcome to join!
- Simple wallpapers (Welcoming contributions!)
- Nix goodies
- Japanese input done right! (almost)
- Japanese Wiki: new pages: Install & Nix internals!
- Nix: compiler for a functional package centric DSL
- functional = lazy + pure + deterministic
- pure = no missing dependency
- deterministic = binary install for free
- lazy = lightweight and fast
- DSL = easy customization
- package isolation = atomic upgrades + easy rollback + no Dependency hell + impossible to break system by installing a package
- not limited to system packages, Nix can package almost anything (great packaging of hackage)
- can be thought as "One package manager to rule them all" "Make on steroids"
- NixOS: an OS is packages + configuration, NixOS is Nix extended with a configuration DSL (module system)
- declarative configuration with typed properties
- lightweight containers (based on systemd nspawn)
- easy to add custom services
-
Foreword:
- Reading the contributor guide is always a good idea
- Basic understanding of the Nix language can help a lot, a tour of nix and the manual are great resources
-
Basic workflow:
- get nixpkgs
- create a package file in the somewhere in
pkgs/
- add the package entry in
pkgs/top-level/all-packages.nix
- build the package and test
-
go to github nixpkgs and click the Fork button
-
go to the forked repository and get the clone url
-
clone to a local machine
$ git clone [email protected]:USER/nixpkgs.git
-
Or just clone the official nixpkgs if you have no github account or don't plan to submit PRs.
-
Exercices:
- check the structure under the
pkgs/
. - check
pkgs/top-level/all-packages.nix
.
- check the structure under the
-
check the default hello package in
pkgs/applications/misc/hello/default.nix
-
create a dedicated branch
$ git checkout -b pkg/my-hello
-
create
my-hello
folder in misc$ mkdir pkgs/applications/misc/my-hello/
-
copy the hello derivation to my-hello
$ cp pkgs/applications/misc/{,my-}hello/default.nix
-
edit
pkgs/applications/misc/my-hello/default.nix
and change the derivation name to my-hello -
Exercices:
- Find what meta maintainers and licence fields refer to.
- Make yourself as the maintainer of
my-hello
.
-
add a my-hello entry to
all-packages.nix
-
Exercices
- figure the relation between the package name, the package path and the
all-packages.nix
entry name. - move the version in a dedicated attribute.
- (tip: check the tilda package)
- figure the relation between the package name, the package path and the
-
build the package
$ nix-build -A my-hello
-
run it!
$ ./result/bin/hello
-
Exercices:
- Check and note the my-hello nix store hash.
- (tip: result is a symlink to the store)
- Change my-hello version to 2.9
- (tip:
man nix-prefetch-url
).
- (tip:
- Compare the first my-hello and 2.9 my-hello store hash.
- Can you still run my-hello 2.10?
- Check and note the my-hello nix store hash.
- Find a package not yet available in nixpkgs and package it.
- Any idea on how to improve the meetup?
- Better times, better places?
- 3 places: meetup, connpass, doorkeeper; Meetup currently as a the main place
- more activities like OSC and other groups
- evolve to a "NixOS user group"?