diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..177441e --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c4a4da8 --- /dev/null +++ b/flake.nix @@ -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 + } + ]; + }; + }; + }; +} diff --git a/home/modules/cli/bash.nix b/home/modules/cli/bash.nix new file mode 100644 index 0000000..5184520 --- /dev/null +++ b/home/modules/cli/bash.nix @@ -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"; + }; + }; +} diff --git a/home/modules/cli/bat.nix b/home/modules/cli/bat.nix new file mode 100644 index 0000000..145895e --- /dev/null +++ b/home/modules/cli/bat.nix @@ -0,0 +1,6 @@ +{ + programs.bat = { + enable = true; + config.theme = "base16"; + }; +} diff --git a/home/modules/cli/default.nix b/home/modules/cli/default.nix new file mode 100644 index 0000000..1563253 --- /dev/null +++ b/home/modules/cli/default.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ./bash.nix + ./git.nix + ./bat.nix + ]; +} + diff --git a/home/modules/cli/git.nix b/home/modules/cli/git.nix new file mode 100644 index 0000000..bafb849 --- /dev/null +++ b/home/modules/cli/git.nix @@ -0,0 +1,8 @@ +{ + programs.git = { + enable = true; + userName = "crurak"; + userEmail = "s.spangenberg@posteo.de"; + ignores = [ ".direnv" "result"]; + }; +} diff --git a/home/modules/desktop/common/default.nix b/home/modules/desktop/common/default.nix new file mode 100644 index 0000000..0db3279 --- /dev/null +++ b/home/modules/desktop/common/default.nix @@ -0,0 +1,3 @@ +{ + +} diff --git a/home/modules/desktop/default.nix b/home/modules/desktop/default.nix new file mode 100644 index 0000000..0db3279 --- /dev/null +++ b/home/modules/desktop/default.nix @@ -0,0 +1,3 @@ +{ + +} diff --git a/home/modules/hyprland/default.nix b/home/modules/hyprland/default.nix new file mode 100644 index 0000000..f5690f2 --- /dev/null +++ b/home/modules/hyprland/default.nix @@ -0,0 +1,4 @@ +{ config, pkgs, ... }: { + hyprland.homeManagerModules.default + +} diff --git a/home/modules/librewolf.nix b/home/modules/librewolf.nix new file mode 100644 index 0000000..71269a2 --- /dev/null +++ b/home/modules/librewolf.nix @@ -0,0 +1,8 @@ +{ + programs.librewolf = { + enable = true; + settings = { + + }; + }; +} diff --git a/home/modules/neovim/default.nix b/home/modules/neovim/default.nix new file mode 100644 index 0000000..b4949eb --- /dev/null +++ b/home/modules/neovim/default.nix @@ -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 + ]; + }; + }; +} diff --git a/home/stefan-merkur/home.nix b/home/stefan-merkur/home.nix new file mode 100644 index 0000000..11190c3 --- /dev/null +++ b/home/stefan-merkur/home.nix @@ -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 +} diff --git a/hosts/common/stefan.nix b/hosts/common/stefan.nix new file mode 100644 index 0000000..22a96af --- /dev/null +++ b/hosts/common/stefan.nix @@ -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 + ]; + }; + }; + +} diff --git a/hosts/merkur/configuration.nix b/hosts/merkur/configuration.nix new file mode 100644 index 0000000..50e9dd4 --- /dev/null +++ b/hosts/merkur/configuration.nix @@ -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 +} diff --git a/hosts/merkur/hardware-configuration.nix b/hosts/merkur/hardware-configuration.nix new file mode 100644 index 0000000..701c8ed --- /dev/null +++ b/hosts/merkur/hardware-configuration.nix @@ -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..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; +} diff --git a/hosts/modules/auto-upgrade.nix b/hosts/modules/auto-upgrade.nix new file mode 100644 index 0000000..c886275 --- /dev/null +++ b/hosts/modules/auto-upgrade.nix @@ -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" + ]; + }; +} diff --git a/hosts/modules/gnome.nix b/hosts/modules/gnome.nix new file mode 100644 index 0000000..c9a42a0 --- /dev/null +++ b/hosts/modules/gnome.nix @@ -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 + ]; +}