Compare commits
2 commits
354f4e87a0
...
b8afaddc38
Author | SHA1 | Date | |
---|---|---|---|
Emi Simpson | b8afaddc38 | ||
Emi Simpson | 1533464084 |
119
modules/machine-info.nix
Normal file
119
modules/machine-info.nix
Normal file
|
@ -0,0 +1,119 @@
|
|||
{ config, pkgs, lib, ... }@nixpkgs: with lib; {
|
||||
options.environment.machineInfo = mkOption {
|
||||
description = lib.mdDoc ''
|
||||
Machine metadata, including stylized hostname, computer icon, etc.
|
||||
|
||||
This module controls the options written to `/etc/machine-info`. For more
|
||||
information, see [the freedesktop documentation][1].
|
||||
|
||||
[1]: https://www.freedesktop.org/software/systemd/man/machine-info.html
|
||||
'';
|
||||
default = {};
|
||||
type = types.submodule { options = {
|
||||
|
||||
prettyHostname = mkOption {
|
||||
description = lib.mdDoc ''
|
||||
A pretty, human-readable hostname for this machine, potentially including
|
||||
spaces, unicode, and emoji. If unset, this falls back to the network hostname
|
||||
set in `networking.hostName`.
|
||||
'';
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
defaultText = literalExpression "null";
|
||||
example = literalExpression "\"Jade's Laptop 💎\"";
|
||||
};
|
||||
|
||||
iconName = mkOption {
|
||||
description = lib.mdDoc ''
|
||||
An XDG icon which should be associated with this machine. Some common choices
|
||||
include: `"computer"`, `"phone"`, but a complete list of icons can be found in
|
||||
the [XDG Icon Naming Spec][1].
|
||||
|
||||
If left unset, applications will typically default to `"computer"`.
|
||||
|
||||
[1]: https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
|
||||
'';
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
defaultText = literalExpression "null";
|
||||
example = literalExpression "\"computer\"";
|
||||
};
|
||||
|
||||
chassis = mkOption {
|
||||
description = lib.mdDoc ''
|
||||
The type of chassis this machine resides within. This is typically detected
|
||||
automatically, but can be manually overridden here.
|
||||
'';
|
||||
type = with types; nullOr (enum [
|
||||
"desktop"
|
||||
"laptop"
|
||||
"convertible"
|
||||
"server"
|
||||
"tablet"
|
||||
"handset"
|
||||
"watch"
|
||||
"embedded"
|
||||
"vm"
|
||||
"container"
|
||||
]);
|
||||
default = null;
|
||||
defaultText = literalExpression "null";
|
||||
example = literalExpression "\"server\"";
|
||||
};
|
||||
|
||||
deployment = mkOption {
|
||||
description = lib.mdDoc ''
|
||||
If this machine is part of a deployment environment / pipeline, this option can
|
||||
be used to specify what environment/pipeline stage it manages.
|
||||
|
||||
Typically, but not necessarily, set to something like `"development"`,
|
||||
`"integration"`, `"staging"`, or `"production"`.
|
||||
'';
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
defaultText = literalExpression "null";
|
||||
example = literalExpression "\"production\"";
|
||||
};
|
||||
|
||||
location = mkOption {
|
||||
description = lib.mdDoc ''
|
||||
A human-readable short description of the location of this machine.
|
||||
|
||||
This can be set to whatever has the most meaning for you, for example "Living
|
||||
Room", "Left Rack, 2nd Shelf", or "Parishville, NY".
|
||||
'';
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
defaultText = literalExpression "null";
|
||||
example = literalExpression "\"Bedroom\"";
|
||||
};
|
||||
|
||||
extraOptions = mkOption {
|
||||
description = lib.mdDoc ''
|
||||
Extra variables to put in `/etc/machine-info`
|
||||
'';
|
||||
type = with types; attrsOf str;
|
||||
default = {};
|
||||
defaultText = literalExpression "{ }";
|
||||
example = literalExpression "{ HARDWARE_VENDOR = \"Intel Corp.\" }";
|
||||
};
|
||||
|
||||
};};
|
||||
};
|
||||
|
||||
config.environment.etc.machine-info =
|
||||
with config.environment.machineInfo;
|
||||
let
|
||||
rawShellVars = {
|
||||
PRETTY_HOSTNAME = prettyHostname;
|
||||
ICON_NAME = iconName;
|
||||
CHASSIS = chassis;
|
||||
DEPLOYMENT = deployment;
|
||||
LOCATION = location;
|
||||
} // extraOptions;
|
||||
nonNullShellVars = attrsets.filterAttrs (k: v: v != null) rawShellVars;
|
||||
in rec {
|
||||
text = strings.toShellVars nonNullShellVars;
|
||||
enable = builtins.stringLength text > 0;
|
||||
};
|
||||
}
|
|
@ -10,6 +10,7 @@ let systemInformation = import ./system/system-information.nix; in
|
|||
[
|
||||
./configs/filesystems.nix
|
||||
./system/hardware-requirements.nix
|
||||
./modules/machine-info.nix
|
||||
<home-manager/nixos>
|
||||
];
|
||||
|
||||
|
@ -166,9 +167,7 @@ let systemInformation = import ./system/system-information.nix; in
|
|||
};
|
||||
};
|
||||
|
||||
environment.etc.machine-info.text = lib.strings.toShellVars {
|
||||
PRETTY_HOSTNAME = systemInformation.prettyHostname;
|
||||
};
|
||||
environment.machineInfo.prettyHostname = systemInformation.prettyHostname;
|
||||
|
||||
# Enable the OpenSSH daemon.
|
||||
# services.openssh.enable = true;
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
'';
|
||||
|
||||
meta = {
|
||||
description = "Open-access fonts for activists, organizers, and movement designers";
|
||||
description = "Open-access fonts for activists, organizers, and movement designers";
|
||||
homepage = "https://justseeds.org/project/justseeds-open-type-project/";
|
||||
license = lib.licenses.cc-by-nc-40;
|
||||
maintainers = [{
|
||||
|
|
Loading…
Reference in a new issue