0

According to https://chris-martin.org/2015/installing-nixos there is a /etc/nixos/configuration.nix file present.

I'm using the docker container from https://hub.docker.com/r/nixos/nix/ and running

find . -name "configuration.nix"

within the container returns no results.

Where is this configuration located?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286

4 Answers4

3

The mentioned docker container doesn't contain NixOS system. Quoting a comment:

It is basically Alpine linux distibution, with apk package manager and nix-env on top of it.

So, no NixOS, no configuration.nix.

( Wouldn't be supprised if OP made that comment ☻)

If we are talking about containers story for NixOS, it is in it's infancy state as of writing.

danbst
  • 3,363
  • 18
  • 38
2
echo $NIX_PATH

should tell you. Look for the definition of nixos-config.

Zimm i48
  • 2,901
  • 17
  • 26
1

If for some reason it doesn't exist or you cannot find it, you can pass everything you need for building your system as arguments to nixos-rebuild:

git clone --branch release-17.03 https://github.com/nixos/nixpkgs $HOME/nixpkgs
mkdir -p $HOME/nix-config
nixos-generate-config --dir $HOME/nix-config

nixos-install -I nixos-config=$HOME/nix-config/configuration.nix -I nixpkgs=$HOME/nixpkgs

I prefer doing it this way anyway, as it allows me to use my configured nixpkgs and nix-files which I store in a personal git repo.

William Casarin
  • 2,542
  • 2
  • 23
  • 24
  • Can you elaborate on what you mean by "building your system"? It sounds like we are making an additional 'copy' of Nix. I'd be more interested to know why it's not present on the docker container in the first place. Possibly an explanation of how this this configuration file relates to Nix / Nixos (is it optional perhaps)? – Chris Stryczynski Apr 02 '17 at 17:39
  • Since nixos is declarative, configuration.nix is the specification that describes the entire system from system packages to services. nixos-install and nixos-rebuild are commands that read configuration.nix to "build" the system described in configuration.nix. This also includes the hardware configuration such as hard drive mount points, which nixos-generate-config can generate automatically. – William Casarin Apr 02 '17 at 22:28
0

The nix image is not directly related to the Nixos project.

Something you could do with the nix container instead is create for example a nix-shell environment:

docker run -ti nixos/nix
cb84c4b79d05:/# echo '{ pkgs ? import <nixpkgs> {} }:
>   pkgs.mkShell {
>     buildInputs = [ pkgs.python pkgs.php ];
> }
> ' > shell.nix
cb84c4b79d05:/# nix-shell shell.nix 
these derivations will be built:
  /nix/store/j6p6rskjji6l4hw95wbyyj2iyxd9j1j5-php.ini.drv
  /nix/store/kymjwis1v82wif5jn7pczphg4j5q3ir5-php-with-extensions-7.4.4.drv
these paths will be fetched (96.21 MiB download, 436.69 MiB unpacked):
  /nix/store/0cxqyn95rh7vihmywnaimrxlpb58958i-php-gd-7.4.4
  /nix/store/0pxqh18n0wzqa6aamad2ljrl5nahlyiv-php-openssl-7.4.4
....
[nix-shell:/]# python --version
Python 2.7.18

[nix-shell:/]# php -v
PHP 7.4.4 (cli) (built: Mar 17 2020 10:40:37) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.4, Copyright (c), by Zend Technologies

More information available here: https://nixos.wiki/wiki/Development_environment_with_nix-shell

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286