2 years ago

#4724

test-img

AronNeewart

nix-shell script does nothing when using script

I'm quite new to Nix and I'm trying to create a very simple shell.nix script file.

Unfortunately I need an old package: mariadb-10.4.21. After reading and searching a bit I found out that version 10.4.17 (would've been nice to have the exact version but I couldn't find it) is in channel nixos-20.09, but when I do

$ nix-shell --version
nix-shell (Nix) 2.5.1
$ cat shell.nix
let
  pkgs = import <nixpkgs> {};

  # git ls-remote https://github.com/nixos/nixpkgs nixos-20.09
  pkgs-20_09 = import (builtins.fetchGit {    
    name = "nixpks-20.09";    
    url = "https://github.com/nixos/nixpkgs";    
    ref = "refs/heads/nixos-20.09";    
    rev = "1c1f5649bb9c1b0d98637c8c365228f57126f361";    
  }) {};        
in    
  pkgs.stdenv.mkDerivation {    
    pname = "test";    
    version = "0.1.0";    
      
    buildInputs = [    
      pkgs-20_09.mariadb    
    ];    
  } 

$ nix-shell

it just waits indefinitely without doing anything. But if I do

$ nix-shell -p mariadb -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/1c1f5649bb9c1b0d98637c8c365228f57126f361.tar.gz
[...]
/nix/store/yias2v8pm9pvfk79m65wdpcby4kiy91l-mariadb-server-10.4.17
[...]
copying path '/nix/store/yias2v8pm9pvfk79m65wdpcby4kiy91l-mariadb-server-10.4.17' from 'https://cache.nixos.org'...
[nix-shell:~/Playground]$ mariadb --version
mariadb  Ver 15.1 Distrib 10.4.17-MariaDB, for Linux (x86_64) using readline 5.1

it works perfectly.

What am I doing wrong in the script for it to halt?

EDIT: I got a bit more info by running

$ nix-shell -vvv
[...]
did not find cache entry for '{"name":"nixpks-20.09","rev":"1c1f5649bb9c1b0d98637c8c365228f57126f361","type":"git"}'
did not find cache entry for '{"name":"nixpks-20.09","ref":"refs/heads/nixos-20.09","type":"git","url":"https://github.com/nixos/nixpkgs"}'
locking path '/home/test/.cache/nix/gitv3/17blyky0ja542rww32nj04jys1r9vnkg6gcfbj83drca9a862hwp.lock'
lock acquired on '/home/test/.cache/nix/gitv3/17blyky0ja542rww32nj04jys1r9vnkg6gcfbj83drca9a862hwp.lock.lock'
fetching Git repository 'https://github.com/nixos/nixpkgs'...

Is it me or it seems like it's trying to fetch from two different sources? As far as I understood all three url, rev and ref are needed for git-fetching, but it looks like if it's splitting them.

EDIT2: I've been trying with fetchFromGitHub

pkgs-20_09 = import (pkgs.fetchFromGitHub {      
  name = "nixpks-20.09";      
  owner = "nixos";      
  repo = "nixpkgs";      
  rev = "1c1f5649bb9c1b0d98637c8c365228f57126f361";      
  sha256 = "0f2nvdijyxfgl5kwyb4465pppd5vkhqxddx6v40k2s0z9jfhj0xl";      
}) {};      

and fetchTarball

pkgs-20_09 = import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/1c1f5649bb9c1b0d98637c8c365228f57126f361.tar.gz") {};

and both work just fine. I'll use fetchFromGitHub from now on but it'd be interesting to now why fetchGit doesn't work.

mariadb

nix

nixos

mariadb-10.4

nixpkgs

0 Answers

Your Answer

Accepted video resources