Skip to content

Instantly share code, notes, and snippets.

@m1cr0man
Last active October 30, 2023 19:55
Show Gist options
  • Save m1cr0man/8cae16037d6e779befa898bfefd36627 to your computer and use it in GitHub Desktop.
Save m1cr0man/8cae16037d6e779befa898bfefd36627 to your computer and use it in GitHub Desktop.
The simplest Nix Flake for nixos-rebuild
# This can be built with nixos-rebuild --flake .#myhost build
{
description = "the simplest flake for nixos-rebuild";
inputs = {
nixpkgs = {
# Using the nixos-unstable branch specifically, which is the
# closest you can get to following the equivalent channel with flakes.
url = "github:NixOS/nixpkgs/nixos-unstable";
};
};
# Outputs can be anything, but the wiki + some commands define their own
# specific keys. Wiki page: https://nixos.wiki/wiki/Flakes#Output_schema
outputs = { self, nixpkgs }: {
# nixosConfigurations is the key that nixos-rebuild looks for.
nixosConfigurations = {
myhost = nixpkgs.lib.nixosSystem {
# A lot of times online you will see the use of flake-utils + a
# function which iterates over many possible systems. My system
# is x86_64-linux, so I'm only going to define that
system = "x86_64-linux";
# Import our old system configuration.nix
modules = [
./configuration.nix
];
};
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment