niv
niv copied to clipboard
Write more examples
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.
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
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.
#167 Added the examples.
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)