traverseda-nixos-config/nixos/configuration.nix

107 lines
3.3 KiB
Nix
Raw Normal View History

2024-04-23 07:59:37 -03:00
# This is your system's configuration file.
# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix)
aider: Fix nixos/configuration.nix to accept `hostname` as an argument. # Aider chat conversation: USER: I ran this command: nixos-rebuild build-vm --flake ./#athame And got this output: building the system configuration... warning: Git tree '/home/traverseda/Code/nixos-config' is dirty error: … while calling the 'derivationStrict' builtin at /builtin/derivation.nix:9:12: (source not available) … while evaluating derivation 'nixos-vm' whose name attribute is located at /nix/store/0yzh1r9mhsr4vp5w96y3i0jgz3m2qzv6-source/pkgs/stdenv/generic/make-derivation.nix:303:7 … while evaluating attribute 'buildCommand' of derivation 'nixos-vm' at /nix/store/0yzh1r9mhsr4vp5w96y3i0jgz3m2qzv6-source/pkgs/build-support/trivial-builders/default.nix:87:14: 86| enableParallelBuilding = true; 87| inherit buildCommand name; | ^ 88| passAsFile = [ "buildCommand" ] (stack trace truncated; use '--show-trace' to show the full trace) error: attribute 'hostname' missing at /nix/store/ds44l4g1yz0dd3ssqhlpv4r6wwh8p6r0-source/nixos/configuration.nix:77:25: 76| # TODO: Set your hostname 77| networking.hostName = inputs.hostname; | ^ 78| ASSISTANT: The error message indicates that the attribute 'hostname' is missing. This is likely because the `inputs` in `nixos/configuration.nix` does not contain a `hostname` attribute. The `hostname` attribute is defined in `flake.nix` under `nixosConfigurations` for each system (like `athame` and `metatron`). However, this `hostname` attribute is not being passed to `nixos/configuration.nix`. To fix this, we need to modify `nixos/configuration.nix` to accept `hostname` as an argument. Here is the *SEARCH/REPLACE* block: nixos/configuration.nix ```nix <<<<<<< SEARCH { inputs, outputs, lib, config, pkgs, ... }: { ======= { inputs, outputs, lib, config, pkgs, hostname, ... }: { >>>>>>> REPLACE ``` This change will allow `nixos/configuration.nix` to accept `hostname` as an argument. Now, when you run the command `nixos-rebuild build-vm --flake ./#athame`, the `hostname` attribute from `flake.nix` will be passed to `nixos/configuration.nix`, and the error should be resolved.
2024-04-24 09:55:10 -03:00
{ inputs, outputs, lib, config, pkgs, hostname, ... }: {
2024-04-23 07:59:37 -03:00
# You can import other NixOS modules here
imports = [
# If you want to use modules your own flake exports (from modules/nixos):
# outputs.nixosModules.example
# Or modules from other flakes (such as nixos-hardware):
# inputs.hardware.nixosModules.common-cpu-amd
# inputs.hardware.nixosModules.common-ssd
# You can also split up your configuration and import pieces of it here:
# ./users.nix
# Import your generated (nixos-generate-config) hardware configuration
./hardware-configuration.nix
];
nixpkgs = {
# You can add overlays here
overlays = [
# Add overlays your own flake exports (from overlays and pkgs dir):
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.unstable-packages
# You can also add overlays exported from other flakes:
# neovim-nightly-overlay.overlays.default
# Or define it inline, for example:
# (final: prev: {
# hi = final.hello.overrideAttrs (oldAttrs: {
# patches = [ ./change-hello-to-hi.patch ];
# });
# })
];
# Configure your nixpkgs instance
config = {
# Disable if you don't want unfree packages
allowUnfree = true;
};
};
# This will add each flake input as a registry
# To make nix3 commands consistent with your flake
nix.registry = (lib.mapAttrs (_: flake: {inherit flake;})) ((lib.filterAttrs (_: lib.isType "flake")) inputs);
# This will additionally add your inputs to the system's legacy channels
# Making legacy nix commands consistent as well, awesome!
nix.nixPath = ["/etc/nix/path"];
environment.etc =
lib.mapAttrs'
(name: value: {
name = "nix/path/${name}";
value.source = value.flake;
})
config.nix.registry;
nix.settings = {
# Enable flakes and new 'nix' command
experimental-features = "nix-command flakes";
# Deduplicate and optimize nix store
auto-optimise-store = true;
};
2024-04-25 12:28:13 -03:00
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
2024-04-25 12:28:13 -03:00
virtualisation.docker.enable = true;
2024-04-23 07:59:37 -03:00
2024-04-25 12:28:13 -03:00
#Puts fonts in /run/current-system/sw/share/X11/fonts
fonts.fontDir.enable = true;
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
2024-04-23 07:59:37 -03:00
users.users = {
2024-04-25 12:28:13 -03:00
traverseda = {
# You can set an initial password for your user.
# If you do, you can skip setting a root password by passing '--no-root-passwd' to nixos-install.
# Be sure to change it (using passwd) after rebooting!
2024-04-25 12:28:13 -03:00
initialPassword = "changeme";
2024-04-23 07:59:37 -03:00
isNormalUser = true;
openssh.authorizedKeys.keys = [
];
extraGroups = ["wheel"];
2024-04-23 07:59:37 -03:00
};
};
# This setups a SSH server. Very important if you're setting up a headless system.
# Feel free to remove if you don't need it.
services.openssh = {
enable = true;
settings = {
# Forbid root login through SSH.
PermitRootLogin = "no";
# Use keys only. Remove if you want to SSH using password (not recommended)
2024-04-25 12:28:13 -03:00
PasswordAuthentication = true;
2024-04-23 07:59:37 -03:00
};
};
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
system.stateVersion = "23.05";
}