diff --git a/.gitignore b/.gitignore index a806510..eff8d44 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ # Ignore build outputs from performing a nix-build or `nix build` command result result-* - +*.swp diff --git a/configuration.nix b/configuration.nix.bak similarity index 94% rename from configuration.nix rename to configuration.nix.bak index d3ce799..bff24e0 100644 --- a/configuration.nix +++ b/configuration.nix.bak @@ -8,6 +8,8 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + ./system/services/cups.nix + ./system/services/ssh.nix ]; # Use the systemd-boot EFI boot loader. @@ -46,7 +48,7 @@ # services.xserver.xkb.options = "eurosign:e,caps:escape"; # Enable CUPS to print documents. - services.printing.enable = true; + #services.printing.enable = true; # Enable sound. hardware.pulseaudio.enable = true; @@ -76,8 +78,14 @@ wget htop mc + git ]; + nix.package = pkgs.nixFlakes; + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + # Some programs need SUID wrappers, can be configured further or are # started in user sessions. # programs.mtr.enable = true; @@ -89,7 +97,7 @@ # List services that you want to enable: # Enable the OpenSSH daemon. - services.openssh.enable = true; + #services.openssh.enable = true; # Open ports in the firewall. # networking.firewall.allowedTCPPorts = [ ... ]; diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f98425d --- /dev/null +++ b/flake.nix @@ -0,0 +1,69 @@ +{ + description = "kenryuS nixos configurations/dotfiles"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05"; + home-manager.url = "github:nix-community/home-manager/release-24.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + }; + + outputs = inputs@{ nixpkgs, home-manager, ... }: + let + systemSettings = { + system = "x86_64-linux"; + hostname = "kenryu-nixos"; + machine = "workstation"; + timezone = "Asia/Tokyo"; + locale = "ja_JP.UTF-8"; + bootConf = { + mode = "uefi"; + mountPath = "/boot"; + grubDev = ""; + }; + gpuType = "nvidia"; + }; + + userSettings = { + username = "kenryus"; + name = "Kenryu Shibata"; + email-dev = "kenryudev5894@gmail.com"; + dotfilesDir = "/etc/nixos"; + editor = "nvim"; + editor-pkg = pkgs.neovim; + }; + + pkgs = import inputs.nixpkgs { + system = systemSettings.system; + config = { + allowUnfree = true; + allowUnfreePredicate = (_: true); + }; + }; + + lib = inputs.nixpkgs.lib; + home-manager = inputs.home-manager; + in { + nixOSConfiguration = { + system = lib.nixosSystem { + system = systemSettings.system; + modules = [ + ("./machines/" + systemSettings.machine + "/configuration.nix") + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${userSettings.username} = import ("./machines/" + systemSettings.machine + "/home.nix"); + home-manager.extraSpecialArgs = { + inherit userSettings; + }; + } + ]; + specialArgs = { + inherit systemSettings; + inherit userSettings; + inherit inputs; + }; + }; + }; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix.bak similarity index 100% rename from hardware-configuration.nix rename to hardware-configuration.nix.bak diff --git a/machines/base.nix b/machines/base.nix new file mode 100644 index 0000000..85387a1 --- /dev/null +++ b/machines/base.nix @@ -0,0 +1,39 @@ +{ pkgs, lib, config, systemSettings, userSettings, ... }: +{ + imports = [ + ../system/hardware/audio.nix + ../system/hardware/time.nix + ../system/services/network-manager.nix + ../system/utils.nix + ]; + + time.timeZone = systemSettings.timezone; + + networking.hostName = systemSettings.hostname; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + i18n.defaultLocale = systemSettings.locale; + i18n.extraLocaleSettings = { + LC_ADDRESS = systemSettings.locale; + LC_IDENTIFICATION = systemSettings.locale; + LC_MEASUREMENT = systemSettings.locale; + LC_MONETARY = systemSettings.locale; + LC_NAME = systemSettings.locale; + LC_NUMERIC = systemSettings.locale; + LC_PAPER = systemSettings.locale; + LC_TELEPHONE = systemSettings.locale; + LC_TIME = systemSettings.locale; + }; + + users.users.${userSettings.username} = { + isNormalUser = true; + description = userSettings.name; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; []; + uid = 1000; + }; + + envirnment.shells = with pkgs; [ bash ]; + users.defaultUserShell = pkgs.bash; +} diff --git a/machines/workstation/configuration.nix b/machines/workstation/configuration.nix new file mode 100644 index 0000000..729601c --- /dev/null +++ b/machines/workstation/configuration.nix @@ -0,0 +1,50 @@ +# 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 + ../base.nix + ../../system/services/cups.nix + ../../system/services/ssh.nix + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Configure keymap in X11 + # services.xserver.xkb.layout = "us"; + # services.xserver.xkb.options = "eurosign:e,caps:escape"; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # 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 - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how + # to actually do that. + # + # 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 = "24.05"; # Did you read the comment? + +} + diff --git a/machines/workstation/hardware-configuration.nix b/machines/workstation/hardware-configuration.nix new file mode 100644 index 0000000..1ca7675 --- /dev/null +++ b/machines/workstation/hardware-configuration.nix @@ -0,0 +1,41 @@ +# 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" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/f4c95da6-3c6b-4414-a62a-c8c26c4a1c73"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/C83C-841F"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/d933c349-8e70-41e1-8d13-605656dba18b"; } + ]; + + # 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; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/machines/workstation/home.nix b/machines/workstation/home.nix new file mode 100644 index 0000000..95e4e32 --- /dev/null +++ b/machines/workstation/home.nix @@ -0,0 +1,13 @@ +{ pkgs, userSettings, ... }: +{ + home.username = userSettings.username; + home.homeDirectory = "/home/" + userSettings.username; + + programs.home-manager.enable = true; + + imports = []; + + home.stateVersion = "24.05"; + + home.packages = with pkgs; []; +} diff --git a/system/hardware/audio.nix b/system/hardware/audio.nix new file mode 100644 index 0000000..0947c5d --- /dev/null +++ b/system/hardware/audio.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + hardware.pulseaudio.enable = true; +} diff --git a/system/hardware/bluetooth.nix b/system/hardware/bluetooth.nix new file mode 100644 index 0000000..b3a80f0 --- /dev/null +++ b/system/hardware/bluetooth.nix @@ -0,0 +1,5 @@ +{ ... }: +{ + hardware.bluetooth.enable = true; + services.blueman.enable = true; +} diff --git a/system/hardware/kernel.nix b/system/hardware/kernel.nix new file mode 100644 index 0000000..9d1f31c --- /dev/null +++ b/system/hardware/kernel.nix @@ -0,0 +1,5 @@ +{ config, pkgs, ... }: +{ + boot.kernelPackages = pkgs.linuxPackages_xanmod_stable; + boot.consoleLogLevel = 3; +} diff --git a/system/hardware/opengl.nix b/system/hardware/opengl.nix new file mode 100644 index 0000000..6b738e5 --- /dev/null +++ b/system/hardware/opengl.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: +{ + hardware.opengl.enable = true; + hardware.opengl.extraPackages = with pkgs; [ + mesa + ]; +} diff --git a/system/hardware/time.nix b/system/hardware/time.nix new file mode 100644 index 0000000..44b1f23 --- /dev/null +++ b/system/hardware/time.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + services.timesyncd.enable = true; +} diff --git a/system/services/cups.nix b/system/services/cups.nix new file mode 100644 index 0000000..6cfd0e5 --- /dev/null +++ b/system/services/cups.nix @@ -0,0 +1,4 @@ +{...}: +{ + services.printing.enable = true; +} diff --git a/system/services/network-manager.nix b/system/services/network-manager.nix new file mode 100644 index 0000000..68c1cf1 --- /dev/null +++ b/system/services/network-manager.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + networking.networkmanager.enable = true; +} diff --git a/system/services/ssh.nix b/system/services/ssh.nix new file mode 100644 index 0000000..da6800f --- /dev/null +++ b/system/services/ssh.nix @@ -0,0 +1,9 @@ +{...}: +{ + services.openssh = { + enable = true; + settings = { + PermitRootLogin = "yes"; + }; + }; +} diff --git a/system/utils.nix b/system/utils.nix new file mode 100644 index 0000000..6315379 --- /dev/null +++ b/system/utils.nix @@ -0,0 +1,13 @@ +{ lib, pkgs, ... }: +{ + # minimal utilities for using linux + environment.systemPackages = with pkgs; [ + vim + wget + htop + mc + git + parted + tree + ]; +}