Blueprint¶
Blueprint is an opinionated library that maps a standard folder structure to flake outputs, allowing you to divide up your flake into individual files across these folders. This allows you to modularize and isolate these files so that they can be maintained individually and even shared across multiple projects.
Blueprint has built-in support for System Manager, which means:
- You do not need to call
system-manager.lib.makeSystemConfig; Blueprint calls this for you - You must follow Blueprint's folder structure by placing your files under the
hostsfolder, and you must name your filessystem-configuration.nix. - You can have multiple folders under the
hostsfolder (but one level deep), and you can access these using the standard nix specifier, e.g..#folder-name.
In this section we show you how to use Blueprint with System Manager.
Blueprint provides its own initialization that you can start with if you don't already have a flake.nix file using Blueprint. The command to type is:
This results in the following flake:
Now add System Manager to its inputs section:
Next, create a folder called hosts, and under that a folder called default:
Inside default is where you'll put your configuration file.
This configuration file must be named system-configuration.nix.
For example, here's a configuration file that installs bat:
Note
Notice that we need to include nixpkgs.hostPlatform in this file, as there's no place to include it in the parent flake.nix file.
Now return to the folder two levels up (the one containing flake.nix) and you can run System Manager:
Remember
As mentioned elsewhere, if this is the first time running System Manager on this computer, you'll need to log out and log back in to pick up the new path.
Then you should find bat on your path:
The default folder is called default; you can also refer to folders by name as mentioned earlier.
If, for example, under the hosts folder you have a folder called tree, and inside tree you create a file called system-configuration.nix with the following contents:
Then you can choose to install tree by specifying the tree folder like so:
Using multiple configuration files with Blueprint¶
If you want to load multiple configuration files at once, you can create a special system-configuration.nix file that loads multiple files from a modules folder (or any name you choose). To accomplish this, create a folder under hosts; for example, you might name it cli-tools. Starting in the folder with flake.nix:
Then, inside the cli-tools folder, create a system-configuration.nix file with the following:
(Notice this time we can put the nixpkgs.hostPlatform in a single place. As such we won't need it in the configuration files.)
Now move into the modules folder:
And create two files here:
tldr.nix:
cowsay.nix:
Now you can return to the top level where your flake.nix file is and run these two configuration files:
This means if you want to include various recipes, you can easily do so.