mirror of
https://github.com/nix-community/srvos.git
synced 2024-09-11 14:17:02 +03:00
Merge #81
81: remove the _file references r=Mic92 a=zimbatm Co-authored-by: zimbatm <zimbatm@zimbatm.com>
This commit is contained in:
commit
d3394d6d90
@ -2,23 +2,3 @@
|
||||
|
||||
This page explains some of the design decisions that have been made trough
|
||||
this project.
|
||||
|
||||
## What are there `_file` attributes in the NixOS modules?
|
||||
|
||||
TL;DR: to provide better error reporting.
|
||||
|
||||
This is a bit of a subtle issue, combining knowlede about both Flakes and the Nix module system, so please hang with me.
|
||||
|
||||
First, there are two types of imports in the Nix ecosystem:
|
||||
|
||||
1. The `import` builtin function. This can be used anywhere in the code read a target Nix file, and return the evaluation result in its place.
|
||||
2. The `imports` attribute in the Nix module system. This takes a list of either path, attr or function, which is then used to extend the module system with new option of config values.
|
||||
|
||||
The reason to add the `_file` attribute is that it's used to report when there are value or type clashes while building the config tree.
|
||||
It helps the user be pointed directly to the right location. Typically, NixOS modules are passed as a path, and in that case, the module system transparently annotates the module with the `_file` attribute so you don't see it in most cases.
|
||||
|
||||
Now let's talk about flakes.
|
||||
|
||||
When running `nix flake check`, Nix expects the NixOS modules to sit in the `nixosModules.<name>` prefix. And that the value is a function. If we give it a path, it will fail the check. So we can't have a path to (2) and therefor need to use (1) and annotate the `_file` manually.
|
||||
|
||||
Case closed :)
|
@ -2,7 +2,7 @@
|
||||
# Common configuration accross *all* the machines
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
_file = ./default.nix;
|
||||
|
||||
imports = [
|
||||
./flake.nix
|
||||
./mdmonitor-fix.nix
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
_file = ./default.nix;
|
||||
|
||||
imports = [
|
||||
../common
|
||||
./pipewire.nix
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ modulesPath, ... }:
|
||||
{
|
||||
_file = ./default.nix;
|
||||
|
||||
imports = [
|
||||
"${modulesPath}/virtualisation/amazon-image.nix"
|
||||
../../mixins/cloud-init.nix
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ config, modulesPath, lib, ... }:
|
||||
{
|
||||
_file = ./default.nix;
|
||||
|
||||
imports = [
|
||||
../../mixins/cloud-init.nix
|
||||
"${modulesPath}/profiles/qemu-guest.nix"
|
||||
|
@ -1,5 +1,5 @@
|
||||
{ lib, config, ... }: {
|
||||
_file = ./amd.nix;
|
||||
|
||||
imports = [ ./. ];
|
||||
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
|
@ -1,5 +1,5 @@
|
||||
{ lib, config, ... }: {
|
||||
_file = ./intel.nix;
|
||||
|
||||
imports = [ ./. ];
|
||||
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
_file = ./cloud-init.nix;
|
||||
|
||||
config = {
|
||||
services.cloud-init.enable = true;
|
||||
services.cloud-init.network.enable = true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
{ config, lib, ... }: {
|
||||
_file = ./nginx.nix;
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 443 80 ];
|
||||
|
||||
services.nginx = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Add this mixin to machines that boot with EFI
|
||||
{
|
||||
_file = ./systemd-boot.nix;
|
||||
|
||||
# Only enable during install
|
||||
#boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
|
@ -9,7 +9,7 @@ let
|
||||
hasNvme = lib.any (m: m == "nvme") config.boot.initrd.availableKernelModules;
|
||||
in
|
||||
{
|
||||
_file = ./telegraf.nix;
|
||||
|
||||
systemd.services.telegraf.path = lib.optional (!isVM && hasNvme) pkgs.nvme-cli;
|
||||
|
||||
services.telegraf = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ pkgs, lib, ... }:
|
||||
{
|
||||
_file = ./terminfo.nix;
|
||||
|
||||
# various terminfo packages
|
||||
environment.systemPackages = [
|
||||
pkgs.wezterm.terminfo # this one does not need compilation
|
||||
|
@ -3,7 +3,7 @@
|
||||
, lib
|
||||
, ...
|
||||
}: {
|
||||
_file = ./tracing.nix;
|
||||
|
||||
programs.bcc.enable = !pkgs.stdenv.hostPlatform.isRiscV;
|
||||
programs.sysdig.enable = !pkgs.stdenv.isAarch64 && !pkgs.stdenv.hostPlatform.isRiscV;
|
||||
|
||||
|
@ -3,7 +3,7 @@ let
|
||||
cfg = config.roles.github-actions-runner;
|
||||
in
|
||||
{
|
||||
_file = ./github-actions-runner.nix;
|
||||
|
||||
imports = [
|
||||
../modules/github-runners
|
||||
];
|
||||
|
@ -3,7 +3,7 @@ let
|
||||
cfg = config.roles.nix-remote-builder;
|
||||
in
|
||||
{
|
||||
_file = ./nix-remote-builder.nix;
|
||||
|
||||
|
||||
options.roles.nix-remote-builder = {
|
||||
schedulerPublicKeys = lib.mkOption {
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Common configuration accross *all* the machines
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
_file = ./default.nix;
|
||||
|
||||
imports = [
|
||||
../common
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user