niv icon indicating copy to clipboard operation
niv copied to clipboard

Write more examples

Open nmattia opened this issue 5 years ago • 4 comments

There are many ways to use niv. With and without overlays, with and without nixpkgs. There should be a dedicated examples directory, and ideally a website with some tutorials.

nmattia avatar Dec 17 '19 21:12 nmattia

Hello, I have tried to put it together with simple hello-world example, but unfortunately I am still unable to get Cmake to find the libosmium which was build by Nix. I don't know how would I even point the cmake to the correct directory as this is dynamically generated by nix build. I am attaching my attempt to get this working. I have tried also substituting libosmium with any random library, eg. Boost, but even derivations from Nixpkgs, Cmake is just not being able to find. Would you be able to help me out? test.tar.gz

brano543 avatar Dec 18 '19 17:12 brano543

Nevermind, I have figured it out. The problem is that libosmium is header-only library which has multiple dependencies which also header-only. In order to check for their presence we need to propagate them in main default.nix. I will make pull request to add the working example.

brano543 avatar Dec 19 '19 13:12 brano543

#167 Added the examples.

brano543 avatar Dec 19 '19 14:12 brano543

I would also love to see some examples managing overlay dependencies/versioning home-manager nixpkgs/versioning nixos packages.

For example, I usually use niv to follow multiple channels/version my overalys, for example with home-manager. Not sure if the cleanest, but here is how I do things:

My (cut-down) home.nix:

{ config, ... }:

let
  sources = import ./nix/sources.nix;
  pkgs-unstable = import sources.nixpkgs-unstable {};
  pkgs = import sources.nixpkgs {};
  pinned_nixpkgs_unstable = import (
    builtins.fetchTarball {
      name = "nixpkgs-unstable-pinned";
      url = https://github.com/nixos/nixpkgs/archive/a21c2fa3ea2b88e698db6fc151d9c7259ae14d96.tar.gz;
      sha256 = "1z3kxlbz6bqx1dlagcazg04vhk67r8byihzf959c3m0laf2a1w7y";
    }
  ) {};
in
{
  home.packages = (
    with pkgs-unstable; [
      fd
    ]
  ) ++ (
    with pinned_nixpkgs_unstable; [
      neovim
    ]
  ) ++ (
    with pkgs; [
      rg
   ]);
  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}

and my neovim overlay:

let
  sources = import ../nix/sources.nix;
in self: super: {
  neovim-unwrapped = super.neovim-unwrapped.overrideAttrs (old: {
    version = "master";
    src = super.fetchFromGitHub { inherit (sources.neovim) owner repo rev sha256; };
    buildInputs = super.neovim-unwrapped.buildInputs ++ super.neovim-unwrapped.nativeBuildInputs ++ [ super.utf8proc ];
    # cmakeFlags .cmakeFlags;
  });
}

This let's me update my overlay to the latest git, while keeping my nixpkgs pinned (due to a bug in luv that will be fixed pending my PR)

mjlbach avatar Feb 15 '20 18:02 mjlbach