From 10fc34acb3aed5490cde25ed7e0e0a5d67737f64 Mon Sep 17 00:00:00 2001 From: Kalle Struik Date: Tue, 31 Oct 2023 12:20:02 +0100 Subject: [PATCH] Initial commit --- flake.lock | 49 ++++++++++ flake.nix | 35 +++++++ home-manager/kalle-pc/kalle.nix | 69 ++++++++++++++ nixos/kalle-pc/configuration.nix | 94 +++++++++++++++++++ nixos/kalle-pc/hardware-configuration.nix | 56 +++++++++++ .../hardware-configuration.override.nix | 23 +++++ nvim/default.nix | 13 +++ nvim/init.lua | 0 8 files changed, 339 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home-manager/kalle-pc/kalle.nix create mode 100644 nixos/kalle-pc/configuration.nix create mode 100644 nixos/kalle-pc/hardware-configuration.nix create mode 100644 nixos/kalle-pc/hardware-configuration.override.nix create mode 100644 nvim/default.nix create mode 100644 nvim/init.lua diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..96f66a2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,49 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1695108154, + "narHash": "sha256-gSg7UTVtls2yO9lKtP0yb66XBHT1Fx5qZSZbGMpSn2c=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "07682fff75d41f18327a871088d20af2710d4744", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.05", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1698562188, + "narHash": "sha256-9nkxGnA/T+jLhHAMFRW157Qi/zfbf5dF1q7HfKROl3o=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3e10c80821dedb93592682379f476745f370a58e", + "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..af3198a --- /dev/null +++ b/flake.nix @@ -0,0 +1,35 @@ +{ + description = "My NixOS and home-manager configs"; + + inputs = { + # Nixpkgs + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; + + # Home manager + home-manager.url = "github:nix-community/home-manager/release-23.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { + self, + nixpkgs, + home-manager, + ... + } @ inputs : let + inherit (self) outputs; + in { + nixosConfigurations = { + "kalle-pc" = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs;}; + modules = [ ./nixos/kalle-pc/configuration.nix ]; + }; + }; + homeConfigurations = { + "kalle@kalle-pc" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + extraSpecialArgs = {inherit inputs outputs;}; + modules = [ ./home-manager/kalle-pc/kalle.nix ]; + }; + }; + }; +} diff --git a/home-manager/kalle-pc/kalle.nix b/home-manager/kalle-pc/kalle.nix new file mode 100644 index 0000000..f608008 --- /dev/null +++ b/home-manager/kalle-pc/kalle.nix @@ -0,0 +1,69 @@ +{ + inputs, + lib, + config, + pkgs, + ... +}: + +{ + home = { + username = "kalle"; + homeDirectory = "/home/kalle"; + }; + imports = + [ + ../../nvim + ]; + + nixpkgs.config.allowUnfree = true; + nixpkgs.config.allowUnfreePredicate = _: true; + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = with pkgs; [ + discord + firefox + httpie + neovim + kate + kitty + + # # 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}!" + # '') + ]; + + programs.home-manager.enable = true; + programs.bash.enable = true; + programs.git = { + enable = true; + userName = "Kalle Struik"; + userEmail = "kalle@kallestruik.nl"; + extraConfig = { + init.defaultBranch = "main"; + }; + }; + + home.sessionVariables = { + EDITOR = "nvim"; + }; + + # 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.05"; # Please read the comment before changing. +} diff --git a/nixos/kalle-pc/configuration.nix b/nixos/kalle-pc/configuration.nix new file mode 100644 index 0000000..b23ae8e --- /dev/null +++ b/nixos/kalle-pc/configuration.nix @@ -0,0 +1,94 @@ +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ./hardware-configuration.override.nix + ]; + + nix.settings = { + # Enable flakes and new 'nix' command + experimental-features = "nix-command flakes"; + # Deduplicate and optimize nix store + auto-optimise-store = true; + }; + + services.btrfs.autoScrub.enable = true; + + nixpkgs.config.allowUnfree = true; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "kalle-pc"; + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Amsterdam"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + useXkbConfig = true; # use xkbOptions in tty. + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + + # Enable the Plasma 5 Desktop Environment. + services.xserver.displayManager.sddm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; + + + # Configure keymap in X11 + services.xserver.layout = "dvorak"; + services.xserver.xkbOptions = "eurosign:e,caps:escape"; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound. + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + + users.users.kalle = { + isNormalUser = true; + group = "kalle"; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + }; + + users.groups.kalle.gid = 1000; + + environment.systemPackages = with pkgs; [ + xdg-user-dirs + ]; + + # Steam needs to be installed on system level, because reasons + programs.steam.enable = true; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + # Disable firewall. + 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.05"; # Did you read the comment? + +} + diff --git a/nixos/kalle-pc/hardware-configuration.nix b/nixos/kalle-pc/hardware-configuration.nix new file mode 100644 index 0000000..e231b9b --- /dev/null +++ b/nixos/kalle-pc/hardware-configuration.nix @@ -0,0 +1,56 @@ +# 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" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/d453acaf-12a4-4f7a-b33e-90d87a086995"; + fsType = "btrfs"; + options = [ "subvol=root" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/d453acaf-12a4-4f7a-b33e-90d87a086995"; + fsType = "btrfs"; + options = [ "subvol=home" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-uuid/d453acaf-12a4-4f7a-b33e-90d87a086995"; + fsType = "btrfs"; + options = [ "subvol=nix" ]; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/23F6-1045"; + fsType = "vfat"; + }; + + fileSystems."/swap" = + { device = "/dev/disk/by-uuid/d453acaf-12a4-4f7a-b33e-90d87a086995"; + fsType = "btrfs"; + options = [ "subvol=swap" ]; + }; + + 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.enp35s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/nixos/kalle-pc/hardware-configuration.override.nix b/nixos/kalle-pc/hardware-configuration.override.nix new file mode 100644 index 0000000..803eeed --- /dev/null +++ b/nixos/kalle-pc/hardware-configuration.override.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, modulesPath, ...}: + +{ + fileSystems = { + # Extra filesystem configs to enable compression. + "/".options = [ "compress=zstd" ]; + "/home".options = [ "compress=zstd" ]; + "/nix".options = [ "compress=zstd" "noatime" ]; + "/swap".options = [ "noatime" ]; + + # Mount other drives + "/mnt/games" = { + device = "/dev/disk/by-uuid/0ac05c3f-df12-458e-b145-e912febe1205"; + fsType = "ext4"; + }; + "/mnt/external" = { + device = "/dev/disk/by-uuid/13e2dfc3-7b4d-44ac-9417-51b933a36917"; + fsType = "ext4"; + }; + + }; + +} diff --git a/nvim/default.nix b/nvim/default.nix new file mode 100644 index 0000000..6991646 --- /dev/null +++ b/nvim/default.nix @@ -0,0 +1,13 @@ +{ + inputs, + lib, + config, + pkgs, + ... +}: + +{ + xdg.configFile = { + "nvim/init.lua".source = ./init.lua; + }; +} diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..e69de29