cant import channels

Hi, i just installed nix as single user, but it won’t import anything… I will now provide my code and the errors i get when trying to build.

{ stdenv ? import <nixpkgs> {} }:

stdenv.mkDerivation {
  pname = "dbView";
  version = "0.1.0"; # Assign a version 
  src = ./.; # Assuming your source files are in the same directory

  buildPhase = ''
    mkdir -p obj bin
    gcc -c src/*.c -o obj/%.o -I include
    gcc -o bin/dbView obj/*.o
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp bin/dbView $out/bin/
  '';
}

Nix-build

error: attribute 'mkDerivation' missing
       at /home/iaco/code/databaseProject/default.nix:3:1:
            2|
            3| stdenv.mkDerivation {
             | ^
            4|   pname = "dbView";

stdenv is an attribute of your nixpkgs instance. You rather want to do:

{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation {
  pname = "dbView";
  version = "0.1.0"; # Assign a version 
  src = ./.; # Assuming your source files are in the same directory

  buildPhase = ''
    mkdir -p obj bin
    gcc -c src/*.c -o obj/%.o -I include
    gcc -o bin/dbView obj/*.o
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp bin/dbView $out/bin/
  '';
}

When in doubt, don’t hesitate to start a repl and use tab-complete to interactively explore the shape of the various nixpkgs attributesets:

~ » nix repl                                                                                                                                  
nix-repl> :l <nixpkgs>
Added 22757 variables.

nix-repl> pkgs.std<tab>
pkgs.stdenv          pkgs.stdenvNoCC      pkgs.stdenvNoLibs    pkgs.stderred        pkgs.stdmanpages     pkgs.stduuid
pkgs.stdenvAdapters  pkgs.stdenvNoLibc    pkgs.stdenv_32bit    pkgs.stdman          pkgs.stdoutisatty
1 Like