From 5517f337e1f3e813258bd3b7b9070979c2865c27 Mon Sep 17 00:00:00 2001 From: caem Date: Sun, 18 Jun 2023 22:52:24 +0200 Subject: [PATCH] Add initial framework for config --- README.md | 41 ----------- common.nix | 20 ++++++ configuration.nix | 43 ------------ environments/plasma.nix | 11 --- flake.lock | 60 ++++++++++++++++ flake.nix | 26 +++++++ packages/vim/package.nix | 35 ++++++++++ profile.nix | 2 - profiles/workstation.nix | 69 ------------------- sets/base/common.nix | 11 --- sets/base/devel.nix | 9 --- sets/base/plasma.nix | 7 -- sets/devel/c.nix | 11 --- sets/devel/git.nix | 7 -- sets/drivers/nvidia.nix | 8 --- sets/drivers/tablet.nix | 7 -- sets/graphics/art.nix | 9 --- sets/graphics/video.nix | 8 --- sets/meta/sysadmin.nix | 11 +++ .../hardware/qemu-vm.nix | 19 ++--- systems/qemu-vm.nix | 13 ++++ username.nix | 2 +- users/none.nix | 1 + users/user.nix | 44 +++++------- 24 files changed, 190 insertions(+), 284 deletions(-) delete mode 100644 README.md create mode 100644 common.nix delete mode 100644 configuration.nix delete mode 100644 environments/plasma.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 packages/vim/package.nix delete mode 100644 profile.nix delete mode 100644 profiles/workstation.nix delete mode 100644 sets/base/common.nix delete mode 100644 sets/base/devel.nix delete mode 100644 sets/base/plasma.nix delete mode 100644 sets/devel/c.nix delete mode 100644 sets/devel/git.nix delete mode 100644 sets/drivers/nvidia.nix delete mode 100644 sets/drivers/tablet.nix delete mode 100644 sets/graphics/art.nix delete mode 100644 sets/graphics/video.nix create mode 100644 sets/meta/sysadmin.nix rename hardware-configuration.nix => systems/hardware/qemu-vm.nix (59%) create mode 100644 systems/qemu-vm.nix create mode 100644 users/none.nix diff --git a/README.md b/README.md deleted file mode 100644 index 87936ee..0000000 --- a/README.md +++ /dev/null @@ -1,41 +0,0 @@ -### Old Hyprland config can be found [here](https://github.com/c4em/nixos-system-config/tree/deprecated) -# nixos-system-config -Modular NixOS configuration with dotfiles. -## Usage -You should have basic knowledge of NixOS before using this project. Begin at `configuration.nix` and read through the files by following imports. -Everything should be commented. If something is not satisfactory, feel free to open up an issue or pull request. -## Layout -``` -/etc/nixos/ -├── configuration.nix ; master configuration file -├── environments ; Desktop environment specific config -│   └── plasma.nix -├── hardware-configuration.nix ; Replace this with your current hardware-configuration.nix -├── overlays ; Package overlays -├── packages ; Package specifix configuration -├── profile.nix ; Specify the profile to use -├── profiles ; Profiles, for example for different machines or workflows -│   └── workstation.nix -├── sets ; Sets of packages to install -│   ├── base -│   │   ├── common.nix -│   │   ├── devel.nix -│   │   └── plasma.nix -│   ├── devel -│   │   ├── c.nix -│   │   └── git.nix -│   ├── drivers -│   │   ├── nvidia.nix -│   │   └── tablet.nix -│   └── graphics -│   ├── art.nix -│   └── video.nix -├── username.nix ; Set current user -└── users ; Users - └── user.nix -``` -## Todo -- [ ] Hyprland configuration -- [ ] Clean up sets directory -- [ ] Add screenshots to README.md -- [ ] Home-manager configuration diff --git a/common.nix b/common.nix new file mode 100644 index 0000000..36f9179 --- /dev/null +++ b/common.nix @@ -0,0 +1,20 @@ +# Common configuration for all systems + +{ config, pkgs, ... }: + +{ + nix = { + settings.auto-optimise-store = true; + + # Clean generations older than a week + gc = { + automatic = false; # Flip this to do it automatically + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + }; + + nixpkgs.config.allowUnfree = true; + + system.stateVersion = "23.05"; +} diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index 2d5071c..0000000 --- a/configuration.nix +++ /dev/null @@ -1,43 +0,0 @@ -# Master configuration file -{ config, pkgs, ... }: -let - # User configurations are stored under ./user/[username].nix - # Set the corresponding value in ./username.nix - user = import ./username.nix; -in -{ - imports = [ - ./users/${user}.nix - - # Include the results of the hardware scan. - ./hardware-configuration.nix - - # Uncomment the profile you want to use - ./profiles/workstation.nix - ]; - - # General NixOS configuration - nix = { - settings.auto-optimise-store = true; - # Automatically remove generations older than a week - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 7d"; - }; - }; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - # Use the unstable channel - system.autoUpgrade = { - enable = true; - channel = "https://nixos.org/channels/nixos-unstable"; - }; - - # 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 = "22.05"; -} - diff --git a/environments/plasma.nix b/environments/plasma.nix deleted file mode 100644 index a19848c..0000000 --- a/environments/plasma.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ - ../sets/base/plasma.nix - ]; - - services.xserver.enable = true; - services.xserver.displayManager.sddm.enable = true; - services.xserver.desktopManager.plasma5.enable = true; -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..14dcb52 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "impermanence": { + "locked": { + "lastModified": 1684264534, + "narHash": "sha256-K0zr+ry3FwIo3rN2U/VWAkCJSgBslBisvfRIPwMbuCQ=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "89253fb1518063556edd5e54509c30ac3089d5e6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1686921029, + "narHash": "sha256-J1bX9plPCFhTSh6E3TWn9XSxggBh/zDD4xigyaIQBy8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c7ff1b9b95620ce8728c0d7bd501c458e6da9e04", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "impermanence": "impermanence", + "nixpkgs": "nixpkgs", + "unstable": "unstable" + } + }, + "unstable": { + "locked": { + "lastModified": 1686960236, + "narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "04af42f3b31dba0ef742d254456dc4c14eedac86", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fc18dd0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,26 @@ +{ + description = "Modular multi-purpose NixOS configuration."; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; + unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + + # https://nixos.wiki/wiki/Impermanence + impermanence.url = "github:nix-community/impermanence"; + }; + + outputs = { self, nixpkgs, ... }@attrs: let + user = import ./username.nix; + in { + # Debugging VM configuration + nixosConfigurations.qemu-vm = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./users/${user}.nix + ./common.nix + ./systems/qemu-vm.nix + ./systems/hardware/qemu-vm.nix + ]; + }; + }; +} diff --git a/packages/vim/package.nix b/packages/vim/package.nix new file mode 100644 index 0000000..53f15b5 --- /dev/null +++ b/packages/vim/package.nix @@ -0,0 +1,35 @@ +{ pkgs, ... }: + +{ + environment.variables = { EDITOR = "vim"; }; + + environment.systemPackages = with pkgs; [ + ((vim_configurable.override { }).customize{ + name = "vim"; + + vimrcConfig.packages.plugins = with pkgs.vimPlugins; { + start = [ vim-nix ]; + opt = []; + }; + + vimrcConfig.customRC = '' + syntax on + set tabstop=4 + set shiftwidth=4 smarttab + set expandtab + set noswapfile + set incsearch + set noerrorbells + set smartindent + set number + set relativenumber + set nobackup + set undofile + set scrolloff=8 + set sidescrolloff=8 + set fileencoding='utf-8' + set nohlsearch + ''; + }) + ]; +} diff --git a/profile.nix b/profile.nix deleted file mode 100644 index b02be5f..0000000 --- a/profile.nix +++ /dev/null @@ -1,2 +0,0 @@ -# Select profile from ./profiles/ directory -"workstation" diff --git a/profiles/workstation.nix b/profiles/workstation.nix deleted file mode 100644 index 68be2bc..0000000 --- a/profiles/workstation.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ - # Environments - ../environments/plasma.nix # KDE/Plasma - # ../environments/hyprland.nix # Todo - - # Package sets - ../sets/base/common.nix - ../sets/drivers/nvidia.nix - ../sets/drivers/tablet.nix - ../sets/base/devel.nix - ../sets/graphics/art.nix - ../sets/graphics/video.nix - ]; - - # Bootloader - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.loader.efi.efiSysMountPoint = "/boot/efi"; - - # Hostname - networking.hostName = "nixos"; - - # Networking - networking.networkmanager.enable = true; - - # Timezone - time.timeZone = "Europe/Berlin"; - - # Locale - i18n.defaultLocale = "en_US.UTF-8"; - console.keyMap = "uk"; - i18n.extraLocaleSettings = { - LC_ADDRESS = "de_DE.UTF-8"; - LC_IDENTIFICATION = "de_DE.UTF-8"; - LC_MEASUREMENT = "de_DE.UTF-8"; - LC_MONETARY = "de_DE.UTF-8"; - LC_NAME = "de_DE.UTF-8"; - LC_NUMERIC = "de_DE.UTF-8"; - LC_PAPER = "de_DE.UTF-8"; - LC_TELEPHONE = "de_DE.UTF-8"; - LC_TIME = "de_DE.UTF-8"; - }; - - services.xserver = { - layout = "gb"; - xkbVariant = ""; - }; - - # Nvidia - services.xserver.videoDrivers = [ "nvidia" ]; - hardware.opengl.enable = true; - hardware.nvidia.modesetting.enable = true; - - # Enable audio - sound.enable = true; - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; - }; -} - diff --git a/sets/base/common.nix b/sets/base/common.nix deleted file mode 100644 index be9e1d3..0000000 --- a/sets/base/common.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ - neovim - firefox - neofetch - tree - ]; -} - diff --git a/sets/base/devel.nix b/sets/base/devel.nix deleted file mode 100644 index 4c8d9cc..0000000 --- a/sets/base/devel.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ - ../devel/git.nix - ../devel/c.nix - ]; -} - diff --git a/sets/base/plasma.nix b/sets/base/plasma.nix deleted file mode 100644 index 1dc2601..0000000 --- a/sets/base/plasma.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ config, pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ - kate - ]; -} diff --git a/sets/devel/c.nix b/sets/devel/c.nix deleted file mode 100644 index 1d1398c..0000000 --- a/sets/devel/c.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ - gcc - clang - clang-tools - gnumake - ]; -} - diff --git a/sets/devel/git.nix b/sets/devel/git.nix deleted file mode 100644 index 197e22e..0000000 --- a/sets/devel/git.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ config, pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ - git - ]; -} diff --git a/sets/drivers/nvidia.nix b/sets/drivers/nvidia.nix deleted file mode 100644 index fdf60e6..0000000 --- a/sets/drivers/nvidia.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ config, pkgs, ... }: - -{ - services.xserver.videoDrivers = [ "nvidia" ]; - hardware.opengl.enable = true; - hardware.nvidia.modesetting.enable = true; -} - diff --git a/sets/drivers/tablet.nix b/sets/drivers/tablet.nix deleted file mode 100644 index c90699c..0000000 --- a/sets/drivers/tablet.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ config, pkgs, ... }: - -{ - hardware.opentabletdriver.enable = true; - hardware.opentabletdriver.daemon.enable = true; -} - diff --git a/sets/graphics/art.nix b/sets/graphics/art.nix deleted file mode 100644 index fa9ceb3..0000000 --- a/sets/graphics/art.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ config, pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ - krita - gimp - ]; -} - diff --git a/sets/graphics/video.nix b/sets/graphics/video.nix deleted file mode 100644 index b3830f7..0000000 --- a/sets/graphics/video.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ config, pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ - kdenlive - ]; -} - diff --git a/sets/meta/sysadmin.nix b/sets/meta/sysadmin.nix new file mode 100644 index 0000000..426ec2d --- /dev/null +++ b/sets/meta/sysadmin.nix @@ -0,0 +1,11 @@ +{ config, pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + htop + wget + curl + ]; + + services.openssh.enable = true; +} diff --git a/hardware-configuration.nix b/systems/hardware/qemu-vm.nix similarity index 59% rename from hardware-configuration.nix rename to systems/hardware/qemu-vm.nix index b7ae331..66180bc 100644 --- a/hardware-configuration.nix +++ b/systems/hardware/qemu-vm.nix @@ -5,30 +5,24 @@ { imports = - [ (modulesPath + "/installer/scan/not-detected.nix") + [ (modulesPath + "/profiles/qemu-guest.nix") ]; - boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; fileSystems."/" = - { device = "/dev/disk/by-uuid/56ec7666-a2ea-4e77-9015-00151b9b7884"; + { device = "/dev/disk/by-uuid/126df580-7925-4bb4-b280-9e7e1c238d3e"; fsType = "btrfs"; - options = [ "subvol=@" ]; }; - fileSystems."/boot/efi" = - { device = "/dev/disk/by-uuid/F076-283D"; + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/8F2D-7123"; fsType = "vfat"; }; - fileSystems."/mnt/vault" = { - device = "/dev/disk/by-uuid/048d175b-0e3e-4ec7-955b-3d9a45f9f237"; - fsType = "xfs"; - }; - swapDevices = [ ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking @@ -36,8 +30,7 @@ # 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.enp34s0.useDHCP = lib.mkDefault true; + # networking.interfaces.enp1s0.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/systems/qemu-vm.nix b/systems/qemu-vm.nix new file mode 100644 index 0000000..5fa99da --- /dev/null +++ b/systems/qemu-vm.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../sets/meta/sysadmin.nix + ../packages/vim/package.nix + ]; + + boot.loader.grub.enable = true; + boot.loader.grub.device = "/dev/vda"; + + time.timeZone = "Europe/Berlin"; +} diff --git a/username.nix b/username.nix index 8cc2f7f..718f367 100644 --- a/username.nix +++ b/username.nix @@ -1,2 +1,2 @@ -# Select user from the ./users/ directory +# Select the user from the ./users directory "user" diff --git a/users/none.nix b/users/none.nix new file mode 100644 index 0000000..a1677ed --- /dev/null +++ b/users/none.nix @@ -0,0 +1 @@ +{ } diff --git a/users/user.nix b/users/user.nix index 32ab12b..da135ab 100644 --- a/users/user.nix +++ b/users/user.nix @@ -1,30 +1,20 @@ { config, pkgs, ... }: + { - imports = [ - ]; - - users.users.user = { - isNormalUser = true; - description = "user"; - extraGroups = [ - "wheel" - "networkmanager" - "audio" - "video" - "docker" - "plugdev" - ]; - }; - - # Set to false to disable sudo password prompt - security = { - sudo.wheelNeedsPassword = true; - }; - -# home-manager.users.user = { -# home.stateVersion = "22.11"; -# }; - - # programs.home-manager.enable = true; + users.users.user = { + isNormalUser = true; + initialPassword = "ReplaceMe"; + description = "user"; + extraGroups = [ + "wheel" + "audio" + "video" + "docker" + "podman" + "networkmanager" + "kvm" + "libvirt" + "plugdev" + ]; + }; } -