From 4dea2a6b3b7f73439b3fd530d72fbc0dcfc37237 Mon Sep 17 00:00:00 2001 From: CherryKitten Date: Sun, 17 Dec 2023 14:33:15 +0100 Subject: [PATCH] Initial --- flake.lock | 64 +++++++++++++++++ flake.nix | 42 +++++++++++ hosts/bengal/configuration.nix | 96 +++++++++++++++++++++++++ hosts/bengal/hardware-configuration.nix | 43 +++++++++++ modules/common/default.nix | 23 ++++++ modules/common/home.nix | 68 ++++++++++++++++++ modules/common/yubikey.nix | 13 ++++ users/default.nix | 11 +++ 8 files changed, 360 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/bengal/configuration.nix create mode 100644 hosts/bengal/hardware-configuration.nix create mode 100644 modules/common/default.nix create mode 100644 modules/common/home.nix create mode 100644 modules/common/yubikey.nix create mode 100644 users/default.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1e1a1cc --- /dev/null +++ b/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1702676849, + "narHash": "sha256-XqcREaTS38/QOsN8fk8PP325/UXHyF9enbP5ZPw5aiA=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "aa99c2f4e9847cbb7e46fac0844ea1eb164b3b3a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.11", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1701952659, + "narHash": "sha256-TJv2srXt6fYPUjxgLAL0cy4nuf1OZD4KuA1TrCiQqg0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b4372c4924d9182034066c823df76d6eaf1f4ec4", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-23.11", + "type": "indirect" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1702206697, + "narHash": "sha256-vE9oEx3Y8TO5MnWwFlmopjHd1JoEBno+EhsfUCq5iR8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "29d6c96900b9b576c2fb89491452f283aa979819", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9bf59dd --- /dev/null +++ b/flake.nix @@ -0,0 +1,42 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs/nixos-23.11"; + nixpkgs-unstable.url = "nixpkgs/nixpkgs-unstable"; + home-manager = { + url = "github:nix-community/home-manager/release-23.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + }; + + outputs = inputs@{ self, nixpkgs, nixpkgs-unstable, home-manager, ... }: + let + mkHost = hostname: { + imports = [ + ./hosts/${hostname}/configuration.nix + ./modules/common + (import "${home-manager}/nixos") + + ]; + deployment = { + targetUser = "root"; + targetHost = hostname; + allowLocalDeployment = true; + }; + }; + in + { + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; + colmena = { + meta = { + nixpkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ ]; + }; + }; + + bengal = mkHost "bengal"; + + }; + }; +} diff --git a/hosts/bengal/configuration.nix b/hosts/bengal/configuration.nix new file mode 100644 index 0000000..e377477 --- /dev/null +++ b/hosts/bengal/configuration.nix @@ -0,0 +1,96 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, ... }: + +{ + imports = + [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + boot.loader.systemd-boot.enable = true; + + networking.hostName = "bengal"; # Define your hostname. + # Pick only one of the below networking options. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = lib.mkForce "de"; + useXkbConfig = true; # use xkb.options in tty. + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + services.xserver.displayManager.sddm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; + services.xserver.libinput.enable = true; + + services.xserver.xkb.layout = "de"; + services.xserver.xkb.options = "caps:escape"; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound. + # sound.enable = true; + hardware.pulseaudio.enable = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + wget + curl + ]; + + # 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 = [ 22 ]; + + nix.extraOptions = + '' + experimental-features = nix-command flakes + ''; + + # This option defines the first version of NixOS you have installed on this particular machine, + # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. + # + # Most users should NEVER change this value after the initial install, for any reason, + # even if you've upgraded your system to a new NixOS release. + # + # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, + # so changing it will NOT upgrade your system. + # + # This value being lower than the current NixOS release does NOT mean your system is + # out of date, out of support, or vulnerable. + # + # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, + # and migrated your data accordingly. + # + # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + system.stateVersion = "23.11"; # Did you read the comment? + +} + diff --git a/hosts/bengal/hardware-configuration.nix b/hosts/bengal/hardware-configuration.nix new file mode 100644 index 0000000..6426f6d --- /dev/null +++ b/hosts/bengal/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" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/7a713df7-7027-4ae6-b1a3-839dda62dcbc"; + fsType = "btrfs"; + }; + + boot.initrd.luks.devices."root".device = "/dev/disk/by-uuid/fbd8d597-8cdb-4c6b-9fa0-b05f4cbfce86"; + + fileSystems."/boot" = + { + device = "/dev/disk/by-uuid/B4A7-702B"; + fsType = "vfat"; + }; + + swapDevices = + [{ device = "/dev/disk/by-uuid/8cca600e-735e-4486-92e3-01ff6c0b7599"; }]; + + # 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.enp4s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/modules/common/default.nix b/modules/common/default.nix new file mode 100644 index 0000000..6d8964d --- /dev/null +++ b/modules/common/default.nix @@ -0,0 +1,23 @@ +{ lib, config, pkgs, ... }: { + imports = [ + ../../users + ./home.nix + ./yubikey.nix + ]; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + time.timeZone = "Europe/Berlin"; + + # Packages used on all systems + environment.systemPackages = with pkgs; [ + git + openssl + rsync + pinentry + wget + ]; + +} + + diff --git a/modules/common/home.nix b/modules/common/home.nix new file mode 100644 index 0000000..024a052 --- /dev/null +++ b/modules/common/home.nix @@ -0,0 +1,68 @@ +{ lib, config, pkgs, ... }: { + + home-manager.useGlobalPkgs = true; + home-manager.users.sammy = { + home.username = "sammy"; + home.homeDirectory = "/home/sammy"; + home.stateVersion = "23.11"; # Please read the comment before changing. + home.packages = with pkgs; [ + bat + lsd + gnupg + ]; + + programs = { + home-manager.enable = true; + + git = { + enable = true; + userName = "CherryKitten"; + userEmail = "git@cherrykitten.dev"; + signing.key = "0xC01A7CBBA617BD5F"; + signing.signByDefault = true; + extraConfig = { + init = { defaultBranch = "main"; }; + core = { editor = "nvim"; }; + pull.rebase = true; + }; + + }; + + nushell = { + enable = true; + }; + }; + + # 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'. 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 + # + # /etc/profiles/per-user/sammy/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + EDITOR = "nvim"; + }; + + # Let Home Manager install and manage itself. + }; +} diff --git a/modules/common/yubikey.nix b/modules/common/yubikey.nix new file mode 100644 index 0000000..67c687d --- /dev/null +++ b/modules/common/yubikey.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: { + services.udev.packages = with pkgs; [ libu2f-host yubikey-personalization ]; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + enableExtraSocket = true; + + }; + + services.pcscd.enable = true; +} + diff --git a/users/default.nix b/users/default.nix new file mode 100644 index 0000000..c7d711f --- /dev/null +++ b/users/default.nix @@ -0,0 +1,11 @@ +{ lib, config, pkgs, ... }: { + users.users = { + sammy = { + isNormalUser = true; + extraGroups = [ "networkmanager" "wheel" "docker" ]; + shell = pkgs.nushell; + + }; + }; +} +