This commit is contained in:
♥ Minnie ♥ 2023-05-14 22:44:45 +08:00
parent 3c22c2043a
commit c9b2ab3934

View file

@ -2,48 +2,90 @@
# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) # Use this to configure your system environment (it replaces /etc/nixos/configuration.nix)
{ inputs, outputs, lib, config, pkgs, ... }: { { inputs, outputs, lib, config, pkgs, ... }: {
imports = # You can import other NixOS modules here
[ # Include the results of the hardware scan. 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:
# Import your generated (nixos-generate-config) hardware configuration
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
nixpkgs = { nixpkgs = {
# You can add overlays here
overlays = [ overlays = [
# Add overlays your own flake exports (from overlays and pkgs dir):
outputs.overlays.additions outputs.overlays.additions
outputs.overlays.modifications outputs.overlays.modifications
outputs.overlays.unstable-packages 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 = { config = {
# Disable if you don't want unfree packages
allowUnfree = true; allowUnfree = true;
}; };
}; };
nix = { nix = {
autoOptimiseStore = true;
gc = { gc = {
#Automatically run the garbage collector at a specific time.
automatic = true; automatic = true;
dates = "weekly"; dates = "weekly";
options = "--delete-older-than 30d"; options = "--delete-older-than 30d";
}; };
# This will add each flake input as a registry
# To make nix commands consistent with your flake
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
# This will additionally add your inputs to the system's legacy channels
# Making legacy nix commands consistent as well, awesome!
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
settings = {
# Enable flakes and new 'nix' command
experimental-features = "nix-command flakes";
# Deduplicate and optimize nix store
auto-optimise-store = true;
};
# Free up to 1GiB whenever there is less than 100MiB left. # Free up to 1GiB whenever there is less than 100MiB left.
extraOptions = '' extraOptions = ''
min-free = ${toString (100 * 1024 * 1024)} min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (1024 * 1024 * 1024)} max-free = ${toString (1024 * 1024 * 1024)}
''; '';
};
registry = lib.mapAttrs (_: value: { flake = value; }) inputs; # Select internationalisation properties
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; i18n.defaultLocale = "en_AU.UTF-8";
settings = { # Set timezone
experimental-features = "nix-command flakes"; time.timeZone = "Australia/Perth";
auto-optimise-store = true;
};
};
boot = { boot = {
# Kernel to install
kernelPackages = pkgs.linuxPackages_rpi4; kernelPackages = pkgs.linuxPackages_rpi4;
tmpOnTmpfs = true;
tmp.useTmpfs = true;
initrd.availableKernelModules = [ "usbhid" "usb_storage" ]; initrd.availableKernelModules = [ "usbhid" "usb_storage" ];
# ttyAMA0 is the serial consolee broken out to the GPIO
# ttyAMA0 is the serial console broken out to the GPIO
kernelParams = [ kernelParams = [
"8250.nr_uarts=1" "8250.nr_uarts=1"
"console=ttyAMA0,115200" "console=ttyAMA0,115200"
@ -51,6 +93,13 @@
# A lot of GUI programs need this, nearly all wayland applications # A lot of GUI programs need this, nearly all wayland applications
"cma=128M" "cma=128M"
]; ];
loader = {
# Use the extlinux boot loader. (NixOS wants to enable GRUB by default)
grub.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf
generic-extlinux-compatible.enable = true;
};
}; };
# Required for the Wireless firmware # Required for the Wireless firmware
@ -63,37 +112,12 @@
}; };
}; };
# Install docker
virtualisation.docker = {
enable = true;
# Reduce container downtime due to daemon crashes
# Use the extlinux boot loader. (NixOS wants to enable GRUB by default) liveRestore = false;
boot.loader.grub.enable = false; };
# Enables the generation of /boot/extlinux/extlinux.conf
boot.loader.generic-extlinux-compatible.enable = true;
# networking.hostName = "nixos"; # Define your hostname.
# Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
# Set your time zone.
# time.timeZone = "Europe/Amsterdam";
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
# i18n.defaultLocale = "en_US.UTF-8";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# useXkbConfig = true; # use xkbOptions in tty.
# };
# Enable the X11 windowing system.
# services.xserver.enable = true;
@ -118,7 +142,7 @@
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.admin = { users.users.admin = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user. extraGroups = [ "docker" "wheel" ]; # Enable sudo for the user.
shell = pkgs.zsh; shell = pkgs.zsh;
openssh.authorizedKeys.keyFiles = [ ../fuchsia/id_ed25519_sk.pub ]; openssh.authorizedKeys.keyFiles = [ ../fuchsia/id_ed25519_sk.pub ];
}; };
@ -130,6 +154,7 @@
wget wget
git git
home-manager home-manager
docker-compose
]; ];
environment.pathsToLink = [ "/share/zsh" ]; environment.pathsToLink = [ "/share/zsh" ];
@ -148,8 +173,10 @@
# Enable the OpenSSH daemon. # Enable the OpenSSH daemon.
services.openssh = { services.openssh = {
enable = true; enable = true;
permitRootLogin = "no"; settings = {
passwordAuthentication = false; PermitRootLogin = "no";
PasswordAuthentication = false;
};
}; };
# Open ports in the firewall. # Open ports in the firewall.