From 5e9a68a9d597eccacb3a89cdb0c14aad267c52da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czy=C5=BC?= Date: Tue, 16 Apr 2024 21:37:22 +0200 Subject: [PATCH] revamped nix for scalability --- README.md | 39 ++- flake.nix | 126 +++++---- home.nix => home-manager/home.nix | 248 ++++++++++-------- p10k.zsh => home-manager/p10k.zsh | 0 hosts/thor/configuration.nix | 222 ++++++++++++++++ .../thor}/hardware-configuration.nix | 0 {zion => hosts/zion}/configuration.nix | 175 +++++++----- .../zion}/hardware-configuration.nix | 0 modules/home-manager/default.nix | 6 + modules/nixos/default.nix | 6 + overlays/default.nix | 23 ++ pkgs/default.nix | 5 + thor/configuration.nix | 162 ------------ 13 files changed, 635 insertions(+), 377 deletions(-) rename home.nix => home-manager/home.nix (55%) rename p10k.zsh => home-manager/p10k.zsh (100%) create mode 100644 hosts/thor/configuration.nix rename {thor => hosts/thor}/hardware-configuration.nix (100%) rename {zion => hosts/zion}/configuration.nix (54%) rename {zion => hosts/zion}/hardware-configuration.nix (100%) create mode 100644 modules/home-manager/default.nix create mode 100644 modules/nixos/default.nix create mode 100644 overlays/default.nix create mode 100644 pkgs/default.nix delete mode 100644 thor/configuration.nix diff --git a/README.md b/README.md index 0a49039..e1f7691 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,41 @@ # NixOS Configuration Here is my global NixOS configuration -It is still heavly work in progress as I learn how this OS works + +## Install + +Check if Nix version is >= 2.4 + +```bash +nix --version +``` + +Allow experimental `flakes` + +```bash +export NIX_CONFIG="experimental-features = nix-command flakes" +``` + +Clone this repo + +```bash +git clone https://github.com/eRgo35/nixos ~/.dots +``` + +```bash +cd ~/.dots +``` + +## Usage + +Apply system configuration + +```bash +sudo nixos-rebuild switch --flake .#hostname +``` + +Apply user configuration + +```bash +home-manager switch --flake .#mike@zion +``` diff --git a/flake.nix b/flake.nix index 60a199c..31367c4 100644 --- a/flake.nix +++ b/flake.nix @@ -2,66 +2,98 @@ description = "Mike's Flake"; inputs = { + # Nixpkgs nixpkgs.url = "nixpkgs/nixos-23.11"; + # You can access packages and modules from different nixpkgs revs + # at the same time. Here's an working example: nixpkgs-unstable.url = "nixpkgs/nixos-unstable"; - + # Also see the 'unstable-packages' overlay at 'overlays/default.nix'. + + # Home manager home-manager.url = "github:nix-community/home-manager/release-23.11"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + # TODO: Add any other flake you might need + # hardware.url = "github:nixos/nixos-hardware"; + + # Shameless plug: looking for a way to nixify your themes and make + # everything match nicely? Try nix-colors! + # nix-colors.url = "github:misterio77/nix-colors"; }; - outputs = inputs@{ self, nixpkgs, nixpkgs-unstable, home-manager, ...}: - let - lib = nixpkgs.lib; - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - pkgs-unstable = nixpkgs-unstable.legacyPackages.${system}; + outputs = { + self, + nixpkgs, + nixpkgs-unstable, + home-manager, + ... + } @ inputs: let + inherit (self) outputs; + # Supported systems for your flake packages, shell, etc. + system = [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + # This is a function that generates an attribute by calling a function you + # pass to it, with each system as an argument + forAllSystems = nixpkgs.lib.genAttrs systems; in { + # Your custom packages + # Accessible through 'nix build', 'nix shell', etc + packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); + # Formatter for your nix files, available through 'nix fmt' + # Other options beside 'alejandra' include 'nixpkgs-fmt' + formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); + + # Your custom packages and modifications, exported as overlays + overlays = import ./overlays {inherit inputs;}; + # Reusable nixos modules you might want to export + # These are usually stuff you would upstream into nixpkgs + nixosModules = import ./modules/nixos; + # Reusable home-manager modules you might want to export + # These are usually stuff you would upstream into home-manager + homeManagerModules = import ./modules/home-manager; + + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#hostname' nixosConfigurations = { - zion = lib.nixosSystem { - inherit system; + zion = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs;}; modules = [ - zion/configuration.nix - - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - - users.mike = import ./home.nix; - - extraSpecialArgs = { - inherit pkgs-unstable; - }; - }; - } + # > Main NixOS configuration file < + ./hosts/zion/configuration.nix ]; - specialArgs = { - inherit pkgs-unstable; - }; }; - thor = lib.nixosSystem { - inherit system; + thor = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs;}; modules = [ - thor/configuration.nix - - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - - users.mike = import ./home.nix; - - extraSpecialArgs = { - inherit pkgs-unstable; - }; - }; - } + # > Main NixOS configuration file < + ./hosts/thor/configuration.nix + ]; + }; + }; + + # Standalone home-manager configuration entrypoint + # Available through 'home-manager --flake .#username@hostname' + homeConfigurations = { + "mike@zion" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; # home-manager requires 'pkgs' instance + extraSpecialArgs = {inherit inputs outputs;}; + modules = [ + # > Main home-manager configuration file < + ./home-manager/home.nix + ]; + }; + "mike@thor" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; # home-manager requires 'pkgs' instance + extraSpecialArgs = {inherit inputs outputs;}; + modules = [ + # > Main home-manager configuration file < + ./home-manager/home.nix ]; - specialArgs = { - inherit pkgs-unstable; - }; }; }; }; diff --git a/home.nix b/home-manager/home.nix similarity index 55% rename from home.nix rename to home-manager/home.nix index 446f5b4..7867e13 100644 --- a/home.nix +++ b/home-manager/home.nix @@ -1,5 +1,13 @@ -{ config, pkgs, pkgs-unstable, ... }: -let +# This is your home-manager configuration file +# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: let myAliases = { ".." = "cd .."; "cd.." = "cd .."; @@ -39,122 +47,135 @@ let gua = "git remote | xargs -L1 git push --all"; }; in { - # Home Manager needs a bit of information about you and the paths it should - # manage. - home.username = "mike"; - home.homeDirectory = "/home/mike"; + # You can import other home-manager modules here + imports = [ + # If you want to use modules your own flake exports (from modules/home-manager): + # outputs.homeManagerModules.example - # This value determines the Home Manager release that your configuration is - # compatible with. This helps avoid breakage when a new Home Manager release - # introduces backwards incompatible changes. - # - # You should not change this value, even if you update Home Manager. If you do - # want to update the value, then make sure to first check the Home Manager - # release notes. - home.stateVersion = "23.11"; # Please read the comment before changing. + # Or modules exported from other flakes (such as nix-colors): + # inputs.nix-colors.homeManagerModules.default - # imports = [ - # ./apps/neovim.nix - # ]; + # You can also split up your configuration and import pieces of it here: + # ./nvim.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; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = _: true; + }; + }; + + # Username to manage + home = { + username = "mike"; + homeDirectory = "/home/mike"; + file = { + # Building this configuration will create a copy of 'dotfiles/screenrc' in + # the Nix store. Activating the configuration will then make '~/.screenrc' a + # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + }; # The home.packages option allows you to install Nix packages into your # environment. - home.packages = - (with pkgs; [ - # zsh stuff - zsh - zsh-autosuggestions - zsh-powerlevel10k + home.packages = (with pkgs; [ + # > zsh stuff < + zsh + zsh-autosuggestions + zsh-powerlevel10k - # graphics - tuxpaint - krita + # > graphics < + tuxpaint + krita - # terminal - kitty - kitty-themes + # > terminal < + kitty + kitty-themes - # tools - rofi - git - wget - eza - yt-dlp - ffmpeg - # texliveFull - texlive.combined.scheme-full - pgf-umlcd - pgf-umlsd - zoxide - neofetch - pavucontrol - htop - woeusb - steam-run - unzip - gnome.gnome-keyring - gnome.adwaita-icon-theme + # > tools < + rofi + git + wget + eza + yt-dlp + ffmpeg + # texliveFull + texlive.combined.scheme-full + pgf-umlcd + pgf-umlsd + zoxide + neofetch + pavucontrol + htop + woeusb + steam-run + unzip + gnome.gnome-keyring + gnome.adwaita-icon-theme - # media - spotify - vlc - mpv - obs-studio + # > media < + spotify + vlc + mpv + obs-studio - # desktop - firefox - discord - telegram-desktop - libreoffice-fresh - # vscodium - vscode - neovide - lunarvim - evolution - rstudio - - # gaming - prismlauncher - classicube - steam - - # development - clang - clang-tools - cargo - bash - nodejs - python3 - cmake - gtest - boost - - # custom - (callPackage ./pkgs/tikz-uml/tikzuml.nix {}) - ]) - - ++ - - (with pkgs-unstable; [ - # I need fresssh stuff - # neovim - ]); - - # Home Manager is pretty good at managing dotfiles. The primary way to manage - # plain files is through 'home.file'. - home.file = { - # # Building this configuration will create a copy of 'dotfiles/screenrc' in - # # the Nix store. Activating the configuration will then make '~/.screenrc' a - # # symlink to the Nix store copy. - # ".screenrc".source = dotfiles/screenrc; - - # # You can also set the file content immediately. - # ".gradle/gradle.properties".text = '' - # org.gradle.console=verbose - # org.gradle.daemon.idletimeout=3600000 - # ''; - }; + # > desktop < + firefox + discord + telegram-desktop + libreoffice-fresh + # vscodium + vscode + neovide + lunarvim + evolution + rstudio + # > gaming < + prismlauncher + classicube + steam + + # > development < + clang + clang-tools + cargo + bash + nodejs + python3 + cmake + gtest + boost + ]); + services.gnome-keyring.enable = true; home.sessionVariables = { @@ -254,4 +275,17 @@ in { # Let Home Manager install and manage itself. programs.home-manager.enable = true; + programs.git.enable = true; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "23.11"; # Please read the comment before changing. } diff --git a/p10k.zsh b/home-manager/p10k.zsh similarity index 100% rename from p10k.zsh rename to home-manager/p10k.zsh diff --git a/hosts/thor/configuration.nix b/hosts/thor/configuration.nix new file mode 100644 index 0000000..4612f84 --- /dev/null +++ b/hosts/thor/configuration.nix @@ -0,0 +1,222 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { + # 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 = { + # I'm sorry Richard Stallman + 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; + # Use cache servers for packages + substituters = [ + "https://nix-community.cachix.org" + "https://cache.nixos.org/" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + + # Hostname + networking.hostName = "thor"; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Enables wireless support via wpa_supplicant + # networking.wireless.enable = true; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone + time.timeZone = "Europe/Warsaw"; + + # Select internationalisation properties + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "pl_PL.UTF-8"; + LC_IDENTIFICATION = "pl_PL.UTF-8"; + LC_MEASUREMENT = "pl_PL.UTF-8"; + LC_MONETARY = "pl_PL.UTF-8"; + LC_NAME = "pl_PL.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "pl_PL.UTF-8"; + LC_TELEPHONE = "pl_PL.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + + # X Server settings + services.xserver = { + enable = true; + layout = "pl"; + xkbVariant = ""; + + displayManager = { + lightdm = { + enable = true; + }; + }; + + desktopManager = { + xfce = { + enable = true; + }; + }; + }; + + # I use zsh btw + environment.shells = with pkgs; [ bash zsh ]; + users.defaultUserShell = pkgs.zsh; + programs.zsh.enable = true; + + # Configure console keymap + console.keyMap = "pl2"; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users = { + mike = { + isNormalUser = true; + description = "Mike"; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDfqPj+a2gmoUl3TuGSZxf0zRBabVWvXRrjLF7sFlqjMbfkx428F3L7C8OC3Z9XDT4ysbpgWcPuVKNtK5kkKGjSLHAgB2CgvD15K11Q+ag1+uyePaiOypZYJewvv1hhqU5IrVcxUbTsbREH/IsdQSlNSuyNFIr3oFnrff5iKEKEwEvSDeiqpqRh56pAkF6Kb15aYqZO7X9rbfoa8Sgj3VJXN0181lXMjXkNsYVa3gDmKv89C6qutg+KOpHlXgn4AfIRcCw8ik6OGBEfi/gUeb3SYpD+7undNLyloxCbGwHQ40IdoqPatyhTNS4jm9kb+Tno4hj0pbLHZSUdXgGaSfGx1W0MVVY0mm0Hu7EmYDBHUTfmPmPxnolWh8UH+XdkNPnwZfyZlyBcVVkVzog1ZCs1i9Y6oS1ZIbzuz+WxBPPDIHMRdmxv6+PMc5kZyrpuX1PgFb7Xt5cRNAL5/wywoi9Z45SS7qP9zNSb443UaaXzUatqnlawZ0GS0qXJh3ljwJ8= mike@odin" + ]; + extraGroups = [ "networkmanager" "wheel" ]; + }; + }; + + environment.systemPackages = (with pkgs; [ + # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + # wget + ntfs3g + dosfstools + ]); + + fonts.packages = with pkgs; [ nerdfonts ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + programs.mtr.enable = true; + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + + # 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) + PasswordAuthentication = true; + }; + }; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.11"; # Did you read the comment? +} diff --git a/thor/hardware-configuration.nix b/hosts/thor/hardware-configuration.nix similarity index 100% rename from thor/hardware-configuration.nix rename to hosts/thor/hardware-configuration.nix diff --git a/zion/configuration.nix b/hosts/zion/configuration.nix similarity index 54% rename from zion/configuration.nix rename to hosts/zion/configuration.nix index 00645c8..37e6c98 100644 --- a/zion/configuration.nix +++ b/hosts/zion/configuration.nix @@ -1,27 +1,94 @@ # Edit this configuration file to define what should be installed on # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). - -{ config, pkgs, pkgs-unstable, ... }: - { - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { + # You can import other NixOS modules here + imports = [ + # If you want to use modules your own flake exports (from modules/nixos): + # outputs.nixosModules.example - # Bootloader. + # 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 = { + # I'm sorry Richard Stallman + 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; + # Use cache servers for packages + substituters = [ + "https://nix-community.cachix.org" + "https://cache.nixos.org/" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + + # Hostname + networking.hostName = "zion"; + + # Bootloader settings boot.loader.systemd-boot.enable = true; - # boot.loader.grub = { - # enable = true; - # useOSProber = true; - # device = "/dev/nvme0n1p1"; - # efiSupport = true; - # }; boot.loader.efi.canTouchEfiVariables = true; - networking.hostName = "zion"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + # Enables wireless support via wpa_supplicant + # networking.wireless.enable = true; # Configure network proxy if necessary # networking.proxy.default = "http://user:password@proxy:port/"; @@ -30,10 +97,10 @@ # Enable networking networking.networkmanager.enable = true; - # Set your time zone. + # Set your time zone time.timeZone = "Europe/Warsaw"; - # Select internationalisation properties. + # Select internationalisation properties i18n.defaultLocale = "en_US.UTF-8"; i18n.extraLocaleSettings = { @@ -42,12 +109,13 @@ LC_MEASUREMENT = "pl_PL.UTF-8"; LC_MONETARY = "pl_PL.UTF-8"; LC_NAME = "pl_PL.UTF-8"; - LC_NUMERIC = "pl_PL.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; LC_PAPER = "pl_PL.UTF-8"; LC_TELEPHONE = "pl_PL.UTF-8"; - LC_TIME = "pl_PL.UTF-8"; + LC_TIME = "en_US.UTF-8"; }; + # X Server settings services.xserver = { enable = true; layout = "pl"; @@ -101,7 +169,7 @@ open = false; # Enable the Nvidia settings menu, - # accessible via `nvidia-settings`. + # accessible via `nvidia-settings`. nvidiaSettings = true; # Optionally, you may need to select the appropriate driver version for your specific GPU. @@ -140,24 +208,23 @@ # services.xserver.libinput.enable = true; # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.mike = { - isNormalUser = true; - description = "Mike"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = []; + users.users = { + mike = { + isNormalUser = true; + description = "Mike"; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDfqPj+a2gmoUl3TuGSZxf0zRBabVWvXRrjLF7sFlqjMbfkx428F3L7C8OC3Z9XDT4ysbpgWcPuVKNtK5kkKGjSLHAgB2CgvD15K11Q+ag1+uyePaiOypZYJewvv1hhqU5IrVcxUbTsbREH/IsdQSlNSuyNFIr3oFnrff5iKEKEwEvSDeiqpqRh56pAkF6Kb15aYqZO7X9rbfoa8Sgj3VJXN0181lXMjXkNsYVa3gDmKv89C6qutg+KOpHlXgn4AfIRcCw8ik6OGBEfi/gUeb3SYpD+7undNLyloxCbGwHQ40IdoqPatyhTNS4jm9kb+Tno4hj0pbLHZSUdXgGaSfGx1W0MVVY0mm0Hu7EmYDBHUTfmPmPxnolWh8UH+XdkNPnwZfyZlyBcVVkVzog1ZCs1i9Y6oS1ZIbzuz+WxBPPDIHMRdmxv6+PMc5kZyrpuX1PgFb7Xt5cRNAL5/wywoi9Z45SS7qP9zNSb443UaaXzUatqnlawZ0GS0qXJh3ljwJ8= mike@odin" + ]; + extraGroups = [ "networkmanager" "wheel" ]; + }; }; - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = - (with pkgs; [ - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget - ntfs3g - dosfstools - ]) - ++ - (with pkgs-unstable; [ ]); + environment.systemPackages = (with pkgs; [ + # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + # wget + ntfs3g + dosfstools + ]); fonts.packages = with pkgs; [ nerdfonts ]; @@ -169,10 +236,17 @@ enableSSHSupport = true; }; - # List services that you want to enable: - - # Enable the OpenSSH daemon. - services.openssh.enable = true; + # 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) + PasswordAuthentication = true; + }; + }; # Open ports in the firewall. # networking.firewall.allowedTCPPorts = [ ... ]; @@ -187,23 +261,4 @@ # Before changing this value read the documentation for this option # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = "23.11"; # Did you read the comment? - - nix = { - settings = { - experimental-features = ["nix-command" "flakes"]; - substituters = [ - "https://nix-community.cachix.org" - "https://cache.nixos.org/" - ]; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - }; - }; - - # Allow unfree packages - nixpkgs.config = { - allowUnfree = true; - allowUnfreePredicate = (_: true); - }; } diff --git a/zion/hardware-configuration.nix b/hosts/zion/hardware-configuration.nix similarity index 100% rename from zion/hardware-configuration.nix rename to hosts/zion/hardware-configuration.nix diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix new file mode 100644 index 0000000..45aae31 --- /dev/null +++ b/modules/home-manager/default.nix @@ -0,0 +1,6 @@ +# Add your reusable home-manager modules to this directory, on their own file (https://nixos.wiki/wiki/Module). +# These should be stuff you would like to share with others, not your personal configurations. +{ + # List your module files here + # my-module = import ./my-module.nix; +} diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix new file mode 100644 index 0000000..8605069 --- /dev/null +++ b/modules/nixos/default.nix @@ -0,0 +1,6 @@ +# Add your reusable NixOS modules to this directory, on their own file (https://nixos.wiki/wiki/Module). +# These should be stuff you would like to share with others, not your personal configurations. +{ + # List your module files here + # my-module = import ./my-module.nix; +} diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..af62d95 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,23 @@ +# This file defines overlays +{inputs, ...}: { + # This one brings our custom packages from the 'pkgs' directory + additions = final: _prev: import ../pkgs {pkgs = final;}; + + # This one contains whatever you want to overlay + # You can change versions, add patches, set compilation flags, anything really. + # https://nixos.wiki/wiki/Overlays + modifications = final: prev: { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + }; + + # When applied, the unstable nixpkgs set (declared in the flake inputs) will + # be accessible through 'pkgs.unstable' + unstable-packages = final: _prev: { + unstable = import inputs.nixpkgs-unstable { + system = final.system; + config.allowUnfree = true; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..3d9e23c --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,5 @@ +# Custom packages, that can be defined similarly to ones from nixpkgs +# You can build them using 'nix build .#example' +pkgs: { + # example = pkgs.callPackage ./example { }; +} diff --git a/thor/configuration.nix b/thor/configuration.nix deleted file mode 100644 index 06ae887..0000000 --- a/thor/configuration.nix +++ /dev/null @@ -1,162 +0,0 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - -{ config, pkgs, pkgs-unstable, ... }: - -{ - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; - - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "thor"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable networking - networking.networkmanager.enable = true; - - # Set your time zone. - time.timeZone = "Europe/Warsaw"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "pl_PL.UTF-8"; - LC_IDENTIFICATION = "pl_PL.UTF-8"; - LC_MEASUREMENT = "pl_PL.UTF-8"; - LC_MONETARY = "pl_PL.UTF-8"; - LC_NAME = "pl_PL.UTF-8"; - LC_NUMERIC = "pl_PL.UTF-8"; - LC_PAPER = "pl_PL.UTF-8"; - LC_TELEPHONE = "pl_PL.UTF-8"; - LC_TIME = "pl_PL.UTF-8"; - }; - - services.xserver = { - enable = true; - layout = "pl"; - xkbVariant = ""; - - displayManager = { - lightdm = { - enable = true; - }; - }; - - desktopManager = { - xfce = { - enable = true; - }; - }; - }; - - # I use zsh btw - environment.shells = with pkgs; [ bash zsh ]; - users.defaultUserShell = pkgs.zsh; - programs.zsh.enable = true; - - # Configure console keymap - console.keyMap = "pl2"; - - # Enable CUPS to print documents. - services.printing.enable = true; - - # Enable sound with pipewire. - sound.enable = true; - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - # If you want to use JACK applications, uncomment this - #jack.enable = true; - - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; - }; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.mike = { - isNormalUser = true; - description = "Mike"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = []; - }; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = - (with pkgs; [ - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - #wget - ntfs3g - dosfstools - ]) - ++ - (with pkgs-unstable; [ - ]); - - fonts.packages = with pkgs; [ nerdfonts ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - programs.mtr.enable = true; - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "23.11"; # Did you read the comment? - - nix = { - settings = { - experimental-features = ["nix-command" "flakes"]; - substituters = [ - "https://nix-community.cachix.org" - "https://cache.nixos.org/" - ]; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - }; - }; - - # Allow unfree packages - nixpkgs.config = { - allowUnfree = true; - allowUnfreePredicate = (_: true); - }; -}