diff options
-rw-r--r-- | flake.lock | 48 | ||||
-rw-r--r-- | flake.nix | 44 | ||||
-rw-r--r-- | home-manager/home.nix | 60 | ||||
-rw-r--r-- | nixos/configuration.nix | 85 | ||||
-rw-r--r-- | nixos/hardware-configuration.nix | 39 | ||||
-rw-r--r-- | nixos/services/display-manager.nix | 11 |
6 files changed, 287 insertions, 0 deletions
diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b0af64c --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722321190, + "narHash": "sha256-WeVWVRqkgrbLzmk6FfJoloJ7Xe7HWD27Pv950IUG2kI=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "4fcd54df7cbb1d79cbe81209909ee8514d6b17a4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1722185531, + "narHash": "sha256-veKR07psFoJjINLC8RK4DiLniGGMgF3QMlS4tb74S6k=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "52ec9ac3b12395ad677e8b62106f0b98c1f8569d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "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..529a83d --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + description = "Your new nix config"; + + inputs = { + # Nixpkgs + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + # Home manager + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { + self, + nixpkgs, + home-manager, + ... + } @ inputs: let + inherit (self) outputs; + myHostName = "homelab-nix"; + stevenUserName = "stvnliu"; + in { + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + nixosConfigurations = { + "${myHostName}" = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs;}; + # > Our main nixos configuration file < + modules = [./nixos/configuration.nix]; + }; + }; + + # Standalone home-manager configuration entrypoint + # Available through 'home-manager --flake .#your-username@your-hostname' + homeConfigurations = { + "${stevenUserName}@${myHostName}" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance + extraSpecialArgs = {inherit inputs outputs;}; + # > Our main home-manager configuration file < + modules = [./home-manager/${stevenUserName}/home.nix]; + }; + }; + }; +} diff --git a/home-manager/home.nix b/home-manager/home.nix new file mode 100644 index 0000000..5f20559 --- /dev/null +++ b/home-manager/home.nix @@ -0,0 +1,60 @@ +# This is your home-manager configuration file +# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) +{ + inputs, + lib, + config, + pkgs, + ... +}: { + # You can import other home-manager modules here + imports = [ + # If you want to use home-manager modules from other flakes (such as nix-colors): + # inputs.nix-colors.homeManagerModule + + # You can also split up your configuration and import pieces of it here: + # ./nvim.nix + ]; + + nixpkgs = { + # You can add overlays here + overlays = [ + # If you want to use overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = _: true; + }; + }; + + # TODO: Set your username + home = { + username = "your-username"; + homeDirectory = "/home/your-username"; + }; + + # Add stuff for your user as you see fit: + # programs.neovim.enable = true; + # home.packages = with pkgs; [ steam ]; + + # Enable home-manager and git + programs.home-manager.enable = true; + programs.git.enable = true; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + home.stateVersion = "23.05"; +} diff --git a/nixos/configuration.nix b/nixos/configuration.nix new file mode 100644 index 0000000..bbcc3f8 --- /dev/null +++ b/nixos/configuration.nix @@ -0,0 +1,85 @@ +# This is your system's configuration file. +# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) +{ + inputs, + lib, + config, + pkgs, + ... +}: +let +myHostName = "homelab-nix"; +stevenUserName = "stvnliu"; +in +{ + imports = [ +#inputs.hardware.nixosModules.common-cpu-amd +#inputs.hardware.nixosModules.common-ssd + ./hardware-configuration.nix + ./services/display-manager.nix + ]; + boot.loader = { + efi.canTouchEfiVariables = true; + grub = { + enable = true; + useOSProber = true; + efiSupport = true; + fsIdentifier = "label"; + devices = [ "nodev" ]; + extraEntries = '' + menuentry "Reboot" { + reboot + } + menuentry "Poweroff" { + halt + } + ''; + }; + }; + nixpkgs = { + overlays = [ + ]; + config = { + allowUnfree = true; + }; + }; + + nix = let + flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs; + in { + settings = { + experimental-features = "nix-command flakes"; + flake-registry = ""; + nix-path = config.nix.nixPath; + }; + registry = lib.mapAttrs (_: flake: {inherit flake;}) flakeInputs; + nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs; + }; + networking = { + hostName = "${myHostName}"; + networkmanager.enable = true; + }; + users.users = { + "${stevenUserName}" = { + initialPassword = "stevenpassword"; + isNormalUser = true; + openssh.authorizedKeys.keys = [ + ]; + packages = with pkgs; [ + nh + neovim + gitFull + ]; + extraGroups = ["wheel"]; + }; + }; + services.openssh = { + enable = true; + settings = { + PermitRootLogin = "no"; + PasswordAuthentication = false; + }; + }; +# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = "24.05"; +} diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix new file mode 100644 index 0000000..b18ecf7 --- /dev/null +++ b/nixos/hardware-configuration.nix @@ -0,0 +1,39 @@ +# 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" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/f9ff609f-6e72-43cf-917c-3bd3fde6c410"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/2E4F-3060"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + 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.<interface>.useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp3s0.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/nixos/services/display-manager.nix b/nixos/services/display-manager.nix new file mode 100644 index 0000000..edbd360 --- /dev/null +++ b/nixos/services/display-manager.nix @@ -0,0 +1,11 @@ +{ pkgs, lib, ... }: +{ + programs.sway = { + enable = true; + wrapperFeatures.gtk = true; + }; + services.displayManager = { + enable = true; + execCmd = "${pkgs.lemurs}/bin/lemurs --no-logs"; + }; +} |