-
Notifications
You must be signed in to change notification settings - Fork 8
doc, vm, template #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
21fd8e6
doc, vm, template
brainrake 425838a
Specify language for synyax highligthing
aciceri f5101d4
Expose `docs-serve` (also) directly as flake package
aciceri ead3499
Add missing direnv.net link
aciceri 2fb9789
Typo
aciceri e5106de
Fix dead link
aciceri d0db92e
Relativize link
aciceri eed08f7
Not treat as a markdown list
aciceri 51476b4
Move license link in menu
aciceri 8f37880
Minimal contributing page
aciceri a0b9fb6
Merge pull request #66 from mlabs-haskell/aciceri/doc
brainrake 88a9b12
fixes
brainrake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ | |
| /docs/reference/module-options | ||
| /.nixos-test-history | ||
| /result* | ||
| /*.qcow2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| self, | ||
| inputs, | ||
| ... | ||
| }: { | ||
| flake.nixosConfigurations = { | ||
| vm-preview = inputs.nixpkgs.lib.nixosSystem { | ||
| modules = [ | ||
| self.nixosModules.default | ||
| ./preview.nix | ||
| ./vm.nix | ||
| {nixpkgs.hostPlatform = "x86_64-linux";} | ||
| ]; | ||
| }; | ||
| }; | ||
| perSystem = _: { | ||
| apps = { | ||
| vm-preview = { | ||
| type = "app"; | ||
| program = "${self.nixosConfigurations.vm-preview.config.system.build.vm}/bin/run-nixos-vm"; | ||
| }; | ||
| }; | ||
| devshells.default.commands = [ | ||
| { | ||
| name = "vm-preview"; | ||
| category = "examples"; | ||
| command = "${self.nixosConfigurations.vm-preview.config.system.build.vm}/bin/run-nixos-vm"; | ||
| help = "Start vm with cardano services on the preview network and ports forwarded to host"; | ||
| } | ||
| ]; | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| cardano = { | ||
| enable = true; | ||
| network = "preview"; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| {modulesPath, ...}: { | ||
| imports = [ | ||
| (modulesPath + "/virtualisation/qemu-vm.nix") | ||
| (modulesPath + "/profiles/qemu-guest.nix") | ||
| ]; | ||
|
|
||
| # WARNING: don't use this in production | ||
| # Allow root login without password, auto login | ||
| users.users.root.password = ""; | ||
| services.getty.autologinUser = "root"; | ||
|
|
||
| virtualisation = { | ||
| cores = 2; | ||
| memorySize = 2048; | ||
| diskSize = 100 * 1024; | ||
| forwardPorts = [ | ||
| { | ||
| # cardano-node | ||
| from = "host"; | ||
| host.port = 3001; | ||
| guest.port = 3001; | ||
| } | ||
| { | ||
| # ogmios | ||
| from = "host"; | ||
| host.port = 1337; | ||
| guest.port = 1337; | ||
| } | ||
| ]; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,22 @@ | ||
| FIXME | ||
| There are several ways you can contribute. | ||
|
|
||
| ## Reporting issues | ||
|
|
||
| - Search the issue tracker before creating a new issue | ||
| - Provide detailed steps to reproduce the issue | ||
| - Include as much information as possible | ||
|
|
||
| ## Proposing features | ||
|
|
||
| - Use the issue tracker to propose new features | ||
| - Feel free to also propose a PR implementing it | ||
|
|
||
| ## Code style guidelines | ||
|
|
||
| - Format everything with `nix fmt .` | ||
|
|
||
| ## Checks | ||
|
|
||
| - You can verify that all checks pass with `nix flake check` | ||
|
|
||
| Thank you for contributing to `cardano.nix`! Your help is greatly appreciated 😊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| In order to access all the options available in `cardano.nix`, the [NixOS module](https://zero-to-nix.com/concepts/nixos#modules) provided by this project has to be included in a [NixOS configuration](https://zero-to-nix.com/concepts/nixos#configuration) and deployed to a (local or remote or virtual) machine. | ||
|
|
||
| ### Start new project with flake template | ||
|
|
||
| An easy way to get started is to use the [flake template](https://zero-to-nix.com/concepts/flakes#templates) provided by this project. Here's how to start a new project using the template: | ||
|
|
||
| ``` | ||
| mkdir myproject | ||
| cd myproject | ||
| nix flake init --template github:mlabs-haskell/cardano.nix | ||
| git init | ||
| git add . | ||
| ``` | ||
|
|
||
| ### Run a virtual machine | ||
|
|
||
| The default template provides a virtual machine configuration starting all the services in the preview testnet. Here's how to run it: | ||
|
|
||
| `nix run .#vm` | ||
|
|
||
| This machine is set up just like the one in [Run a VM](../vm), but can be customized. | ||
|
|
||
| ### Look around | ||
|
|
||
| The file named `flake.nix` includes: | ||
|
|
||
| - a [https://zero-to-nix.com/concepts/nixos#configuration](NixOS configuration) to run cardano services, under `nixosConfigurations.server` | ||
| - an app to run the virtual machine as above, under `apps.x86_64-linux.vm` | ||
|
|
||
| The file `configuration.nix` is the configuration for the machine. | ||
|
|
||
| ### Customize | ||
|
|
||
| To learn more, browse available [NixOS options in nixpkgs](https://search.nixos.org/options) and [NixOS options provided by cardano.nix](../../reference/module-options/cardano/) (see other modules in the menu on the left). You can ad these options to `configuration.nix` to configure the system. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,28 @@ | ||
| FIXME | ||
| ### Requirements | ||
|
|
||
| - linux | ||
| - nix | ||
| - kvm (optional, for running virtual machine tests) | ||
|
|
||
| ## Setup | ||
|
|
||
| Follow [this guide](https://zero-to-nix.com/start/install) to Install nix with [flakes](https://nix.dev/concepts/flakes.html) enabled. | ||
|
|
||
| ### Binary cache | ||
|
|
||
| You can optionally use this project's binary cache to skip building software and download it instead. Edit `/etc/nix/nix.conf` (or related settings in NixOS config) and merge the new values separated by spaces into the options: | ||
|
|
||
| ``` | ||
| substituters = ... https://cache.staging.mlabs.city/cardano-nix | ||
| trusted-public-keys = ... cardano-nix:BQ7QKgoQQAuL3Kh6pfIJ8oxrihUbUSxf6tN9SxyW608= | ||
| ``` | ||
|
|
||
| Don't edit `~/.config/nix/nix.conf` in your home directory. Don't add users to `trusted-users` because it is [insecure](https://nixos.org/manual/nix/stable/command-ref/conf-file.html?highlight=trusted-user#conf-trusted-users). | ||
|
|
||
| ### Check that it works | ||
|
|
||
| `nix --version` | ||
|
|
||
| ### Learn more | ||
|
|
||
| For an introduction to the Nix ecosystem, check out [Zero to Nix](https://zero-to-nix.com/). Learn more about [Nix flakes](https://zero-to-nix.com/concepts/flakes) and [NixOS](https://zero-to-nix.com/concepts/nixos). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| This project provides a virtual machine configuration with all cardano services. | ||
|
|
||
| `nix run github:mlabs-haskell/cardano.nix#vm-preview` | ||
|
|
||
| Log in with user `root`. The password is empty. | ||
|
|
||
| The following services will be started and ports forwarded to the host: | ||
|
|
||
| |cardano-node|3001| | ||
| |ogmios|1337| | ||
|
|
||
| In the virtual machine, `cardano-cli` is available to query the node. | ||
|
|
||
| `cardano-cli query tip --testnet-magic 2` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,41 @@ | ||
| # About the Project | ||
|
|
||
| `cardano.nix` is a collection of [Nix](https://nixos.org) packages and [NixOS](https://nixos.wiki/wiki/NixOS_modules) modules | ||
| designed to make it easier to operate [Cardano](https://cardano.org) related services and infrastructure. | ||
| `cardano.nix` is a collection of [Nix](https://nixos.org) packages and [NixOS modules](https://zero-to-nix.com/concepts/nixos#modules) designed to make it easy to operate [Cardano](https://cardano.org) related services and infrastructure. | ||
|
|
||
| ### Why? | ||
|
|
||
| [Nix](https://zero-to-nix.com/concepts/nix) is a declarative package manager ensuring hash-based reproducible build and dependency management. [NixOS](https://zero-to-nix.com/concepts/nixos) is a Linux distribution with a declarative configuration system. With NixOS, entire system configurations are reproducible and work the same regardless of the current state of the system. Updates (and rollbacks) are atomic: they either work or nothing happens, so they can't get stuck halfway through. These features are responsible for the increased reliability of a NixOS system, making it an attractive DevOps tool for deploying services. | ||
|
|
||
| ### What? | ||
|
|
||
| The `cardano.nix` project aims to provide [NixOS modules](https://zero-to-nix.com/concepts/nixos#modules) for Cardano services such as `cardano-node`, `ogmios`, `kupo`, `cardano-db-sync`, as well as auxiliary modules such as firewall and HTTP(S), making it easy to deploy these services in production. Very little configuration is needed to run the services with sane defaults that are easy to customize. The services can be run on the same host or in a distributed cluster, and a HTTPS proxy module is also provided. | ||
|
|
||
| ### How? | ||
|
|
||
| Here are some motivating examples. | ||
|
|
||
| This NixOS configuration will start `cardano-node` and related services on the `preview` testnet. | ||
|
|
||
| ```nix | ||
| { | ||
| cardano = { | ||
| enable = true; | ||
| network = preview; | ||
| }; | ||
| } | ||
| ``` | ||
|
|
||
| This snippet will configure a HTTPS reverse proxy and load balancer with ACME certificates from Let's Encrypt. DNS records need to be set up and the backend servers (configured as above) need to be reachable. | ||
|
|
||
| ```nix | ||
| { | ||
| cardano.http.enable = true; | ||
| services.http-proxy = { | ||
| domainName = "preview.example.com"; | ||
| https.enable = true; | ||
| servers = ["server1" "server2"]; | ||
| }; | ||
| }; | ||
| ``` | ||
|
|
||
| Configurations including the above can be deployed to a laptop, a virtual machine, a cloud instance, a container, or any other system running NixOS. Example configurations and shortcuts to run virtual machines are provided as part of the project. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.