From 67c25da50b583ae0acc98adebf25cfd84bbcf297 Mon Sep 17 00:00:00 2001 From: user Date: Mon, 7 Sep 2026 23:18:21 +0400 Subject: [PATCH] feat(nixos): add initial NixOS and Home Manager configuration --- nixos/nix/flake.lock | 134 ++++++++++++++++++ nixos/nix/flake.nix | 38 +++++ nixos/nix/modules/home-manager/users/user.nix | 21 +++ nixos/nix/modules/nixos/features/niri.nix | 31 ++++ nixos/nix/modules/nixos/features/noctalia.nix | 10 ++ nixos/nix/modules/nixos/features/sddm.nix | 42 ++++++ .../nixos/hosts/laptop/configuration.nix | 48 +++++++ .../modules/nixos/hosts/laptop/default.nix | 12 ++ .../modules/nixos/hosts/laptop/hardware.nix | 59 ++++++++ nixos/nix/modules/nixos/services/ssh.nix | 14 ++ 10 files changed, 409 insertions(+) create mode 100644 nixos/nix/flake.lock create mode 100644 nixos/nix/flake.nix create mode 100644 nixos/nix/modules/home-manager/users/user.nix create mode 100644 nixos/nix/modules/nixos/features/niri.nix create mode 100644 nixos/nix/modules/nixos/features/noctalia.nix create mode 100644 nixos/nix/modules/nixos/features/sddm.nix create mode 100644 nixos/nix/modules/nixos/hosts/laptop/configuration.nix create mode 100644 nixos/nix/modules/nixos/hosts/laptop/default.nix create mode 100644 nixos/nix/modules/nixos/hosts/laptop/hardware.nix create mode 100644 nixos/nix/modules/nixos/services/ssh.nix diff --git a/nixos/nix/flake.lock b/nixos/nix/flake.lock new file mode 100644 index 0000000..75ebc91 --- /dev/null +++ b/nixos/nix/flake.lock @@ -0,0 +1,134 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1782949081, + "narHash": "sha256-vp6Y/Grm98ESt6ceOkWiHWyZRDV3J1RID4w+6NWK9yA=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "17c9d6cdfc60c64f4ee8d306f9bc0b4ccb51481e", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1783221248, + "narHash": "sha256-ESQnuNHEDChsB4IxoLRhscVahqkDWkTb+qdIz8euYt4=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "af2beae5f0fae0a4310cc0e6aef2572f56090353", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-26.05", + "repo": "home-manager", + "type": "github" + } + }, + "import-tree": { + "locked": { + "lastModified": 1778781969, + "narHash": "sha256-Jjuz5CmSkur8KvLDoGa+vylEp+RkQtv4mt/qcMznpH0=", + "owner": "vic", + "repo": "import-tree", + "rev": "d321337efd0f23a9eb14a42adb7b2c29313ab274", + "type": "github" + }, + "original": { + "owner": "vic", + "repo": "import-tree", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1783389287, + "narHash": "sha256-0xIy4dVLqq47rA+mRy0hXDfjhQd4E5PoIns/RmB7nR4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0ad6f47ea4fe188f4bc8f0380f93ae8523337c6c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1782614948, + "narHash": "sha256-ePjCwr1sNm9NYUqywL7QfK3JnlS015msC+eBu2zKlp8=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "db3f255737b94216eb71cce308e2912cf6bc2d7c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1780336545, + "narHash": "sha256-vhVhuXzFrIOfcssC/9hDHx7MHzDKjF3keHuREOQqQiQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4df1b885d76a54e1aa1a318f8d16fd6005b6401f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "home-manager": "home-manager", + "import-tree": "import-tree", + "nixpkgs": "nixpkgs", + "wrapper-modules": "wrapper-modules" + } + }, + "wrapper-modules": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1782135443, + "narHash": "sha256-vAmbArdCyjqpVW+37aCy/PMBOLIqukUXLQuEKLwUhA4=", + "owner": "BirdeeHub", + "repo": "nix-wrapper-modules", + "rev": "6e7f66fa2cdf4d63162580b438f7fcf87c28a46f", + "type": "github" + }, + "original": { + "owner": "BirdeeHub", + "repo": "nix-wrapper-modules", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nixos/nix/flake.nix b/nixos/nix/flake.nix new file mode 100644 index 0000000..09da8db --- /dev/null +++ b/nixos/nix/flake.nix @@ -0,0 +1,38 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; + + home-manager = { + url = "github:nix-community/home-manager/release-26.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-parts.url = "github:hercules-ci/flake-parts"; + + import-tree.url = "github:vic/import-tree"; + + wrapper-modules.url = "github:BirdeeHub/nix-wrapper-modules"; + }; + + outputs = inputs@{ flake-parts, import-tree, home-manager, ... }: + let + mkFlake = flake-parts.lib.mkFlake; + + flakeArgs = { + inherit inputs; + }; + + flakeConfig = { + imports = [ + home-manager.flakeModules.home-manager + (import-tree ./modules) + ]; + + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + }; + in + mkFlake flakeArgs flakeConfig; +} diff --git a/nixos/nix/modules/home-manager/users/user.nix b/nixos/nix/modules/home-manager/users/user.nix new file mode 100644 index 0000000..4b8f1c6 --- /dev/null +++ b/nixos/nix/modules/home-manager/users/user.nix @@ -0,0 +1,21 @@ +{ self, withSystem, inputs, ... }: + +{ + flake.homeConfigurations.user = + withSystem "x86_64-linux" ({ pkgs, ... }: + inputs.home-manager.lib.homeManagerConfiguration { + inherit pkgs; + + modules = with self.homeModules; [ + bash + cursor + kitty + + { + home.username = "user"; + home.homeDirectory = "/home/user"; + home.stateVersion = "26.05"; + } + ]; + }); +} diff --git a/nixos/nix/modules/nixos/features/niri.nix b/nixos/nix/modules/nixos/features/niri.nix new file mode 100644 index 0000000..2a8bf17 --- /dev/null +++ b/nixos/nix/modules/nixos/features/niri.nix @@ -0,0 +1,31 @@ +{ self, inputs, ... }: { + flake.nixosModules.niri = { pkgs, lib, ... }: { + programs.niri = { + enable = true; + package = self.packages.${pkgs.stdenv.hostPlatform.system}.myNiri; + }; + }; + + perSystem = { pkgs, lib, self', ... }: { + packages.myNiri = inputs.wrapper-modules.wrappers.niri.wrap { + inherit pkgs; + settings = { + spawn-at-startup = [ + (lib.getExe self'.packages.myNoctalia) + ]; + + xwayland-satellite.path = lib.getExe pkgs.xwayland-satellite; + + input.keyboard.xkb.layout = "us,ru"; + + layout.gaps = 5; + + # binds = { + # "Mod+Return".spawn-sh = lib.getExe pkgs.kitty; + # "Mod+Q".close-window = {}; + # "Mod+S".spawn-sh = "${lib.getExe self'.packages.myNoctalia} ipc call launcher toggle"; + # }; + }; + }; + }; +} diff --git a/nixos/nix/modules/nixos/features/noctalia.nix b/nixos/nix/modules/nixos/features/noctalia.nix new file mode 100644 index 0000000..b5c91b3 --- /dev/null +++ b/nixos/nix/modules/nixos/features/noctalia.nix @@ -0,0 +1,10 @@ +{ self, inputs, ... }: { + perSystem = { pkgs, ... }: { + packages.myNoctalia = inputs.wrapper-modules.wrappers.noctalia-shell.wrap { + inherit pkgs; + # settings = + # (builtins.fromJSON + # (builtins.readFile ./noctalia.json)).settings; + }; + }; +} diff --git a/nixos/nix/modules/nixos/features/sddm.nix b/nixos/nix/modules/nixos/features/sddm.nix new file mode 100644 index 0000000..50184d8 --- /dev/null +++ b/nixos/nix/modules/nixos/features/sddm.nix @@ -0,0 +1,42 @@ +{ ... }: { + flake.nixosModules.sddm = { pkgs, ... }: + + let + sddm-astrounaut = pkgs.sddm-astronaut.override { + embeddedTheme = "astronaut"; + + # astronaut + # black_hole + # cyberpunk + # hyprland_kath + # jake_the_dog + # japanese_aesthetic + # japanese_aesthetic + # pixel_sakura + # pixel_sakura_static + # post-apocalyptic_hacker + # purple_leaves + + }; + in { + + environment.systemPackages = with pkgs; [ + sddm-astrounaut + ]; + + services.displayManager.sddm = { + enable = true; + + package = pkgs.kdePackages.sddm; + + theme = "sddm-astronaut-theme"; + + extraPackages = with pkgs; [ + kdePackages.qtmultimedia + ]; + }; + + services.xserver.enable = true; + + }; +} diff --git a/nixos/nix/modules/nixos/hosts/laptop/configuration.nix b/nixos/nix/modules/nixos/hosts/laptop/configuration.nix new file mode 100644 index 0000000..8a103c0 --- /dev/null +++ b/nixos/nix/modules/nixos/hosts/laptop/configuration.nix @@ -0,0 +1,48 @@ +{ self, inputs, ... }: + +let + machine = builtins.baseNameOf ./.; +in +{ + flake.nixosModules."${machine}Configuration" = { pkgs, lib, ... }: { + imports = [ + self.nixosModules."${machine}Hardware" + self.nixosModules.ssh + self.nixosModules.niri + self.nixosModules.sddm + ]; + + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; + + environment.systemPackages = with pkgs; [ + git + vim + wget + curl + neovim + firefox + tree + inputs.home-manager.packages.${pkgs.system}.default + ]; + + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + }; + + networking.hostName = "nixos-macbook-air-2017"; + networking.networkmanager.enable = true; + + users.users.user = { + isNormalUser = true; + extraGroups = [ "wheel" "input" "networkmanager" ]; + }; + + system.stateVersion = "26.05"; + }; +} diff --git a/nixos/nix/modules/nixos/hosts/laptop/default.nix b/nixos/nix/modules/nixos/hosts/laptop/default.nix new file mode 100644 index 0000000..806a42c --- /dev/null +++ b/nixos/nix/modules/nixos/hosts/laptop/default.nix @@ -0,0 +1,12 @@ +{ self, inputs, ... }: + +let + machine = builtins.baseNameOf ./.; +in +{ + flake.nixosConfigurations.${machine} = inputs.nixpkgs.lib.nixosSystem { + modules = [ + self.nixosModules."${machine}Configuration" + ]; + }; +} diff --git a/nixos/nix/modules/nixos/hosts/laptop/hardware.nix b/nixos/nix/modules/nixos/hosts/laptop/hardware.nix new file mode 100644 index 0000000..e0c28b2 --- /dev/null +++ b/nixos/nix/modules/nixos/hosts/laptop/hardware.nix @@ -0,0 +1,59 @@ +{ ... }: + +let + machine = builtins.baseNameOf ./.; +in +{ + flake.nixosModules."${machine}Hardware" = { config, lib, modulesPath, ... }: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot = { + initrd = { + availableKernelModules = [ + "xhci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + + kernelModules = [ ]; + }; + + kernelModules = [ + "kvm-intel" + ]; + + extraModulePackages = [ ]; + }; + + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/992b8f95-6ca7-475d-b3ab-54c4339619e6"; + fsType = "ext4"; + }; + + "/boot" = { + device = "/dev/disk/by-uuid/A1EC-32E5"; + fsType = "vfat"; + options = [ + "fmask=0022" + "dmask=0022" + ]; + }; + }; + + swapDevices = [ + { + device = "/dev/disk/by-uuid/bfb36fe8-16b4-4ea5-a8dd-0f90b5dde2fb"; + } + ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; + }; +} diff --git a/nixos/nix/modules/nixos/services/ssh.nix b/nixos/nix/modules/nixos/services/ssh.nix new file mode 100644 index 0000000..5a5e866 --- /dev/null +++ b/nixos/nix/modules/nixos/services/ssh.nix @@ -0,0 +1,14 @@ +{ ... }: + +{ + flake.nixosModules.ssh = { ... }: { + services.openssh = { + enable = true; + + settings = { + PasswordAuthentication = false; + PermitRootLogin = "no"; + }; + }; + }; +}