From 4e5ab169377b463f81d0d689132c5acbe68347c9 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 30 Mar 2023 19:15:51 +0100 Subject: [PATCH] feat: initial commit of NixOS on my Infinitybook --- flake.nix | 85 ++++++----- home-manager/modules/common.nix | 14 +- home-manager/nixedo.nix | 49 +++++++ justfile | 4 +- system/nixos/nixedo/configuration.nix | 136 ++++++++++++++++++ .../nixos/nixedo/hardware-configuration.nix | 43 ++++++ 6 files changed, 286 insertions(+), 45 deletions(-) create mode 100644 home-manager/nixedo.nix create mode 100644 system/nixos/nixedo/configuration.nix create mode 100644 system/nixos/nixedo/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index d01e2ac..fcb8676 100644 --- a/flake.nix +++ b/flake.nix @@ -3,49 +3,62 @@ inputs = { home-manager.inputs.nixpkgs.follows = "nixpkgs"; home-manager.url = "github:nix-community/home-manager"; - neovim-nightly = { - # workaround: https://github.com/nix-community/neovim-nightly-overlay/issues/164 - inputs.nixpkgs.url = "github:nixos/nixpkgs?rev=fad51abd42ca17a60fc1d4cb9382e2d79ae31836"; - url = "github:nix-community/neovim-nightly-overlay"; - }; + # workaround: https://github.com/nix-community/neovim-nightly-overlay/issues/164 + neovim-nightly.inputs.nixpkgs.url = + "github:nixos/nixpkgs?rev=fad51abd42ca17a60fc1d4cb9382e2d79ae31836"; + neovim-nightly.url = "github:nix-community/neovim-nightly-overlay"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; }; outputs = { self, home-manager, neovim-nightly, nixpkgs, ... }: - let - overlays = [ neovim-nightly.overlay ]; - in { - nixosConfigurations = { - apollo = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./system/nixos/apollo/configuration.nix - { nixpkgs.overlays = overlays; } - home-manager.nixosModules.home-manager { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.opdavies = import ./home-manager/apollo.nix; - } - ]; - }; - }; + let overlays = [ neovim-nightly.overlay ]; + in { + nixosConfigurations = { + apollo = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; - homeConfigurations = { - pop-os = home-manager.lib.homeManagerConfiguration { - modules = [ - { nixpkgs.overlays = overlays; } - ./system/pop-os.nix - ]; - pkgs = nixpkgs.legacyPackages.x86_64-linux; + modules = [ + { nixpkgs.overlays = overlays; } + + ./system/nixos/apollo/configuration.nix + + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.opdavies = import ./home-manager/apollo.nix; + } + ]; + }; + + nixedo = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + + modules = [ + { nixpkgs.overlays = overlays; } + + ./system/nixos/nixedo/configuration.nix + + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.opdavies = import ./home-manager/nixedo.nix; + } + ]; + }; }; - wsl2 = home-manager.lib.homeManagerConfiguration { - modules = [ - { nixpkgs.overlays = overlays; } - ./system/wsl2.nix - ]; - pkgs = nixpkgs.legacyPackages.x86_64-linux; + homeConfigurations = { + pop-os = home-manager.lib.homeManagerConfiguration { + modules = [ { nixpkgs.overlays = overlays; } ./system/pop-os.nix ]; + pkgs = nixpkgs.legacyPackages.x86_64-linux; + }; + + wsl2 = home-manager.lib.homeManagerConfiguration { + modules = [ { nixpkgs.overlays = overlays; } ./system/wsl2.nix ]; + pkgs = nixpkgs.legacyPackages.x86_64-linux; + }; }; }; - }; } diff --git a/home-manager/modules/common.nix b/home-manager/modules/common.nix index d13d0c6..fe07105 100644 --- a/home-manager/modules/common.nix +++ b/home-manager/modules/common.nix @@ -15,13 +15,13 @@ in { package = pkgs.neovim-nightly; plugins = with pkgs; [ - customVim.tabline-vim - customVim.vim-astro - customVim.vim-caser - customVim.vim-heritage - customVim.vim-just - customVim.vim-textobj-xmlattr - customVim.vim-visual-star-search +# customVim.tabline-vim +# customVim.vim-astro +# customVim.vim-caser +# customVim.vim-heritage +# customVim.vim-just +# customVim.vim-textobj-xmlattr +# customVim.vim-visual-star-search vimPlugins.comment-nvim vimPlugins.dial-nvim diff --git a/home-manager/nixedo.nix b/home-manager/nixedo.nix new file mode 100644 index 0000000..621a207 --- /dev/null +++ b/home-manager/nixedo.nix @@ -0,0 +1,49 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./modules/common.nix + ./modules/git.nix + ./modules/home-manager.nix + ./modules/tmux.nix + ./modules/zsh.nix + ]; + + home.stateVersion = "22.05"; + + home.username = "opdavies"; + home.homeDirectory = "/home/opdavies"; + + programs.alacritty = { + enable = true; + + settings = { + window.padding = { + x = 15; + y = 15; + }; + + font = { + size = 12.0; + + normal.family = "JetBrainsMono Nerd Font"; + + offset.y = 12; + glyph_offset.y = 6; + }; + + shell = { + program = "zsh"; + }; + }; + }; + + home.packages = with pkgs; [ + discord + slack + teams + vlc + xcape + zoom-us + ]; +} diff --git a/justfile b/justfile index 4fcddd3..7d3a22d 100644 --- a/justfile +++ b/justfile @@ -4,8 +4,8 @@ default: clean: rm -rf ./result -apollo command *args: && clean - sudo nixos-rebuild {{ command }} --flake .#apollo {{ args }} +nixos command profile: && clean + sudo nixos-rebuild {{ command }} --flake .#{{ profile }} pop-os command *args: && clean NIXPKGS_ALLOW_UNFREE=1 home-manager {{ command }} -f home-manager/home.nix --impure --flake .#pop-os {{ args }} diff --git a/system/nixos/nixedo/configuration.nix b/system/nixos/nixedo/configuration.nix new file mode 100644 index 0000000..30a40e5 --- /dev/null +++ b/system/nixos/nixedo/configuration.nix @@ -0,0 +1,136 @@ +# 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, ... }: + +{ + imports = [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.efiSysMountPoint = "/boot/efi"; + + boot.kernelPackages = pkgs.linuxPackages_latest; + + networking.hostName = "nixedo"; # 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/London"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_GB.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_GB.UTF-8"; + LC_IDENTIFICATION = "en_GB.UTF-8"; + LC_MEASUREMENT = "en_GB.UTF-8"; + LC_MONETARY = "en_GB.UTF-8"; + LC_NAME = "en_GB.UTF-8"; + LC_NUMERIC = "en_GB.UTF-8"; + LC_PAPER = "en_GB.UTF-8"; + LC_TELEPHONE = "en_GB.UTF-8"; + LC_TIME = "en_GB.UTF-8"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the KDE Plasma Desktop Environment. + services.xserver.displayManager.sddm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; + + # Configure keymap in X11 + services.xserver = { + layout = "gb"; + xkbVariant = ""; + }; + + # Configure console keymap + console.keyMap = "uk"; + + # 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.opdavies = { + isNormalUser = true; + description = "Oliver Davies"; + extraGroups = [ "docker" "networkmanager" "wheel" ]; + packages = with pkgs; [ firefox ]; + }; + + # 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.11"; # Did you read the comment? + + virtualisation.docker.enable = true; +} + diff --git a/system/nixos/nixedo/hardware-configuration.nix b/system/nixos/nixedo/hardware-configuration.nix new file mode 100644 index 0000000..6cb9d0d --- /dev/null +++ b/system/nixos/nixedo/hardware-configuration.nix @@ -0,0 +1,43 @@ +# 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" "thunderbolt" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.kernelParams = [ "i8042.reset" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/7c6d69ec-ba06-4ddb-b9c4-62b3994fda91"; + fsType = "ext4"; + }; + + fileSystems."/boot/efi" = { + device = "/dev/disk/by-uuid/B729-9A75"; + fsType = "vfat"; + }; + + swapDevices = + [{ device = "/dev/disk/by-uuid/5db0a0e6-93fb-4d0b-8fb0-fdb3cb76b89d"; }]; + + # 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.enp0s13f0u1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.bluetooth.enable = true; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; + +}