Getting the Sources By default, NixOS’s nixos-rebuild command uses the NixOS and Nixpkgs sources provided by the nixos-unstable channel (kept in /nix/var/nix/profiles/per-user/root/channels/nixos). To modify NixOS, however, you should check out the latest sources from Git. This is done using the following command: $ nixos-checkout /my/sources or $ mkdir -p /my/sources $ cd /my/sources $ nix-env -i git $ git clone git://github.com/NixOS/nixpkgs.git This will check out the latest NixOS sources to /my/sources/nixpkgs/nixos and the Nixpkgs sources to /my/sources/nixpkgs. (The NixOS source tree lives in a subdirectory of the Nixpkgs repository.) It’s often inconvenient to develop directly on the master branch, since if somebody has just committed (say) a change to GCC, then the binary cache may not have caught up yet and you’ll have to rebuild everything from source. So you may want to create a local branch based on your current NixOS version: $ /my/sources/nixpkgs/maintainers/scripts/update-channel-branches.sh Fetching channels from https://nixos.org/channels: * [new branch] cbe467e -> channels/remotes/nixos-unstable Fetching channels from nixos-version: * [new branch] 9ff4738 -> channels/current-system Fetching channels from ~/.nix-defexpr: * [new branch] 0d4acad -> channels/root/nixos $ git checkout -b local channels/current-system Or, to base your local branch on the latest version available in the NixOS channel: $ /my/sources/nixpkgs/maintainers/scripts/update-channel-branches.sh $ git checkout -b local channels/remotes/nixos-unstable You can then use git rebase to sync your local branch with the upstream branch, and use git cherry-pick to copy commits from your local branch to the upstream branch. If you want to rebuild your system using your (modified) sources, you need to tell nixos-rebuild about them using the flag: $ nixos-rebuild switch -I nixpkgs=/my/sources/nixpkgs If you want nix-env to use the expressions in /my/sources, use nix-env -f /my/sources/nixpkgs, or change the default by adding a symlink in ~/.nix-defexpr: $ ln -s /my/sources/nixpkgs ~/.nix-defexpr/nixpkgs You may want to delete the symlink ~/.nix-defexpr/channels_root to prevent root’s NixOS channel from clashing with your own tree.