From 3cb3e95e89a91da4f143881dfe8f6090e80d466c Mon Sep 17 00:00:00 2001 From: Gabriella Bere Date: Tue, 16 Jul 2024 11:18:51 +0100 Subject: [PATCH] init --- flake.lock | 65 ++++++ flake.nix | 32 +++ hosts/gabbielaptop/configuration.nix | 203 ++++++++++++++++++ hosts/gabbielaptop/hardware-configuration.nix | 45 ++++ hosts/gabbielaptop/home.nix | 76 +++++++ modules/environment.nix | 6 + modules/home-manager/zsh.nix | 29 +++ modules/nh.nix | 9 + modules/waydroid.nix | 3 + 9 files changed, 468 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/gabbielaptop/configuration.nix create mode 100644 hosts/gabbielaptop/hardware-configuration.nix create mode 100644 hosts/gabbielaptop/home.nix create mode 100644 modules/environment.nix create mode 100644 modules/home-manager/zsh.nix create mode 100644 modules/nh.nix create mode 100644 modules/waydroid.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5f05666 --- /dev/null +++ b/flake.lock @@ -0,0 +1,65 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720734513, + "narHash": "sha256-neWQ8eNtLTd+YMesb7WjKl1SVCbDyCm46LUgP/g/hdo=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "90ae324e2c56af10f20549ab72014804a3064c7f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1720768451, + "narHash": "sha256-EYekUHJE2gxeo2pM/zM9Wlqw1Uw2XTJXOSAO79ksc4Y=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7e7c39ea35c5cdd002cd4588b03a3fb9ece6fad9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "stablepkgs": "stablepkgs" + } + }, + "stablepkgs": { + "locked": { + "lastModified": 1720823163, + "narHash": "sha256-FZ5dnrvKkln9ESdoTR8R7GKW9rNpXNZrxGsOXsbsTpE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f12ee5f64c6a09995e71c9626d88c4efa983b488", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7d0115f --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + description = "main system configuration flake"; + + inputs = { + # NixOS official package source, using the nixos-24.05 branch as stable and nixos-unstable as default + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + stablepkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, ... } @ inputs: + let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + stable = inputs.stablepkgs.legacyPacakges.x86_64-linux; + in + { + nixosConfigurations.gabbielaptop = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + system = "x86_64-linux"; + modules = [ + # Import configuration modules + ./hosts/gabbielaptop/configuration.nix + ./modules/nh.nix + ./modules/environment.nix + ./modules/waydroid.nix + ]; + }; + }; +} diff --git a/hosts/gabbielaptop/configuration.nix b/hosts/gabbielaptop/configuration.nix new file mode 100644 index 0000000..7d57d30 --- /dev/null +++ b/hosts/gabbielaptop/configuration.nix @@ -0,0 +1,203 @@ +# 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, lib, pkgs, inputs, ... }: + +{ + + imports = + [ + ./hardware-configuration.nix + inputs.home-manager.nixosModules.default + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # default kernel causes issues with wpa_supplicant meaning shutdown times are > 10 mins updating to kernel 69 fixes this + boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_9; + + networking.hostName = "gabbielaptop"; # 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. + # You can disable this if you're only using the Wayland session. + services.xserver.enable = true; + + # Enable the KDE Plasma Desktop Environment. + services.displayManager.sddm.enable = true; + services.desktopManager.plasma6.enable = true; + + # Configure keymap in X11 + services.xserver.xkb = { + layout = "gb"; + variant = ""; + }; + + # Configure console keymap + console.keyMap = "uk"; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + 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; + }; + + programs.zsh.enable = true; + users.users.blue = { + isNormalUser = true; + description = "Gabriella Bere"; + extraGroups = [ "networkmanager" "wheel" ]; + shell = pkgs.zsh; + }; + + home-manager = { +# extraSpeicalArgs = { inherit inputs; }; + users = { + "blue" = import ./home.nix; + }; + }; + + services.fprintd.enable = true; + hardware.bluetooth.enable = true; + + # Install firefox. + programs.firefox.enable = true; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + neovim # nano is installed by default + wget + vesktop + prismlauncher + thunderbird + kdePackages.bluedevil + fastfetch + ungoogled-chromium + qbittorrent + obsidian + p7zip + unrar + wineWowPackages.stable + wine + (wine.override { wineBuild = "wine64"; }) + wine64 + wineWowPackages.staging + winetricks + wineWowPackages.waylandFull + vlc + krename + kdePackages.filelight + protonmail-bridge + obs-studio + pciutils + vial + git + qmk + dmidecode + wl-clipboard + lutris + tree + tenacity + mediawriter + ]; + + hardware.keyboard.qmk.enable = true; + + programs.steam.enable = true; + programs.steam.remotePlay.openFirewall = true; + + # protonmail daemon config + systemd.user.services.protonmail-bridge = { + enable = true; + wantedBy = [ "default.target" ]; + description = "autostart protonmail-bridge on login as a daemon"; + serviceConfig = { + Type = "simple"; + ExecStart = "/nix/store/protonmail-bridge --noninteractive --no-window"; + }; + }; + + # 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 = [ + 43391 # used to forward minecraft traffic to minecraft.gabbie.blue:33991 + 4455 # used for OBS websocket + ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # networking.firewall.allowedTCPPortRanges = [ + # { + # from = 49000; + # to = 65535; + # } + # ]; + # 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 = "24.05"; # Did you read the comment? + +} diff --git a/hosts/gabbielaptop/hardware-configuration.nix b/hosts/gabbielaptop/hardware-configuration.nix new file mode 100644 index 0000000..52a7620 --- /dev/null +++ b/hosts/gabbielaptop/hardware-configuration.nix @@ -0,0 +1,45 @@ +# 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 = [ "nvme" "xhci_pci" "thunderbolt" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/56b2985c-c9c3-4d1b-9b97-479ca1217822"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/5932-F16D"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/7b70ea86-8c19-4089-ac1c-0fdcf24bfa8e"; + fsType = "ext4"; + }; + + 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.enp196s0f3u1.useDHCP = lib.mkDefault true; + # networking.interfaces.eth1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/gabbielaptop/home.nix b/hosts/gabbielaptop/home.nix new file mode 100644 index 0000000..2ccf6d9 --- /dev/null +++ b/hosts/gabbielaptop/home.nix @@ -0,0 +1,76 @@ +{ config, pkgs, ... }: + +{ + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "blue"; + home.homeDirectory = "/home/blue"; + + # 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 = "24.05"; # Please read the comment before changing. + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = [ + # # Adds the 'hello' command to your environment. It prints a friendly + # # "Hello, world!" when run. + # pkgs.hello + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + # 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 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. These will be explicitly sourced when using a + # shell provided by Home Manager. If you don't want to manage your shell + # through Home Manager then you have to manually source 'hm-session-vars.sh' + # located at either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/blue/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + # EDITOR = "emacs"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/modules/environment.nix b/modules/environment.nix new file mode 100644 index 0000000..6fd4b39 --- /dev/null +++ b/modules/environment.nix @@ -0,0 +1,6 @@ +{ + # set FLAKE variable for use with nh + environment.sessionVariables = { + FLAKE = "/home/blue/nixos"; + }; +} diff --git a/modules/home-manager/zsh.nix b/modules/home-manager/zsh.nix new file mode 100644 index 0000000..94b558a --- /dev/null +++ b/modules/home-manager/zsh.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +{ + programs.zsh = { + enable = true; + autocd = true; + dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableCompletion = true; +# shellAliases = { +# sl = "exa"; +# ls = "exa"; +# l = "exa -l"; +# la = "exa -la"; +# ip = "ip --color=auto"; +# }; + + plugins = with pkgs; [ + { + name = "zsh-syntax-highlighting"; + src = fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-syntax-highlighting"; + rev = "0.6.0"; + sha256 = "0zmq66dzasmr5pwribyh4kbkk23jxbpdw4rjxx0i7dx8jjp2lzl4"; + }; + file = "agkozak-zsh-prompt.plugin.zsh"; + } +} diff --git a/modules/nh.nix b/modules/nh.nix new file mode 100644 index 0000000..49d06cf --- /dev/null +++ b/modules/nh.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: +{ + programs.nh = { + enable = true; + clean.enable = true; + clean.extraArgs = "--keep-since 4d --keep 3"; + flake = "/home/blue/nixos"; + }; +} diff --git a/modules/waydroid.nix b/modules/waydroid.nix new file mode 100644 index 0000000..00ff0d9 --- /dev/null +++ b/modules/waydroid.nix @@ -0,0 +1,3 @@ +{ + virtualisation.waydroid.enable = true; +}