0xB10C
bitcoin++ 2023
no photos, ty
Nix | a package manager |
NixOS | a Linux distribution |
NixOS module | isolated and reusable NixOS component |
Is configuration.nix
a NixOS module?
{
imports = [
# Paths to local modules.
# Compose this module by combining others.
];
options = {
# Option declarations.
# Declare what settings a user of this module can control.
# For example, an "enable" option to let a user choose to enable it.
# (this is an API declaration)
};
config = {
# Option definitions.
# Set options of other modules.
# (this you using an API of another NixOS module)
};
}
options = {
name = mkOption {
type = type specification;
default = default value;
example = example value;
description = lib.mdDoc "Description for use in the NixOS manual.";
};
...
};
types.bool
- A boolean, can be true or false types.int
- A signed integertypes.ints.unsigned
- An unsigned integertypes.port
- A porttypes.str
- A string types.path
- A filesystem path, starts with a / types.package
- A Nix packageSee also NixOS manual: Option Types
types.listOf t
- A list with entries of type t
types.attrsOf t
- An attribute set with values of type t
types.nullOr t
- null
or type t
See also NixOS manual: Option Types
lib.mkEnableOption (lib.mdDoc "magic")
# is short for
lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = lib.mdDoc "Whether to enable magic.";
}
See also NixOS manual: mkEnableOption
options = {
services.bitcoind = {
enable = mkEnableOption "Bitcoin daemon";
...
dataDir = mkOption {
type = types.path;
default = "/var/lib/bitcoind";
description = mdDoc "The data directory for bitcoind.";
};
...
};
};
from nix-bitcoin/modules/bitcoind.nix
let
cfg = config.services.bitcoind;
in
{
config = mkIf cfg.enable {
systemd.services.bitcoind = {
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/bitcoind -datadir='${cfg.dataDir}'";
...
};
...
};
};
}
from nix-bitcoin/modules/bitcoind.nix
add e1 e2
- Return the sum of e1
and e2
toString e
- Convert the expression e
to a stringtrace e1 e2
- Print e1
and return e2
. Useful for debugging.map f list
- Apply the function f
to each element in the list list
sh nixos-rebuild-vm.sh
ssh vm
host$ command
and vm$ command
systemctl status
log lines?your_app_server
configuration.nix
bitcoind
and your_app
?