Documentation

menu

Nix flakesshare

Nix flakes provide a standardized interface for nixified git repos. garnix reads the flake.nix file from the root directory of your repos and uses the flake outputs — the declared packages, apps and NixOS configurations — to figure out what to build, run and deploy.

Here's a very simple example flake.nix file:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs";
  };
  outputs = { self, nixpkgs }: {
    packages.x86_64-linux =
      let pkgs = import nixpkgs { system = "x86_64-linux"; };
      in {
        myExamplePackage = pkgs.runCommand "example" { } ''
          echo hello from nix!
          echo "build output" > $out
        '';
      };
  };
}

You can build the flake locally with:

nix build -L .#myExamplePackage

Further reading about Nix flakes:share