wiki/structured/tools.nix.derivations.org
Gabriel Arazas edc686c25c Update wiki on various topics
This update is too large, I made too many notes on stuff. Nonetheless,
it is very nice to see progress. I've made note revisions on the
following topics:

- Learning
- Writing
- Various Linux-related stuff

I've yet to start learning illustration but I'll be starting tomorrow
for an update how do I keep in mind with those writings. There are still
a lot of things to be processed from the backlog with yet more notes on
learning but I keep having those perspectives whenever I practice so
ehhh... Better have those than nothing?

Furthermore, I've also updated the timestamp format. It is pretty simple
to update all of the notes with a couple of `sed` calls.

Aaaand, I've also changed the way how the assets stored with the folders
only leaving it up for the generated files instead of enforcing it on
every note. I create more visual aids and managing them is a pain for
each note. This restructuring frees me of that burden.
2021-07-20 19:52:43 +08:00

2.8 KiB

Nix derivations

Derivations are recipes for the Nix build daemon how to build the package. At a glance, this is the equivalent to manifests from Flatpak packages or Guix packages.

The following code block shows what a derivation looks like.

nix show-derivation nixpkgs.hello
{
  "/nix/store/7xcq1j6kxry9p5scmgccifqp1m57ha17-hello-2.10.drv": {
    "outputs": {
      "out": {
        "path": "/nix/store/kzq2f6pqb3ig89278n3c21g6x4y3pghs-hello-2.10"
      }
    },
    "inputSrcs": [
      "/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"
    ],
    "inputDrvs": {
      "/nix/store/aq6m16jyrdpz2frivygw0502lkhyv271-stdenv-linux.drv": [
        "out"
      ],
      "/nix/store/hhq1cbwwjm28bp7bnr9ivlvgah7988xb-hello-2.10.tar.gz.drv": [
        "out"
      ],
      "/nix/store/mhgg30w6ayhbvnp03z8gx4c92n67ajg6-bash-4.4-p23.drv": [
        "out"
      ]
    },
    "platform": "x86_64-linux",
    "builder": "/nix/store/26a78ync552m8j4sbjavhvkmnqir8c9y-bash-4.4-p23/bin/bash",
    "args": [
      "-e",
      "/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"
    ],
    "env": {
      "buildInputs": "",
      "builder": "/nix/store/26a78ync552m8j4sbjavhvkmnqir8c9y-bash-4.4-p23/bin/bash",
      "configureFlags": "",
      "depsBuildBuild": "",
      "depsBuildBuildPropagated": "",
      "depsBuildTarget": "",
      "depsBuildTargetPropagated": "",
      "depsHostHost": "",
      "depsHostHostPropagated": "",
      "depsTargetTarget": "",
      "depsTargetTargetPropagated": "",
      "doCheck": "1",
      "doInstallCheck": "",
      "name": "hello-2.10",
      "nativeBuildInputs": "",
      "out": "/nix/store/kzq2f6pqb3ig89278n3c21g6x4y3pghs-hello-2.10",
      "outputs": "out",
      "patches": "",
      "pname": "hello",
      "propagatedBuildInputs": "",
      "propagatedNativeBuildInputs": "",
      "src": "/nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz",
      "stdenv": "/nix/store/dj40kjgp5lhs55v4hc47vyrarhq4qycz-stdenv-linux",
      "strictDeps": "",
      "system": "x86_64-linux",
      "version": "2.10"
    }
  }
}

While we can create derivations with the Nix language, it is unnecessary and verbose if we use nixpkgs. nixpkgs has made the process easier with their standard library.

  • stdenv.mkDerivation
  • nixpkgs also comes with several convenient functions/environments for several programming languages and frameworks including Python, Rust, Go, and Nim
  • it also includes environments for common setups such as for clang compiler