commit 13fe4d6fdf367b7446a3ed594fbc3d3971237793 Author: ChUrl Date: Wed Jun 29 14:26:43 2022 +0200 Commit initial flake config diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..4fae6dc1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.jpg filter=lfs diff=lfs merge=lfs -text diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 00000000..21f0abb2 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,151 @@ +# 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, lib, config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Enable flakes + nix = { + package = pkgs.nixFlakes; + extraOptions = "experimental-features = nix-command flakes"; + }; + + # TODO: Understand this + # This will add your inputs as registries, making operations with them (such + # as nix shell nixpkgs#name) consistent with your flake inputs. + nix.registry = lib.mapAttrs' (n: v: lib.nameValuePair n { flake = v; }) inputs; + + # TODO: Understand that + # Will activate home-manager profiles for each user upon login + # This is useful when using ephemeral installations + environment.loginShellInit = '' + [ -d "$HOME/.nix-profile" ] || /nix/var/nix/profiles/per-user/$USER/home-manager/activate &> /dev/null + ''; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.efiSysMountPoint = "/boot/efi"; + + networking.hostName = "nixinator"; # 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/Berlin"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.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"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the KDE Plasma Desktop Environment. + services.xserver.videoDrivers = ["nvidia"]; + services.xserver.displayManager.sddm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; + services.xserver.desktopManager.plasma5.runUsingSystemd = true; + + # Configure keymap in X11 + services.xserver = { + layout = "us"; + xkbVariant = "altgr-intl"; + }; + + # 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.christoph = { + isNormalUser = true; + description = "Christoph"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + # firefox + # kate + # thunderbird + ]; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # 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 + ]; + + # 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 = "22.05"; # Did you read the comment? + +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..2ad8e88e --- /dev/null +++ b/flake.lock @@ -0,0 +1,127 @@ +{ + "nodes": { + "emacs-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1656413262, + "narHash": "sha256-I8X1LaW/qoSWeBLK0N8GPOshIuXG9zyNyZUtKZYa0h4=", + "owner": "nix-community", + "repo": "emacs-overlay", + "rev": "8772891c73e2809df5e5469d14535ea77e123d3e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "emacs-overlay", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1656065134, + "narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "hardware": { + "locked": { + "lastModified": 1656353817, + "narHash": "sha256-UJEzMQcft/0Ilu4LWV7UH51mr5UCo28GL06BGO+djv4=", + "owner": "nixos", + "repo": "nixos-hardware", + "rev": "78e7c2c397b0376526e83162b58de921362e3399", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixos-hardware", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1656367977, + "narHash": "sha256-0hV17V9Up9pnAtPJ+787FhrsPnawxoTPA/VxgjRMrjc=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "3bf16c0fd141c28312be52945d1543f9ce557bb1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-wW1xRFBn376yGloXZ4QzBE4hjipMawpV18Lshd9QSPw=", + "path": "/nix/store/1qz0d0cx49ic26jynvb6fqmzl138rj0s-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1656239181, + "narHash": "sha256-wW1xRFBn376yGloXZ4QzBE4hjipMawpV18Lshd9QSPw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f2537a505d45c31fe5d9c27ea9829b6f4c4e6ac5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "emacs-overlay": "emacs-overlay", + "hardware": "hardware", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2" + } + }, + "utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..85097281 --- /dev/null +++ b/flake.nix @@ -0,0 +1,78 @@ +# The curly braces denote a set of keys and values. +{ + description = "ChUrl's very bad and basic Nix config using Flakes"; + + # This config is a Flake. + # It needs inputs that are passed as arguments to the output. + # These are the dependencies of the Flake. + # The git revisions get locked in flake.lock to make the outputs deterministic. + inputs = { + # Nixpkgs + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + hardware.url = "github:nixos/nixos-hardware"; + + # Home manager + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + # Other Flakes + emacs-overlay.url = "github:nix-community/emacs-overlay"; + }; + + # Outputs is a function that takes the inputs as arguments. + # To handle extra arguments we use the inputs@ pattern. + # It gives a name to the ... ellipses. + outputs = inputs @ { nixpkgs, home-manager, ... }: + # With let you can define local variables + let + # We bring these functions into the scope for the outputs. + inherit (nixpkgs.lib) nixosSystem; + inherit (home-manager.lib) homeManagerConfiguration; + in + # The rec expression turns a basic set into a set where self-referencing is possible. + # It is a shorthand for recursive and allows to use the values defined in this set from its own scope. + rec { + # System configurations + # Accessible via 'nixos-rebuild' + nixosConfigurations = { + # We give our configuration a name (the hostname) to choose a configuration when rebuilding. + # This makes it easy to add different configurations later (e.g. for a laptop). + # Usage: sudo nixos-rebuild switch --flake .#nixinator + nixinator = nixosSystem { + system = "x86_64-linux"; + + # >> Main NixOS configuration file << + modules = [ ./configuration.nix ]; + + # Make our inputs available to the config (for importing modules) + specialArgs = { inherit inputs; }; + }; + }; + + # Home configurations + # Accessible via 'home-manager' + homeConfigurations = { + # We give our configuration a name (the user + hostname). + # This makes it easy to add configurations for different users/PCs. + # Usage: home-manager switch --flake .#christoph@nixinator + "christoph@nixinator" = homeManagerConfiguration rec { + pkgs = nixpkgs.legacyPackages."x86_64-linux"; # HomeManager needs this since 22.11 release + + modules = [ + # >> Main HomeManager configuration file << + ./home.nix + { + home = rec { + username = "christoph"; + homeDirectory = "/home/${username}"; + stateVersion = "22.05"; + }; + } + ]; + + # Make our inputs available to the config (for importing modules) + extraSpecialArgs = { inherit inputs; }; + }; + }; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 00000000..b77dc680 --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,41 @@ +# 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" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/b87bbc3d-edd3-434a-b4a3-859bf62b8a17"; + fsType = "ext4"; + }; + + fileSystems."/boot/efi" = + { device = "/dev/disk/by-uuid/36A9-3D74"; + 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; + # networking.interfaces.enp4s0u2.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + # high-resolution display + hardware.video.hidpi.enable = lib.mkDefault true; +} diff --git a/home.nix b/home.nix new file mode 100644 index 00000000..bccc4568 --- /dev/null +++ b/home.nix @@ -0,0 +1,31 @@ +# This is your home-manager configuration file +# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) + +{ inputs, lib, config, pkgs, ... }: { + imports = [ + # If you want to use home-manager modules from other flakes (such as nix-colors), use something like: + # inputs.nix-colors.homeManagerModule + + # Feel free to split up your configuration and import pieces of it here. + ]; + + # Comment out if you wish to disable unfree packages for your system + nixpkgs.config.allowUnfree = true; + + # Enable home-manager and git + programs.home-manager.enable = true; + programs.git = { + enable = true; + delta.enable = true; + userEmail = "christoph.urlacher@protonmail.com"; + userName = "ChUrl"; + }; + programs.neovim.enable = true; + programs.firefox.enable = true; + + # Add stuff for your user as you see fit: + # home.packages = with pkgs; [ steam ]; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; +}