Start a shell and install package from local nixpkgs repo:

nix-shell -I nixpkgs=./nixpkgs/ -p package1 package2

Hints: https://www.mankier.com/1/nix-shell

Create a container from a configuration.nix

sudo nixos-container create container-name --config-file /path/configuration.nix

Experimental nixos features in nixos-rebuild

nixos-rebuild --option experimental-features "nix-command flakes" switch

error: file ’nixos-config’ was not found in the Nix search path (add it using $NIX_PATH or -I)

nix-channel --update

Call flake by name

nixos-rebuild switch --flake .#witness

generate (hardware) config

nixos-generate-config

Simple flake for OS config

{
  description = "Your new nix config";

  inputs = {
    # Nixpkgs
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";

  };

  outputs = {
    self,
    nixpkgs,
    ...
  } @ inputs: let
    inherit (self) outputs;
  in {
    # NixOS configuration entrypoint
    nixosConfigurations = {
      # FIXME replace with your hostname
      teletyper = nixpkgs.lib.nixosSystem {
        specialArgs = {inherit inputs outputs;};
        # > Our main nixos configuration file <
        modules = [./configuration.nix];
      };
    };
  };
}