Go to file
Patrick MARIE 78894bd3b1 Adding an extend example (helm+oci) 2024-03-24 09:33:05 +01:00
flake-basic Initial commit 2024-03-17 17:33:12 +01:00
flake-mkDerivation Adding more flakes samples 2024-03-19 07:46:33 +01:00
flake-multi-platform Adding more flakes samples 2024-03-19 07:46:33 +01:00
flake-rust-devshell Adding more flakes samples 2024-03-19 07:46:33 +01:00
flake-rust-docker Adding flake-rust-docker 2024-03-19 08:21:16 +01:00
hello-derivation Initial commit 2024-03-17 17:33:12 +01:00
hello-versions Initial commit 2024-03-17 17:33:12 +01:00
hello-world Initial commit 2024-03-17 17:33:12 +01:00
hello-world-callpackage Initial commit 2024-03-17 17:33:12 +01:00
hello-world-docker Initial commit 2024-03-17 17:33:12 +01:00
hello-world-github Initial commit 2024-03-17 17:33:12 +01:00
hello-world-go Initial commit 2024-03-17 17:33:12 +01:00
helm-poc Adding an extend example (helm+oci) 2024-03-24 09:33:05 +01:00
poc-gomod2nix Adding a gomod2nix test sample 2024-03-20 07:34:46 +01:00
poc-helm-oci Adding an extend example (helm+oci) 2024-03-24 09:33:05 +01:00
poc-oci Adding a POC for basic OCI images 2024-03-22 15:51:40 +01:00
samples/shaka-packager Initial commit 2024-03-17 17:33:12 +01:00
simple-shell Initial commit 2024-03-17 17:33:12 +01:00
.gitignore Adding a POC around helm 2024-03-20 23:30:01 +01:00
README.md Adding more flakes samples 2024-03-19 07:46:33 +01:00
TODO.md Initial commit 2024-03-17 17:33:12 +01:00

README.md

Nix samples

Existing samples

  • hello-world: Sample local C program;
  • hello-world-github: Some github hosted program, built against Wayland;
  • hello-world-callpackage: A basic callPackage usage;
  • hello-world-go: Basic usage of buildGoModule;
  • hello-world-docker: A docker image of a binary extracted from another derivation;
  • simple-shell: Some shells;
  • hello-versions: Choosing some package version;
  • samples: A directory with found exicting recipes!
  • flake-basic: A really basic flake
  • flake-basic-platform: A slighly more complex flake, with more targets
  • flake-mkDerivation: A flake with a ... mkDerivation
  • flake-rust-devshell: A flake with a rust overlay

Building, running, deleting

hello-world

> cd /path/to/nix-samples
> nix-build hello-world/default.nix
this derivation will be built:
  /nix/store/rwi8d1fv4hnpl194pi2cj7ikph2k5ny8-hello.drv
building '/nix/store/rwi8d1fv4hnpl194pi2cj7ikph2k5ny8-hello.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/29265kg6m3mzgf7rhfqjx34dwhgn9p4g-src
...
stripping (with command strip and flags -S -p) in  /nix/store/4nzxqrm1gddddwlz55c2q398p0si4qhf-hello/bin
/nix/store/4nzxqrm1gddddwlz55c2q398p0si4qhf-hello

> nix profile install /nix/store/4nzxqrm1gddddwlz55c2q398p0si4qhf-hello
> nix profile list
Name:               hello
Store paths:        /nix/store/4nzxqrm1gddddwlz55c2q398p0si4qhf-hello

> hello
/home/mycroft/.nix-profile/bin/hello

Note: ~/.nix-profile/bin was added in $PATH.

Prior to remove it, it must be unlinked from the profile and the build:

> nix-store --query --roots /nix/store/4nzxqrm1gddddwlz55c2q398p0si4qhf-hello
/home/mycroft/.local/state/nix/profiles/profile-7-link -> /nix/store/53zlkdqd1m2wdgi2a9q390ld9gkkkydf-profile
/home/mycroft/dev/nix-samples/result -> /nix/store/4nzxqrm1gddddwlz55c2q398p0si4qhf-hello

> nix profile remove /nix/store/4nzxqrm1gddddwlz55c2q398p0si4qhf-hello
removing 'hello'

> 

It will be needed to wipe the profile history and the result link to be able to nix-store --delete or nix-collect-garbage.

Resources