mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-02-07 09:18:59 +00:00
732ef34ca8
Welp, I rarely take notes nowadays due to more specialized work and stuff. Though, I should have more incentives for writing. In other words, I'm just lazy. ;p More free-thinking morning sessions should be done soon.
4.4 KiB
4.4 KiB
Nix flakes
As of 2021-06-30, the version used for this note is at v2.3 so it needs to be invoked with the unstable version.
- similar to Guix channels
- a collection of packages and functions while making it easy to configure Nix declaratively
- replaces the traditional Nix channels since fully reproducing an environment with Nix requires special care in practice; it isn't fully reproducible in practice such as the inclusion of Nix paths embedded in environment variables and access to arbitrary files; plus, there's no standard way of composing projects with Nix
- as of 2021-06-30, this is on the unstable version of the Nix package manager and needs some additional configuration
why flakes?
- provides a structure for discoverability
- makes 100% reproducibility a little easier with Nix
- in case you're using NixOS, it also provides an easier way to extend it with third-party custom modules
Here's an example to interact with a flake. It will show the entire outputs of a flake as well as the normalized version of the flake object.
#! nix-shell -i bash -p nixUnstable
nix --experimental-features 'nix-command flakes' flake show <<flake-sample-object()>> | sed -e "s/\x1b\[.\{1,5\}m//g"
github:edolstra/dwarffs/f691e2c991e75edb22836f1dbe632c40324215c5 ├───checks │ ├───aarch64-linux │ │ ├───build: derivation 'dwarffs-0.1.20210121.f691e2c' │ │ └───test: derivation 'vm-test-run-unnamed' │ ├───i686-linux │ │ ├───build: derivation 'dwarffs-0.1.20210121.f691e2c' │ │ └───test: derivation 'vm-test-run-unnamed' │ └───x86_64-linux │ ├───build: derivation 'dwarffs-0.1.20210121.f691e2c' │ └───test: derivation 'vm-test-run-unnamed' ├───defaultPackage │ ├───aarch64-linux: package 'dwarffs-0.1.20210121.f691e2c' │ ├───i686-linux: package 'dwarffs-0.1.20210121.f691e2c' │ └───x86_64-linux: package 'dwarffs-0.1.20210121.f691e2c' ├───nixosModules │ └───dwarffs: NixOS module └───overlay: Nixpkgs overlay
Let's build from one of the outputs of call_flake-sample-object().
#! nix-shell -i bash -p nixUnstable
nix --experimental-features 'nix-command flakes' build 'github:edolstra/dwarffs#checks.aarch64-linux.build'
nix --experimental-features 'nix-command flakes' shell 'github:edolstra/dwarffs' --command dwarffs --version
fusermount version: 2.9.9
For full reproducibility, you can refer to specific point of a flake (e.g., commit).
To easily get a pinned URL, you can run flake metadata
subcommand.
#! nix-shell -i bash -p nixUnstable
nix --experimental-features 'nix-command flakes' flake metadata 'github:edolstra/dwarffs' | sed -e "s/\x1b\[.\{1,5\}m//g"
Resolved URL: github:edolstra/dwarffs Locked URL: github:edolstra/dwarffs/f691e2c991e75edb22836f1dbe632c40324215c5 Description: A filesystem that fetches DWARF debug info from the Internet on demand Path: /nix/store/769s05vjydmc2lcf6b02az28wsa9ixh1-source Revision: f691e2c991e75edb22836f1dbe632c40324215c5 Last modified: 2021-01-21 22:41:26 Inputs: ├───nix: github:NixOS/nix/6254b1f5d298ff73127d7b0f0da48f142bdc753c │ ├───lowdown-src: github:kristapsdz/lowdown/1705b4a26fbf065d9574dce47a94e8c7c79e052f │ └───nixpkgs: github:NixOS/nixpkgs/ad0d20345219790533ebe06571f82ed6b034db31 └───nixpkgs follows input 'nix/nixpkgs'
#! nix-shell -i bash -p nixUnstable
nix --experimental-features 'nix-command flakes' shell github:edolstra/dwarffs/f691e2c991e75edb22836f1dbe632c40324215c5 --command dwarffs --version
fusermount version: 2.9.9