You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
blueprint is an opinionated library that maps a standard folder structure to
19
-
flake outputs. It makes common use cases easy both for the author and
20
-
consumers.
18
+
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.
19
+
20
+
Blueprint also makes common use cases easy for both the author and consumers.
Nix is just a tool. It should help you, and stay out of the way. But because
56
-
it's so flexible, everybody goes through a long period where they figure out
57
-
how to structure their repo. `flake.nix` files become noisy with boilerplate.
49
+
Nix is just a tool. It should help you, and stay out of the way. But because it's so flexible, everybody goes through a long period where they figure out how to structure their repo. `flake.nix` files become noisy with boilerplate.
58
50
59
-
By making a few opinionated choices, we're able to cut 99% of the glue code
60
-
you would find in most repos. A bit like Ruby on Rails or NextJS did for web
61
-
frameworks, we do it for Nix packages. We map folder and files to flake
62
-
outputs.
51
+
By making a few opinionated choices, we're able to cut 99% of the glue code you would find in most repos. A bit like Ruby on Rails or NextJS did for web frameworks, we do it for Nix packages. We map folder and files to flake outputs.
63
52
64
-
In some ways, this is the spiritual successor to `flake-utils`, my first
65
-
attempt at making flakes easier to use.
53
+
In some ways, this is the spiritual successor to `flake-utils`, my first attempt at making flakes easier to use.
66
54
67
-
Blueprint isn't suitable for complex flakes but it does allow you to easily
68
-
break out once your project becomes complicated beyond its capability.
55
+
Blueprint isn't suitable for complex flakes but it does allow you to easily break out once your project becomes complicated beyond its capability.
69
56
70
57
## Design principles
71
58
@@ -80,3 +67,101 @@ break out once your project becomes complicated beyond its capability.
*[clan-core](https://git.clan.lol/clan/clan-core) is an all-in-one solution to manage your deployments.
70
+
71
+
## Full Documentation
72
+
73
+
You can find the [full documentation here](https://numtide.github.io/blueprint/main/).
74
+
75
+
## Quickstart
76
+
77
+
Meanwhile, if you're ready to get started right away, here's what you do.
78
+
79
+
1.[Install Nix](https://nix.dev/install-nix) or use NixOS.
80
+
2. Run `mkdir my-project && cd my-project`
81
+
3. Run `nix flake init -t github:numtide/blueprint`
82
+
83
+
Now you're ready to create some folders and special files. The full documentation shows you all the folders and special files available, but for now let's create a couple of development shells, and a formatter.
84
+
85
+
Remember, the goal is to divide up the flake.nix file into individual modular parts. This not only helps keep your flake.nix file size down, it lets you create reusable modules that you can easily drop into other projects.
86
+
87
+
Let's create a package the builds a docker container from our source, assuming your source lives in a folder called src off the root folder. Assume your src entry point is a file called hello.py; in this example, just put the following in `hello.py`:
88
+
89
+
```
90
+
print('Hello from docker!')
91
+
```
92
+
93
+
Also from the root folder create a folder called `packages`, and under that a folder called `docker-python-hello`. Inside that folder create a file called `default.nix`, and place the following in it:
94
+
95
+
```nix
96
+
{ pkgs, system, ... }:
97
+
98
+
let
99
+
python = pkgs.python3;
100
+
101
+
pythonApp = pkgs.stdenv.mkDerivation {
102
+
pname = "my-python-app";
103
+
version = "1.0";
104
+
src = ../../src;
105
+
106
+
installPhase = ''
107
+
mkdir -p $out/app
108
+
cp hello.py $out/app/
109
+
'';
110
+
};
111
+
112
+
rootImage = pkgs.buildEnv {
113
+
name = "my-docker-root";
114
+
paths = [ python pythonApp ];
115
+
pathsToLink = [ "/bin" "/app" ]; # python will be linked in /bin
This template is a bit of an example plus a template. You'll want to study all the files carefully. It shows how you can define and reuse modules, in this case nixos and home-manager.
32
+
33
+
Look carefully at the folder structure; in this case we're using `hosts` and `modules` folders which are both picked up by Blueprint.
34
+
35
+
If you drill down into the folders, you'll see inside the `hosts` folder, are a `my-darwin` folder and a `my-nixos` folder, both of which are imported by Blueprint. This defines the two hosts called `my-darwin` and `my-nixos`.
36
+
37
+
Their respective configuration files both import a shared `modules/nixos/host-shared.nix` module between them.
38
+
39
+
Also, both hosts define a `me` user and their home-manager configuration simply imports `modules/homes/home-shared.nix`.
40
+
41
+
Finally, notice in the root `flake.nix` we're adding the home-manager and nix-darwin inputs, which serve as dependencies for managing home configurations and macOS integrations, respectively.
42
+
43
+
The idea with this template is that you can use this example to get started on how to share configurations between different system and home environments on different hosts.
44
+
45
+
46
+
## Toml-DevEnvs
47
+
48
+
Members of your team might be intimidated by Nix and flake files, and prefer a more traditional method of configuring their devshells. As such, we provide full support for TOML files.
49
+
50
+
For more information, please visit our [devshell repo](https://github.com/numtide/devshell), which is what powers this template behind-the-scenes.
Notice that the root flake.nix file we're adding the system-manager input, which is our own project. You can find it on GitHub at [system-manager](https://github.com/numtide/system-manager), where you can read more information on how to use it.
If set, blueprint will create a new overlay with the passed config.
67
79
68
80
Type: list of functions.
69
81
70
-
Example:
82
+
Here's an example that creates a couple of overlays; the first ("otherflake") reuses an overlay defined in another flake, and the second, an inline overlay, defines an overlay that replaces the default git package with the smaller gitMinimal:
0 commit comments