Merge pull request 'Flake: nixos-facter-module with flake: false' (#1986) from hsjobeki/clan-core:hsjobeki-main into main

This commit is contained in:
clan-bot
2024-09-02 12:36:35 +00:00
8 changed files with 107 additions and 29 deletions

View File

@@ -6,6 +6,7 @@
./flash/flake-module.nix ./flash/flake-module.nix
./impure/flake-module.nix ./impure/flake-module.nix
./installation/flake-module.nix ./installation/flake-module.nix
./nixos-documentation/flake-module.nix
]; ];
perSystem = perSystem =
{ {

View File

@@ -0,0 +1,26 @@
{ self, ... }:
let
documentationModule = {
# This is how some downstream users currently generate documentation
# If this breaks notify them via matrix since we spent ~5 hrs for bughunting last time.
documentation.nixos.enable = true;
documentation.nixos.extraModules = [
self.nixosModules.clanCore
# This is the only option that is not part of the
# module because it is usually set by flake-parts
{ clan.core.clanDir = ./.; }
];
};
in
{
clan = {
machines.test-documentation = {
# Dummy file system
fileSystems."/".device = "/dev/null";
boot.loader.grub.device = "/dev/null";
imports = [
documentationModule
];
};
};
}

17
flake.lock generated
View File

@@ -40,6 +40,22 @@
"type": "github" "type": "github"
} }
}, },
"nixos-facter-modules": {
"flake": false,
"locked": {
"lastModified": 1724681057,
"narHash": "sha256-wxx2Sh/urE3sKY/1v3tmrWTNMIQ3RoJtd7bcuqVpY2Y=",
"owner": "numtide",
"repo": "nixos-facter-modules",
"rev": "55088bf19810d23ca7cb86fb71516c95d97f035b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "nixos-facter-modules",
"type": "github"
}
},
"nixos-images": { "nixos-images": {
"inputs": { "inputs": {
"nixos-stable": [], "nixos-stable": [],
@@ -81,6 +97,7 @@
"inputs": { "inputs": {
"disko": "disko", "disko": "disko",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nixos-facter-modules": "nixos-facter-modules",
"nixos-images": "nixos-images", "nixos-images": "nixos-images",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",

View File

@@ -18,16 +18,11 @@
treefmt-nix.url = "github:numtide/treefmt-nix"; treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
#nixos-facter-modules.url = "github:numtide/nixos-facter-modules"; nixos-facter-modules.url = "github:numtide/nixos-facter-modules";
#nixos-facter-modules.inputs.nixpkgs.follows = "nixpkgs"; # TODO: remove this once the upstream doesnt have dependencies
#nixos-facter-modules.inputs.systems.follows = "systems"; nixos-facter-modules.flake = false;
#nixos-facter-modules.inputs.blueprint.follows = "blueprint"; # nixos-facter-modules.inputs.nixpkgs.follows = "nixpkgs";
#nixos-facter-modules.inputs.treefmt-nix.follows = "treefmt-nix";
# Pinned input for nixos-facter-modules
# Allows downstream flakes to .follow override the input
#blueprint.url = "github:numtide/blueprint";
#blueprint.inputs.nixpkgs.follows = "nixpkgs";
#blueprint.inputs.systems.follows = "systems";
}; };
outputs = outputs =

View File

@@ -67,13 +67,13 @@ let
facterJson = "${directory}/machines/${name}/facter.json"; facterJson = "${directory}/machines/${name}/facter.json";
hwConfig = "${directory}/machines/${name}/hardware-configuration.nix"; hwConfig = "${directory}/machines/${name}/hardware-configuration.nix";
facterModules = lib.optionals (builtins.pathExists facterJson) [
"${clan-core.inputs.nixos-facter-modules}/modules/nixos/facter.nix"
{ config.facter.reportPath = facterJson; }
];
in in
#facterModules = lib.optionals (builtins.pathExists facterJson) [
# clan-core.inputs.nixos-facter-modules.nixosModules.facter
# { config.facter.reportPath = facterJson; }
#];
(machineImports settings) (machineImports settings)
#++ facterModules ++ facterModules
++ [ ++ [
{ {
# Autoinclude configuration.nix and hardware-configuration.nix # Autoinclude configuration.nix and hardware-configuration.nix

View File

@@ -14,22 +14,49 @@ let
# }; # };
# } # }
instanceOptions = lib.types.submodule { instanceOptions = lib.types.submodule {
options.roles = lib.mkOption { type = lib.types.attrsOf machinesList; }; options.roles = lib.mkOption {
description = ''
Configuration for a service instance.
Specific roles describe the membership of foreign machines.
```nix
{ # Configuration for an instance
roles.<roleName>.machines = [ # List of machines ];
}
```
'';
type = lib.types.attrsOf machinesList;
};
}; };
# {
# machines = [
# "camina_machine"
# "vi_machine"
# "vyr_machine"
# ];
# }
machinesList = lib.types.submodule { machinesList = lib.types.submodule {
options.machines = lib.mkOption { type = lib.types.listOf lib.types.str; }; options.machines = lib.mkOption {
description = ''
List of machines that are part of a role.
```nix
{ # Configuration for an instance
roles.<roleName>.machines = [ # List of machines ];
}
```
'';
type = lib.types.listOf lib.types.str;
};
}; };
in in
{ {
options.clan.inventory.services = lib.mkOption { options.clan.inventory.services = lib.mkOption {
description = ''
Configuration for each inventory service.
Each service can have multiple instances as follows:
```
{serviceName}.{instancename} = { # Configuration for an instance }
```
'';
type = lib.types.attrsOf (lib.types.attrsOf instanceOptions); type = lib.types.attrsOf (lib.types.attrsOf instanceOptions);
}; };
} }

View File

@@ -3,7 +3,16 @@ let
optStr = lib.types.nullOr lib.types.str; optStr = lib.types.nullOr lib.types.str;
in in
{ {
options.clan.meta.name = lib.mkOption { type = lib.types.str; }; options.clan.meta.name = lib.mkOption {
options.clan.meta.description = lib.mkOption { type = optStr; }; description = "The name of the clan";
options.clan.meta.icon = lib.mkOption { type = optStr; }; type = lib.types.str;
};
options.clan.meta.description = lib.mkOption {
description = "The description of the clan";
type = optStr;
};
options.clan.meta.icon = lib.mkOption {
description = "The location of the clan icon";
type = optStr;
};
} }

View File

@@ -45,8 +45,11 @@
}; };
clanDir = lib.mkOption { clanDir = lib.mkOption {
type = lib.types.path; type = lib.types.path;
# TODO: @DavHau: before we can remove this, we need to make sure that Palo's config case works # documentation.nixos.extraModules = [
default = ./.; # ...
# clan-core.nixosModules.clanCore
# { clan.core.clanDir = ./path/to/flake; }
# ];
description = '' description = ''
the location of the flake repo, used to calculate the location of facts and secrets the location of the flake repo, used to calculate the location of facts and secrets
''; '';