From 55e4c663f4326eb3446fb96d721c3dff75d00870 Mon Sep 17 00:00:00 2001 From: Ivan Kirilov Dimitrov Date: Mon, 10 Jun 2024 22:41:40 +0200 Subject: [PATCH] still working --- default.nix | 5 + flake.nix | 39 +--- modules/nixos/wireguard/default.nix | 18 -- nixos/default.nix | 14 +- nixos/laptop/default.nix | 180 --------------- nixos/modules/default.nix | 207 ++++++++++++++++++ nixos/systems/default.nix | 11 + .../systems/laptop-hardware.nix | 0 8 files changed, 226 insertions(+), 248 deletions(-) create mode 100644 default.nix delete mode 100644 modules/nixos/wireguard/default.nix delete mode 100644 nixos/laptop/default.nix create mode 100644 nixos/modules/default.nix create mode 100644 nixos/systems/default.nix rename hardware-configuration.nix => nixos/systems/laptop-hardware.nix (100%) diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..4743854 --- /dev/null +++ b/default.nix @@ -0,0 +1,5 @@ +{ ... }: { + imports = [ ./nixos ]; + systems = [ "x86_64-linux" ]; + perSystem = { system, ... }: { }; +} diff --git a/flake.nix b/flake.nix index 6105076..4267152 100644 --- a/flake.nix +++ b/flake.nix @@ -23,42 +23,5 @@ }; catppuccin.url = "github:catppuccin/nix"; }; - outputs = inputs@{ parts, nixpkgs, ide, nid, home-manager, hosts, catppuccin, ... }: - parts.lib.mkFlake { inherit inputs; } { - flake = - let - stateVersion = "24.05"; - my-overlay = self: super: { - scripts = (super.buildEnv { name = "scripts"; paths = [ ./. ]; }); - }; - pkgs = import nixpkgs { - overlays = [ my-overlay ]; - }; - modules = import ./modules { - inherit nixpkgs pkgs ide my-overlay; - system = "x86_64-linux"; - }; - home = import ./home { - inherit stateVersion pkgs modules home-manager nid catppuccin; - system = "x86_64-linux"; - }; - nixos = import ./nixos { - inherit stateVersion nixpkgs modules hosts catppuccin; - system = "x86_64-linux"; - }; - in - { - nixosConfigurations = { - nixos = nixos.laptop; - }; - homeConfigurations = { - ivand = home.ivand; - }; - modules = modules; - }; - systems = [ - "x86_64-linux" - ]; - perSystem = { config, ... }: { }; - }; + outputs = inputs: inputs.parts.lib.mkFlake { inherit inputs; } { imports = [ ./. ]; }; } diff --git a/modules/nixos/wireguard/default.nix b/modules/nixos/wireguard/default.nix deleted file mode 100644 index be49959..0000000 --- a/modules/nixos/wireguard/default.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - networking.wg-quick.interfaces = { - wg0 = { - address = [ "10.0.0.2/24" "fdc9:281f:04d7:9ee9::2/64" ]; - dns = [ "1.1.1.1" "fdc9:281f:04d7:9ee9::1" ]; - privateKeyFile = "/etc/wireguard/privatekey"; - - peers = [ - { - publicKey = "5FiTLnzbgcbgQLlyVyYeESEd+2DtwM1JHCGz/32UcEU="; - allowedIPs = [ "0.0.0.0/0" "::/0" ]; - endpoint = "37.205.13.29:51820"; - persistentKeepalive = 25; - } - ]; - }; - }; -} diff --git a/nixos/default.nix b/nixos/default.nix index 047b27b..f582c2b 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -1,13 +1,3 @@ -{ stateVersion, system, nixpkgs, modules, hosts, catppuccin, ... }: { - laptop = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - { system.stateVersion = stateVersion; } - ../hardware-configuration.nix - ./laptop - modules.nixos.wireguard - hosts.nixosModule - catppuccin.nixosModules.catppuccin - ]; - }; +{ ... }: { + imports = [ ./modules ./systems ]; } diff --git a/nixos/laptop/default.nix b/nixos/laptop/default.nix deleted file mode 100644 index 446a9fa..0000000 --- a/nixos/laptop/default.nix +++ /dev/null @@ -1,180 +0,0 @@ -{ config, pkgs, ... }: { - - nix = { - extraOptions = '' - experimental-features = nix-command flakes - ''; - }; - - hardware = { - opengl = { - enable = true; - driSupport = true; - }; - }; - - catppuccin = { - enable = true; - flavor = "mocha"; - }; - - boot = { - loader = { - grub = { - enable = true; - catppuccin.enable = true; - useOSProber = true; - efiSupport = true; - device = "nodev"; - }; - efi = { - canTouchEfiVariables = true; - efiSysMountPoint = "/boot/efi"; - }; - }; - extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ]; - kernelModules = [ "v4l2loopback" ]; - }; - - security = { - sudo = { - enable = false; - execWheelOnly = true; - extraRules = [ - { - groups = [ "wheel" ]; - commands = [{ command = "${pkgs.light}/bin/light"; options = [ "SETENV" "NOPASSWD" ]; }]; - } - ]; - }; - doas = { - enable = true; - extraRules = [ - # Allow wheel to run all commands without password and keep user env. - { groups = [ "wheel" ]; noPass = true; keepEnv = true; } - ]; - }; - polkit.enable = true; - rtkit.enable = true; - pam = { services = { swaylock = { }; }; }; - }; - - xdg = { - portal = { - enable = true; - wlr.enable = true; - config.common.default = "*"; - }; - }; - - i18n.supportedLocales = [ "all" ]; - - time.timeZone = "Europe/Prague"; - - fonts.packages = with pkgs; [ (nerdfonts.override { fonts = [ "FiraCode" ]; }) noto-fonts noto-fonts-emoji noto-fonts-lgc-plus ]; - - environment = { - systemPackages = with pkgs; [ - cmatrix - coreutils-full - cryptsetup - dig - fd - file - git - glibc - gnumake - jq - mlocate - moreutils - ntfs3g - openssl - srm - unzip - vim - zip - ]; - shells = with pkgs; [ zsh nushell ]; - }; - - networking = { - wireless = { - enable = true; - networks = { - "Smart-Hostel-2.4" = { - psk = "smarttrans.bg"; - }; - "Yohohostel2.4G" = { - psk = "kaskamaska"; - }; - "Nomado_Guest" = { - psk = "welcomehome"; - }; - "HostelMusala Uni" = { - psk = "mhostelm"; - }; - "BOUTIQUE APARTMENTS" = { - psk = "boutique26"; - }; - "Safestay" = { - psk = "AlldayrooftopBAR"; - }; - "HOSTEL JASMIN 2" = { - psk = "Jasmin2024"; - }; - "HOME" = { - psk = "iloveprague"; - }; - "Vodafone-B925" = { - psk = "7aGh3FE6pN4p4cu6"; - }; - }; - }; - stevenBlackHosts = { - enable = true; - blockFakenews = true; - blockGambling = true; - }; - }; - - programs = { - zsh.enable = true; - nix-ld.enable = true; - adb.enable = true; - dconf.enable = true; - }; - - users = { - defaultUserShell = pkgs.zsh; - users = { - ivand = { - isNormalUser = true; - extraGroups = [ - "adbusers" - "adm" - "audio" - "bluetooth" - "dialout" - "flatpak" - "kvm" - "mlocate" - "render" - "video" - "wheel" - ]; - }; - }; - extraGroups = { mlocate = { }; }; - }; - - services = { - xserver.videoDrivers = [ "nouveau" ]; - dbus.enable = true; - flatpak.enable = true; - pipewire = { - enable = true; - alsa.enable = true; - pulse.enable = true; - }; - }; -} diff --git a/nixos/modules/default.nix b/nixos/modules/default.nix new file mode 100644 index 0000000..953099e --- /dev/null +++ b/nixos/modules/default.nix @@ -0,0 +1,207 @@ +{ inputs, ... }: +let pkgs = import inputs.nixpkgs { system = "x86_64-linux"; }; in { + flake.nixosModules = { + wireguard = { + networking.wg-quick.interfaces = { + wg0 = { + address = [ "10.0.0.2/24" "fdc9:281f:04d7:9ee9::2/64" ]; + dns = [ "1.1.1.1" "fdc9:281f:04d7:9ee9::1" ]; + privateKeyFile = "/etc/wireguard/privatekey"; + + peers = [ + { + publicKey = "5FiTLnzbgcbgQLlyVyYeESEd+2DtwM1JHCGz/32UcEU="; + allowedIPs = [ "0.0.0.0/0" "::/0" ]; + endpoint = "37.205.13.29:51820"; + persistentKeepalive = 25; + } + ]; + }; + }; + }; + catppuccin = { + catppuccin = { + enable = true; + flavor = "mocha"; + }; + boot.loader.grub.catppuccin.enable = true; + }; + boot = { + boot = { + loader = { + grub = { + enable = true; + useOSProber = true; + efiSupport = true; + device = "nodev"; + }; + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot/efi"; + }; + }; + kernelModules = [ "v4l2loopback" ]; + }; + }; + security = { + security = { + sudo = { + enable = false; + execWheelOnly = true; + extraRules = [ + { + groups = [ "wheel" ]; + commands = [{ command = "${pkgs.light}/bin/light"; options = [ "SETENV" "NOPASSWD" ]; }]; + } + ]; + }; + doas = { + enable = true; + extraRules = [ + # Allow wheel to run all commands without password and keep user env. + { groups = [ "wheel" ]; noPass = true; keepEnv = true; } + ]; + }; + polkit.enable = true; + rtkit.enable = true; + pam = { services = { swaylock = { }; }; }; + }; + + }; + xdg = { + xdg = { + portal = { + enable = true; + wlr.enable = true; + config.common.default = "*"; + }; + }; + }; + networking = { + networking = { + wireless = { + enable = true; + networks = { + "Smart-Hostel-2.4" = { + psk = "smarttrans.bg"; + }; + "Yohohostel2.4G" = { + psk = "kaskamaska"; + }; + "Nomado_Guest" = { + psk = "welcomehome"; + }; + "HostelMusala Uni" = { + psk = "mhostelm"; + }; + "BOUTIQUE APARTMENTS" = { + psk = "boutique26"; + }; + "Safestay" = { + psk = "AlldayrooftopBAR"; + }; + "HOSTEL JASMIN 2" = { + psk = "Jasmin2024"; + }; + "HOME" = { + psk = "iloveprague"; + }; + "Vodafone-B925" = { + psk = "7aGh3FE6pN4p4cu6"; + }; + }; + }; + stevenBlackHosts = { + enable = true; + blockFakenews = true; + blockGambling = true; + }; + }; + }; + users = { + users = { + defaultUserShell = pkgs.zsh; + users = { + ivand = { + isNormalUser = true; + extraGroups = [ + "adbusers" + "adm" + "audio" + "bluetooth" + "dialout" + "flatpak" + "kvm" + "mlocate" + "render" + "video" + "wheel" + ]; + }; + }; + extraGroups = { mlocate = { }; }; + }; + }; + services = { + services = { + xserver.videoDrivers = [ "nouveau" ]; + dbus.enable = true; + flatpak.enable = true; + pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + }; + }; + }; + programs = { + programs = { + zsh.enable = true; + nix-ld.enable = true; + adb.enable = true; + dconf.enable = true; + }; + }; + env = { + environment = { + systemPackages = with pkgs; [ + cmatrix + coreutils-full + cryptsetup + dig + fd + file + git + glibc + gnumake + jq + mlocate + moreutils + ntfs3g + openssl + srm + unzip + vim + zip + ]; + shells = with pkgs; [ zsh nushell ]; + }; + }; + rest = { + nix = { + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + hardware = { + opengl = { + enable = true; + driSupport = true; + }; + }; + i18n.supportedLocales = [ "all" ]; + time.timeZone = "Europe/Prague"; + fonts.packages = with pkgs; [ (nerdfonts.override { fonts = [ "FiraCode" ]; }) noto-fonts noto-fonts-emoji noto-fonts-lgc-plus ]; + }; + }; +} diff --git a/nixos/systems/default.nix b/nixos/systems/default.nix new file mode 100644 index 0000000..b8279af --- /dev/null +++ b/nixos/systems/default.nix @@ -0,0 +1,11 @@ +{ inputs, config, ... }: { + flake.nixosConfigurations = { + nixos = inputs.nixpkgs.lib.nixosSystem { + modules = [ + ./laptop-hardware.nix + inputs.hosts.nixosModule + inputs.catppuccin.nixosModules.catppuccin + ] ++ (with config.flake.nixosModules; [ wireguard catppuccin boot security xdg networking users services programs env rest ]); + }; + }; +} diff --git a/hardware-configuration.nix b/nixos/systems/laptop-hardware.nix similarity index 100% rename from hardware-configuration.nix rename to nixos/systems/laptop-hardware.nix