remove default for clan.core.settings.machine.name and make readOnly

There is not reason that there needs to be a default. Machines are usually defined as an attrset, so there is no reason to have a default.
Also make this readOnly as we never want to override it.
This commit is contained in:
DavHau
2025-04-02 18:21:05 +07:00
parent 51d39a4c8c
commit 73d14e078e
4 changed files with 40 additions and 27 deletions

View File

@@ -9,29 +9,38 @@ in
{ {
hostPkgs = pkgs; hostPkgs = pkgs;
# speed-up evaluation # speed-up evaluation
defaults = { defaults =
imports = [ { config, options, ... }:
./minify.nix {
]; imports = [
documentation.enable = lib.mkDefault false; ./minify.nix
boot.isContainer = true; ];
config = lib.mkMerge [
(lib.optionalAttrs (options ? clan) {
clan.core.settings.machine.name = config.networking.hostName;
})
{
documentation.enable = lib.mkDefault false;
boot.isContainer = true;
# needed since nixpkgs 7fb2f407c01b017737eafc26b065d7f56434a992 removed the getty unit by default # needed since nixpkgs 7fb2f407c01b017737eafc26b065d7f56434a992 removed the getty unit by default
console.enable = true; console.enable = true;
# undo qemu stuff # undo qemu stuff
system.build.initialRamdisk = ""; system.build.initialRamdisk = "";
virtualisation.sharedDirectories = lib.mkForce { }; virtualisation.sharedDirectories = lib.mkForce { };
networking.useDHCP = false; networking.useDHCP = false;
# we have not private networking so far # we have not private networking so far
networking.interfaces = lib.mkForce { }; networking.interfaces = lib.mkForce { };
#networking.primaryIPAddress = lib.mkForce null; #networking.primaryIPAddress = lib.mkForce null;
systemd.services.backdoor.enable = false; systemd.services.backdoor.enable = false;
# we don't have permission to set cpu scheduler in our container # we don't have permission to set cpu scheduler in our container
systemd.services.nix-daemon.serviceConfig.CPUSchedulingPolicy = lib.mkForce ""; systemd.services.nix-daemon.serviceConfig.CPUSchedulingPolicy = lib.mkForce "";
}; }
];
};
# to accept external dependencies such as disko # to accept external dependencies such as disko
node.specialArgs.self = self; node.specialArgs.self = self;
_module.args = { inherit self; }; _module.args = { inherit self; };

View File

@@ -8,14 +8,21 @@ in
hostPkgs = pkgs; hostPkgs = pkgs;
# speed-up evaluation # speed-up evaluation
defaults = ( defaults = (
{ config, ... }: { config, options, ... }:
{ {
imports = [ imports = [
./minify.nix ./minify.nix
]; ];
documentation.enable = lib.mkDefault false; config = lib.mkMerge [
nix.settings.min-free = 0; (lib.optionalAttrs (options ? clan) {
system.stateVersion = config.system.nixos.release; clan.core.settings.machine.name = config.networking.hostName;
})
{
documentation.enable = lib.mkDefault false;
nix.settings.min-free = 0;
system.stateVersion = config.system.nixos.release;
}
];
} }
); );

View File

@@ -94,9 +94,6 @@ let
# Inherited from clan wide settings # Inherited from clan wide settings
# TODO: remove these # TODO: remove these
# Machine specific settings
# clan.core.settings.machine.name = name;
networking.hostName = lib.mkDefault name; networking.hostName = lib.mkDefault name;
# For vars we need to override the system so we run vars # For vars we need to override the system so we run vars

View File

@@ -117,7 +117,7 @@ in
options = { options = {
name = mkOption { name = mkOption {
type = types.str; type = types.str;
default = "nixos"; readOnly = true;
description = '' description = ''
the name of the machine the name of the machine
''; '';