initial nixos-config

This commit is contained in:
crurak 2023-08-01 05:06:16 +00:00
parent 0a7012b316
commit 6cc6a1f32c
17 changed files with 366 additions and 0 deletions

49
flake.lock generated Normal file
View File

@ -0,0 +1,49 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1685599623,
"narHash": "sha256-Tob4CMOVHue0D3RzguDBCtUmX5ji2PsdbQDbIOIKvsc=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "93db05480c0c0f30382d3e80779e8386dcb4f9dd",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-23.05",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1686431482,
"narHash": "sha256-oPVQ/0YP7yC2ztNsxvWLrV+f0NQ2QAwxbrZ+bgGydEM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d3bb401dcfc5a46ce51cdfb5762e70cc75d082d2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

36
flake.nix Normal file
View File

@ -0,0 +1,36 @@
{
description = "NixOS configuration";
inputs = { # All flake references
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; # Default stable nix packages
# Home manager
home-manager = { # User package management
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
inherit (self) outputs;
lib = nixpkgs.lib // home-manager.lib;
in
{
inherit lib;
nixosConfigurations = { # NixOS Configuration
"stefan@merkur" = lib.nixosSystem { # Flake "stefan@merkur" (Notebook)
specialArgs = { inherit inputs; }; # Pass flake inputs to our config
modules = [
./hosts/merkur/configuration.nix # Import configuration,nix
home-manager.nixosModules.home-manager { # Home-Manager configuration (non-NixOS)
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.stefan = import ./home/stefan-merkur/home.nix; # Import default.nix
}
];
};
};
};
}

16
home/modules/cli/bash.nix Normal file
View File

@ -0,0 +1,16 @@
{ config, lib, pkgs, ...}:
let
inherit (lib) mkIf;
hasNeovim = config.programs.neovim.enable;
in
{
programs.bash = {
enable = true;
shellAliases = {
ll = "ls -lisah --color=auto";
".." = "cd ..";
vim = mkIf hasNeovim "nvim";
vi = mkIf hasNeovim "nvim";
};
};
}

6
home/modules/cli/bat.nix Normal file
View File

@ -0,0 +1,6 @@
{
programs.bat = {
enable = true;
config.theme = "base16";
};
}

View File

@ -0,0 +1,8 @@
{
imports = [
./bash.nix
./git.nix
./bat.nix
];
}

8
home/modules/cli/git.nix Normal file
View File

@ -0,0 +1,8 @@
{
programs.git = {
enable = true;
userName = "crurak";
userEmail = "s.spangenberg@posteo.de";
ignores = [ ".direnv" "result"];
};
}

View File

@ -0,0 +1,3 @@
{
}

View File

@ -0,0 +1,3 @@
{
}

View File

@ -0,0 +1,4 @@
{ config, pkgs, ... }: {
hyprland.homeManagerModules.default
}

View File

@ -0,0 +1,8 @@
{
programs.librewolf = {
enable = true;
settings = {
};
};
}

View File

@ -0,0 +1,23 @@
{ config, pkgs, ...}:
{
home.sessionVariables.Editor = "nvim";
programs = {
neovim = {
enable = true;
extraConfig = ''
syntax enable
colorscheme gruvbox
set number relativenumber
highlight Comment cterm=italic gui=italic
hi Normal guibg=NONE ctermbg=NONE
'';
plugins = with pkgs.vimPlugins; [
vim-nix
gruvbox
];
};
};
}

View File

@ -0,0 +1,27 @@
{ inputs, lib, config, pkgs, outputs, ... }: {
imports = [
../modules/neovim
../modules/cli
];
nixpkgs = {
config = {
allowUnfree = true; # Allow unfree packages
allowUnfreePredicate = (_: true); # Workaround for https://github.com/nix-community/home-manager/issues/2942
};
};
home = {
username = "stefan";
homeDirectory = "/home/stefan";
stateVersion = "23.05"; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
};
programs = {
home-manager.enable = true; # Enable home-manager
};
systemd.user.startServices = "sd-switch"; # Reload system units when changing configs
}

13
hosts/common/stefan.nix Normal file
View File

@ -0,0 +1,13 @@
{
users.users = {
stefan = {
isNormalUser = true;
extraGroups = [ "wheel" ];
initialPassword = "password";
openssh.authorizedKeys.keys = [
# Add your SSH public key(s) here, if you plan on using SSH to connect
];
};
};
}

View File

@ -0,0 +1,93 @@
{ inputs, lib, config, pkgs, ... }: {
imports = [
./hardware-configuration.nix # Current system hardware config
../common/stefan.nix
# ../modules/gnome.nix
];
nixpkgs.config.allowUnfree = true; # Allow proprietary packages
nix = { # Nix package manager settings
registry = lib.mapAttrs (_: value: { flake = value; }) inputs; # Adds each flake input to make nix3 commands consistent to flake
# 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 = {
experimental-features = "nix-command flakes"; # Enable flake support
auto-optimise-store = true; # Duplicate and optimize nix store
};
gc = { # Automatic garbage collection
automatic = true;
dates = "weekly";
options = "--delete-older-than 2d";
};
};
boot = {
#kernelPackages = pkgs.linuxPackages_latest; # Latest stable kernel
loader = {
systemd-boot = {
enable = true;
configurationLimit = 5; # Limit the amount of configuration
};
efi.canTouchEfiVariables = true;
timeout = 1; # Grub autoselect time
};
};
networking = { # Network settings
hostName = "merkur";
networkmanager.enable = true;
};
security = {
rtkit.enable = true; # RealTimeKit ex. PulseAudio
polkit.enable = true;
};
i18n = { # internationalisation properties
defaultLocale = "de_DE.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8";
};
};
services = {
xserver = {
layout = "de"; # X11 keymap
xkbVariant = "";
};
pipewire = { # Sound
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
jack.enable = true;
};
};
environment = {
systemPackages = with pkgs; [
wget
tree
];
};
# Configure console keymap
console.keyMap = "de"; # Console keymap settings
system.stateVersion = "23.05"; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
}

View File

@ -0,0 +1,38 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/2ffd7af0-882b-4f88-9cf9-02d9abd555b4";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/7C6D-739B";
fsType = "vfat";
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -0,0 +1,14 @@
{ config, inputs, ... }:
let
inherit (config.networking) hostName; # Inherit variable
isClean = inputs.self ? rev; # Only enable if current config came from clean tree
in
{
system.autoUpgrade = { # NixOS auto upgrade
enable = isClean;
dates = "hourly";
flags = [
"--refresh"
];
};
}

17
hosts/modules/gnome.nix Normal file
View File

@ -0,0 +1,17 @@
{ pkgs, ... }:
{
services = {
xserver = {
enable = true;
desktopManager.gnome.enable = true;
displayManager.gdm.enable = true;
};
gnome.core-utilities.enable = false;
};
environment.systemPackages = with pkgs; [
gnomeExtensions.dash-to-dock
gnomeExtensions.gsconnect
];
}